code-rag-bench/online-tutorials huggingface dataset:
Initialize a static Map in Java using Double Brace Initialization - GeeksforGeeks

03 Dec, 2019
In this article, a static map is created and initialised in Java using Double Brace Initialization.
Static Map in JavaA static map is a map which is defined as static. It means that the map becomes a class member and can be easily used using class.
Double Brace InitializationIn Double Brace Initialization:
The first brace creates a new Anonymous Inner Class. These inner classes are capable of accessing the behaviour of their parent class. So, in our case, we are actually creating a subclass of HashMap class, so this inner class is capable of using put() method.
The second braces are instance initializers. The code an instance initializers inside is executed whenever an instance is created.
Approach:
Pass the map values as Key and Value pair in the Double braces.
A static factory Map instance is returned.
Store it in Map and use.
Below is the implementation of the above approach:
Example 1:
// Java program to create a static map// using Double Brace Initialization  import java.util.*;  class GFG {      // Declaring and instantiating the static map    // using Double Brace Initialization    private static Map<String, String> map        = new HashMap<String, String>() {{            put("1", "GFG");            put("2", "Geek");            put("3", "GeeksForGeeks");        }};      // Driver code    public static void main(String[] args)    {        System.out.println(map);    }}
{1=GFG, 2=Geek, 3=GeeksForGeeks}

Example 2: To show with 10 key-value pairs
// Java program to create a static map// using Double Brace Initialization  import java.util.*;  class GFG {      // Declaring and instantiating the static map    // using Double Brace Initialization    private static Map<String, String> map        = new HashMap<String, String>() {{            put("1", "GFG");            put("2", "Geek");            put("3", "GeeksForGeeks");            put("4", "G");            put("5", "e");            put("6", "e");            put("7", "k");            put("8", "s");            put("9", "f");            put("10", "o");        }};      // Driver code    public static void main(String[] args)    {        System.out.println(map);    }}
{1=GFG, 2=Geek, 3=GeeksForGeeks, 4=G, 5=e, 6=e, 7=k, 8=s, 9=f, 10=o}

Related Articles:
Initialize a static map in Java with Examples
Initialize a static Map using Stream in Java
Initialize a static Map using Java 9 Map.of()
java-map
Static Keyword
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Different ways of Reading a text file in Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Generics in Java
Comparator Interface in Java with Examples
HashMap get() Method in Java
Introduction to Java
Difference between Abstract Class and Interface in Java
How to output colored text to a Linux terminal?

Here we will see how to print some lines into the linux terminal with some color. Here we are doing anything special into C++ code. We are just using some linux terminal commands to do this. The command for this kind of output is like below.
\033[1;31m Sample Text \033[0m
There are some codes for text styles and colors. These are listed below.
Some additional options are like below −
#include<iostream>
using namespace std;
main() {
   cout << "\033[1;31mThis is bold red text\033[0m\n";
   cout << "\033[;32mGreen Text\033[0m\n";
   cout << "\033[4;33mYellow underlined text\033[0m\n";
   cout << "\033[;34mBlue text\033[0m\n";
}
Exit Methods in C# Application

The Environment.Exit() method terminates the process and returns an exit code to the operating system −
Environment.Exit(exitCode);
Use exitCode as 0 (zero) to show that the process completed successfully.
Use exitCode as a non-zero number to show an error, for example −
Environment.Exit(1) − Return a value 1 to show that the file you want is not present
Environment.Exit(1) − Return a value 1 to show that the file you want is not present
Environment.Exit(2) − Return a value 2 to indicate that the file is in an incorrect format.
Environment.Exit(2) − Return a value 2 to indicate that the file is in an incorrect format.
To close a subapplication or current thread in a Windows Form, use theSystem.Windows.Forms.Application.ExitThread( ).
private void buttonClose_Click(object sender, EventArgs eventArgs) {
   System.Windows.Forms.Application.ExitThread( );
}
Format specifiers in C

The format specifiers are used in C for input and output purposes. Using this concept the compiler can understand that what type of data is in a variable during taking input using the scanf() function and printing using printf() function. Here is a list of format specifiers.
These are the basic format specifiers. We can add some other parts with the format specifiers. These are like below −
A minus symbol (-) sign tells left alignment
A minus symbol (-) sign tells left alignment
A number after % specifies the minimum field width. If string is less than the width, it will be filled with spaces
A number after % specifies the minimum field width. If string is less than the width, it will be filled with spaces
A period (.) is used to separate field width and precision
A period (.) is used to separate field width and precision
 Live Demo
#include <stdio.h>
main() {
   char ch = 'B';
   printf("%c\n", ch); //printing character data
   //print decimal or integer data with d and i
   int x = 45, y = 90;
   printf("%d\n", x);
   printf("%i\n", y);
   float f = 12.67;
   printf("%f\n", f); //print float value
   printf("%e\n", f); //print in scientific notation
   int a = 67;
   printf("%o\n", a); //print in octal format
   printf("%x\n", a); //print in hex format
   char str[] = "Hello World";
   printf("%s\n", str);
   printf("%20s\n", str); //shift to the right 20 characters including the string
   printf("%-20s\n", str); //left align
   printf("%20.5s\n", str); //shift to the right 20 characters including the string, and print string up to 5 character
   printf("%-20.5s\n", str); //left align and print string up to 5 character
}
B
45
90
12.670000
1.267000e+001
103
43
Hello World
Hello World
Hello World
Hello
Hello
We can use these format specifiers for the scanf() function also in the same manner. So we can take the input from scanf() like above how we have printed.
How to create plot in R with different shape of points?

In base R, the plot with different shape of points can be created by using pch argument inside the plot function. The list of pch values with shape is as written below −
pch = 0 display square
pch = 1 display circle
pch = 2 display triangle point up
pch = 3 display plus
pch = 4 display cross
pch = 5 display diamond
pch = 6 display triangle point down
pch = 7 display square cross
pch = 8 display star
pch = 9 display diamond plus
pch = 10 display circle plus
pch = 11 display triangles up and down
pch = 12 display square plus
pch = 13 display circle cross
pch = 14 display square and triangle down
pch = 15 display filled square
pch = 16 display filled circle
pch = 17 display filled triangle point-up
pch = 18 display filled diamond
pch = 19 display solid circle
pch = 20 display bullet (smaller circle)
pch = 21 display filled circle blue
pch = 22 display filled square blue
pch = 23 display filled diamond blue
pch = 24 display filled triangle point-up blue
pch = 25 display filled triangle point down blue
Consider the below vectors and create a point chart with three different shapes −
 Live Demo
x<-sample(0:5,20,replace=TRUE)
y<-sample(1:10,20,replace=TRUE)
plot(x,y,pch=c(16,17,18))
Creating the same plot with different colors of the shapes −
plot(x,y,pch=c(16,17,18),col=c("red","yellow","blue"))
What is strcmp() Function in C language?

The C library function int strcmp(const char *str1, const char *str2) compares the string pointed to, by str1 to the string pointed to by str2.
An array of characters is called a string.
Following is the declaration for an array −
char stringname [size];
For example − char string[50]; string of length 50 characters
Using single character constant −
char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}
Using string constants −
char string[10] = "Hello":;
Accessing − There is a control string "%s" used for accessing the string till it encounters ‘\0’.
This function compares two strings.
This function compares two strings.
It returns the ASCII difference of the first two non – matching characters in both the strings.
It returns the ASCII difference of the first two non – matching characters in both the strings.
The syntax is as follows −
int strcmp (string1, string2);
If the difference is equal to zero ------ string1 = string2
If the difference is positive ------- string1> string2
If the difference is negative ------- string1 <string2
The following program shows the usage of strcmp() function −
 Live Demo
#include<stdio.h>
main ( ){
   char a[50], b [50];
   int d;
   printf ("enter 2 strings:\n");
   scanf ("%s %s", a,b);
   d = strcmp (a,b);
   if (d==0)
      printf("%s is equal to %s", a,b);
   else if (d>0)
      printf("%s is greater than %s",a,b);
   else if (d<0)
      printf("%s is less than %s", a,b);
}
When the above program is executed, it produces the following result −
enter 2 strings:
bhanu
priya
bhanu is less than priya
Let’s see another example on strcmp().
Given below is the C program to compare two strings using strcmp library function −
 Live Demo
#include<stdio.h>
#include<string.h>
void main(){
   //Declaring two strings//
   char string1[25],string2[25];
   int value;
   //Reading string 1 and String 2//
   printf("Enter String 1: ");
   gets(string1);
   printf("Enter String 2: ");
   gets(string2);
   //Comparing using library function//
   value = strcmp(string1,string2);
   //If conditions//
   if(value==0){
      printf("%s is same as %s",string1,string2);
   }
   else if(value>0){
      printf("%s is greater than %s",string1,string2);
   }
   else{
      printf("%s is less than %s",string1,string2);
   }
}
When the above program is executed, it produces the following result −
Enter String 1: Tutorials
Enter String 2: Point
Tutorials is greater than Point
Perl pack Function

This function evaluates the expressions in LIST and packs them into a binary structure specified by EXPR. The format is specified using the characters shown in Table below −
Each character may be optionally followed by a number, which specifies a repeat count for the type of value being packed.that is nibbles, chars, or even bits, according to the format. A value of * repeats for as many values remain in LIST. Values can be unpacked with the unpack function.
For example, a5 indicates that five letters are expected. b32 indicates that 32 bits are expected. h8 indicates that 8 nybbles ( or 4 bytes) are expected. P10 indicates that the structure is 10 bytes long.
Following is the simple syntax for this function −
pack EXPR, LIST

This function returns a packed version of the data in LIST using TEMPLATE to determine how it is coded.
This function returns a packed version of the data in LIST using TEMPLATE to determine how it is coded.
Here is the table which gives values to be used in TEMPLATE.
a
ASCII character string padded with null characters
A
ASCII character string padded with spaces
b
String of bits, lowest first
B
String of bits, highest first
c
A signed character (range usually -128 to 127)
C
An unsigned character (usually 8 bits)
d
A double-precision floating-point number
f
A single-precision floating-point number
h
Hexadecimal string, lowest digit first
H
Hexadecimal string, highest digit first
i
A signed integer
I
An unsigned integer
l
A signed long integer
L
An unsigned long integer
n
A short integer in network order
N
A long integer in network order
p
A pointer to a string
s
A signed short integer
S
An unsigned short integer
u
Convert to uuencode format
v
A short integer in VAX (little-endian) order
V
A long integer in VAX order
x
A null byte
X
Indicates "go back one byte"
@
Fill with nulls (ASCII 0)
Following is the example code showing its basic usage −
#!/usr/bin/perl -w

$bits = pack("c", 65);
# prints A, which is ASCII 65.
print "bits are $bits\n";
$bits = pack( "x" );
# $bits is now a null chracter.
print "bits are $bits\n";
$bits = pack( "sai", 255, "T", 30 );
# creates a seven charcter string on most computers'
print "bits are $bits\n";

@array = unpack( "sai", "$bits" );

#Array now contains three elements: 255, T and 30.
print "Array $array[0]\n";
print "Array $array[1]\n";
print "Array $array[2]\n";
When above code is executed, it produces the following result −
bits are A
bits are 
bits are �T
Array 255
Array T
Array 30


    46 Lectures 
     4.5 hours 

 Devi Killada

    11 Lectures 
     1.5 hours 

 Harshit Srivastava

    30 Lectures 
     6 hours 

 TELCOMA Global

    24 Lectures 
     2 hours 

 Mohammad Nauman

    68 Lectures 
     7 hours 

 Stone River ELearning

    58 Lectures 
     6.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
jQuery - prev( [selector] ) Method

The prev( [selector] ) method gets the immediately preceding sibling of each element in the set of matched elements, optionally filtered by a selector.
Here is the simple syntax to use this method −
selector.prev( [selector] )

Here is the description of all the parameters used by this method −
selector − This is optional selector to filter the previous Elements with.
selector − This is optional selector to filter the previous Elements with.
Following is a simple example a simple showing the usage of this method. Try this example without passing selector in prev() method −
<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
		
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function(){
            $("p").prev(".selected").addClass("hilight");
         });
      </script>
		
      <style>
         .hilight { background:yellow; }
      </style>
   </head>
	
   <body>
      <div><span>Hello</span></div>
      <p class = "selected">Hello Again</p>
      <p>And Again</p>
   </body>
</html>
This will produce following result −
Hello Again
And Again
Following is a simple example a simple showing the usage of this method.
<html>
   <head>
      <title>The jQuery Example</title>
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
		
      <script type = "text/javascript" language = "javascript">
         $(document).ready(function(){
            $("p").next(".selected").addClass("hilight");
         });
      </script>
		
      <style>
         .hilight { background:yellow; }
      </style>
   </head>
	
   <body>
      <div><span>Hello</span></div>
      <p class = "hilight">Hello Again</p>
      <p>And Again</p>
   </body>
</html>
This will produce following result −
Hello Again
And Again

    27 Lectures 
     1 hours 

 Mahesh Kumar

    27 Lectures 
     1.5 hours 

 Pratik Singh

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    60 Lectures 
     9 hours 

 Eduonix Learning Solutions

    17 Lectures 
     2 hours 

 Sandip Bhattacharya

    12 Lectures 
     53 mins

 Laurence Svekis
 Print
 Add Notes
 Bookmark this page
PyQt5 - QClipboard

The QClipboard class provides access to system-wide clipboard that offers a simple mechanism to copy and paste data between applications. Its action is similar to QDrag class and uses similar data types.
QApplication class has a static method clipboard() which returns reference to clipboard object. Any type of MimeData can be copied to or pasted from the clipboard.
Following are the clipboard class methods that are commonly used −
clear()
Clears clipboard contents
setImage()
Copies QImage into clipboard
setMimeData()
Sets MIME data into clipboard
setPixmap()
Copies Pixmap object in clipboard
setText()
Copies QString in clipboard
text()
Retrieves text from clipboard
Signal associated with clipboard object is −
dataChanged()
Whenever clipboard data changes
In the following example, two TextEdit objects and two Pushbuttons are added to a top level window.
To begin with the clipboard object is instantiated. Copy() method of textedit object copies the data onto the system clipboard. When the Paste button is clicked, it fetches the clipboard data and pastes it in other textedit object.
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

class Example(QWidget):
   def __init__(self):
      super(Example, self).__init__()

      self.initUI()

   def initUI(self):
      hbox = QVBoxLayout()
      self.edit1=QTextEdit()
      hbox.addWidget(self.edit1)
      self.btn1=QPushButton("Copy")
      hbox.addWidget(self.btn1)
      self.edit2=QTextEdit()
      self.btn2=QPushButton("Paste")
      hbox.addWidget(self.edit2)
      hbox.addWidget(self.btn2)
      self.btn1.clicked.connect(self.copytext)
      self.btn2.clicked.connect(self.pastetext)
      self.setLayout(hbox)
      
      self.setGeometry(300, 300, 300, 200)
      self.setWindowTitle('Clipboard')
      self.show()
      
   def copytext(self):

      #clipboard.setText(self.edit1.copy())
      self.edit1.copy()
      print (clipboard.text())

      msg=QMessageBox()
      msg.setText(clipboard.text()+" copied on clipboard")
      msg.exec_()

   def pastetext(self):
      self.edit2.setText(clipboard.text())

app = QApplication(sys.argv)
clipboard=app.clipboard()
ex = Example()
ex.setWindowTitle("clipboard Example")
sys.exit(app.exec_())
The above code produces the following output −

    146 Lectures 
     22.5 hours 

 ALAA EID
 Print
 Add Notes
 Bookmark this page
Remove and update the existing record in MongoDB?

You can use only $pull operator that removes and updates the existing record in MongoDB. Let us first create a collection with documents −
> db.removeDemo.insertOne(
...    {
...       "UserName" : "Larry",
...       "UserDetails" : [
...          {
...             "_id" : 101,
...             "UserEmailId" : "976Larry@gmail.com",
...          }
...       ]
...    }
... );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cc7f9f88f9e6ff3eb0ce446")
}
> db.removeDemo.insertOne(
...    {
...       "UserName" : "Mike",
...       "UserDetails" : [
...          {
...             "_id" : 102,
...             "UserEmailId" : "Mike121@gmail.com",
...          }
...       ]
...    }
... );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5cc7f9f98f9e6ff3eb0ce447")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.removeDemo.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5cc7f9f88f9e6ff3eb0ce446"),
   "UserName" : "Larry",
   "UserDetails" : [
      {
         "_id" : 101,
         "UserEmailId" : "976Larry@gmail.com"
      }
   ]
}
{
   "_id" : ObjectId("5cc7f9f98f9e6ff3eb0ce447"),
   "UserName" : "Mike",
   "UserDetails" : [
      {
         "_id" : 102,
         "UserEmailId" : "Mike121@gmail.com"
      }
   ]
}
Let us now implement the $pull query to remove and update the existing record −
> db.removeDemo.update(
...    {"_id": ObjectId("5cc7f9f98f9e6ff3eb0ce447")},
...    { "$pull": { "UserDetails": {"_id": 102}}}
... );
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
Let us display the documents from the collection in order to check the objects have been removed or not −
> db.removeDemo.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5cc7f9f88f9e6ff3eb0ce446"),
   "UserName" : "Larry",
   "UserDetails" : [
      {
         "_id" : 101,
         "UserEmailId" : "976Larry@gmail.com"
      }
   ]
}
{
   "_id" : ObjectId("5cc7f9f98f9e6ff3eb0ce447"),
   "UserName" : "Mike",
   "UserDetails" : [ ]
}
Static Positioning Using CSS

We can define positioning of an element in CSS as static which does not renders the element in any special way, but in a normal way. Elements with positioning as static are not affected by any of the CSS Positioning properties (left, right, top and bottom).
Let’s see an example of CSS Static Positioning Method −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
p {
   margin: 0;
}
div:first-child {
   position: static;
   background-color: orange;
   text-align: center;
}
</style>
</head>
<body>
<div>Demo text</div>
<p>This is demo text wherein we are displaying an example for static positioning.</p>
<div></div>
</body>
</html>
Following is the output for the above code −
Let’s see another example of positioning method −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
div {
   border: 2px double #a43356;
   margin: 5px;
   padding: 5px;
}
#d1 {
   position: relative;
   height: 10em;
}
#d2 {
   position: absolute;
   width: 20%;
   bottom: 10px; /*relative to parent d1*/
}
#d3 {
   position: fixed;
   width: 30%;
   top:10em; /*relative to viewport*/
}
</style>
</head>
<body>
<div id="d1">This is demo paragraph. This is demo paragraph. 
This is demo paragraph. This is demo paragraph. 
This is demo paragraph. This is demo paragraph. 
This is demo paragraph. This is demo paragraph. 
<mark>relative</mark>
<div id="d2"><mark>absolute</mark></div>
<div id="d3"><mark>fixed</mark></div>
</div>
</body>
</html>
Following is the output for the above code −
Lines of Code (LOC) in Software Engineering - GeeksforGeeks

26 Apr, 2021
A line of code (LOC) is any line of text in a code that is not a comment or blank line, in any case of the number of statements or fragments of statements on the line. LOC clearly consists of all lines containing program header files, declaration of any variable, and executable and non-executable statements. As Lines of Code (LOC) only counts the volume of code, you can only use it to compare or estimate projects that use the same language and are coded using the same coding standards. 
Features :
Variations such as “source lines of code”, are used to set out a codebase.
LOC is frequently used in some kinds of arguments.
They are used in assessing a project’s performance or efficiency.
Advantages :
Most used metric in cost estimation.
Its alternates have many problems as compared to this metric.
It is very easy in estimating the efforts.
Disadvantages : 
Increases productivity while writing more lines of code.
Less efficient code.
It doesn’t consider complexity.
Researches have shown a rough correlation between LOC and the overall cost and length of developing a project/ product in Software Development, and between LOC and the number of defects. This means the lower your LOC measurement is, the better off you probably are in the development of your product.
Let’s take an example and check that how does the Line of code work in the simple sorting program given below:
C++
void selSort(int x[], int n) {  //Below function sorts an array in ascending order    int i, j, min, temp;   for (i = 0; i < n - 1; i++) {      min = i;      for (j = i + 1; j < n; j++)      if (x[j] < x[min])      min = j;      temp = x[i];      x[i] = x[min];      x[min] = temp;   }}
So, now If LOC is simply a count of the numbers of lines then the above function shown contains 13 lines of code (LOC). But when comments and blank lines are ignored, the function shown above contains 12 lines of code (LOC).
Let’s take another example and check that how does the Line of code work in the given below:
C++
void main(){    int fN, sN, tN;    cout << "Enter the 2 integers: ";    cin >> fN >> sN;    // sum of two numbers in stored in variable sum    sum = fN + sN;    // Prints sum     cout << fN << " + " <<  sN << " = " << sum;         return 0;}
Here also, If LOC is simply a count of the numbers of lines then the above function shown contains 11 lines of code (LOC). But when comments and blank lines are ignored, the function shown above contains 9 lines of code (LOC).
Software Testing
Software Engineering
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
DFD for Library Management System
What is DFD(Data Flow Diagram)?
Software Engineering | Software Design Process
Software Engineering | Black box testing
RUP and its Phases
System Testing
Software Development Life Cycle (SDLC)
Software Engineering | Seven Principles of software testing
Software Engineering | Incremental process model
Data Dictionaries in Software Engineering
Difference Between List and Tuple in Python

In this post, we will understand the differences between list and tuple in Python.
List and tuple are two different kinds of data structures used in Python. They are both used in different instances to store data of different types.
It is often referred to as a sequence. It is considered to be one of the most frequently used data type, as well as lauded for its versatility. A list can be created by placing all elements inside square brackets ([ ]) and separating the elements with commas. There can be any number of elements inside the list and they can be of different types as well (such as integer, float, string, and so on). The most important characteristic of list is that it is a mutable structure, i.e changes can be made by references the list. 
Let us see how a list with heterogeneous data types can be created −
Live Demo
my_list = [1.8, 'string', 34, 'a']
print(my_list)
[1.8, 'string', 34, 'a']
There are many ways in which data within a list can be accessed.
Let us see how indexing can be used to access elements −
my_list = [1.8, ‘string’, 34, ‘a’]
print(“The second element is”)
print(my_list[1])
The second element is
string
We can also access elements from one range to another. This is known as list slicing. Let us see how that can be done −
Live Demo
my_list = [1.8, 'string', 34, 'a']
print("The elements within a certain range are")
print(my_list[1:4])
The elements within a certain range are
['string', 34, ‘a’]
We can also change the values of a list by performing indexing and assigning a new value to that index. Let us see how that can be done −
my_list = [1.8, 'string', 34, 'a']
print(“List before changes”)
print(my_list)
my_list[1] = ‘my_string’
print("List after changes")
print(my_list)
List before changes
[1.8, 'string', 34, 'a']
List after changes
[1.8, 'my_string', 34, 'a']
Now let us understand the working of a tuple structure. It is created using parenthesis, i.e. (). The important characteristic of tuple is that it is immutable, i.e. the elements one assigned inside a tuple can't be changed by accessing the tuple. There can be any number of elements inside the tuple and they can be of different types as well (such as integer, float, string, and so on).
Note: A tuple can be created without the use of parenthesis, but it is considered good practice to use parenthesis.
Let us see how a tuple with a single element can be created −
my_tuple = (“hey”,)
print(“Creating a tuple with one element”)
print(my_tuple)
("hello")
Note: Accessing the elements of the tuple, negative indexing, and list slicing are same as that of list.
If the tuple contains a list inside it, that list can be changed, but elements that are only inside the tuple, but not inside the list, can't be changed.
A unique string in Python

Suppose we have a string s, we have to check whether it has all unique characters or not.
So, if the input is like "world", then the output will be True
To solve this, we will follow these steps −
set_var := a new set from all characters of s
set_var := a new set from all characters of s
return true when size of set_var is same as size of s, otherwise false
return true when size of set_var is same as size of s, otherwise false
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, s):
      set_var = set(s)
      return len(set_var) == len(s)
ob = Solution()
print(ob.solve('hello'))
print(ob.solve('world'))
hello
world
False
True
How can we get only unique values of a column in MySQL result set?

While querying data from a MySQL table, we may get duplicate values from a column. With the help of the DISTINCT clause in the SELECT statement, we can get rid of duplicate data in the result set.
SELECT DISTINCT Columns FROM Table_name WHERE conditions;
For example, we have a table named ‘tender’ having the following columns −
mysql> Select * from tender;
+----------+--------------+--------------+-------+
| clientid | client_Fname | Client_Lname | value |
+----------+--------------+--------------+-------+
|      100 | Mohan        | Kumar        | 60000 |
|      101 | Sohan        | Singh        | 50000 |
|      101 | Somil        | Rattan       | 55000 |
|      103 | Gaurav       | Kumar        | 75000 |
|      103 | Rahul        | Singh        | 63000 |
+----------+--------------+--------------+-------+
5 rows in set (0.00 sec)
Now, if we want to get only the unique values of the column named ‘Client_Lname’ then following would be query −
mysql> Select DISTINCT client_Lname from tender;
+--------------+
| client_Lname |
+--------------+
| Kumar        |
| Singh        |
| Rattan       |
+--------------+
3 rows in set (0.05 sec)
The query below will do the same with a column named ‘client_Fname’.
mysql> Select DISTINCT client_Fname from tender;
+--------------+
| client_Fname |
+--------------+
| Mohan        |
| Sohan        |
| Somil        |
| Gaurav       |
| Rahul        |
+--------------+
5 rows in set (0.00 sec)
Font Size in CSS

The CSS font-size property is used to set the size of font. We can specify the value in percentages, units like pixels, cm, points, em, etc. and absolute keyword. Relative values maximize accessibility. The default font-size is 16px or 12pt.
The syntax of CSS font-size property is as follows −
Selector {
   font-size: /*value*/
}
The following examples illustrate CSS font-size property −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
div {
   margin: auto;
   padding: 10px;
   text-align: center;
   width: 50%;
   border: 2px solid;
   border-radius: 15%;
   font-size: 1.4em;
}
</style>
</head>
<body>
<div>
one
<div>two
<div>three</div>
</div>
</div>
</body>
</html>
This gives the following output −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
p {
   font-size: smaller;
}
#demo {
   font-size: initial;
}
p:last-of-type {
   font-size: 200%;
}
</style>
</head>
<body>
<h2>Demo Heading</h2>
<p>This is demo text 1.</p>
<p id="demo">This is demo text 2. </p>
<p>This is demo text 3.</p>
</body>
</html>
This gives the following output −
Array creation using Comprehensions and Generators in Julia - GeeksforGeeks

17 May, 2020
Julia is a language designed for high-level performance and can support interactive use as well. It has many descriptive datatypes and type-declarations can be used to solidify the programs. Julia is slowly climbing the ladder and gaining the interest of many Data Scientists and machine learning scientists today. It is comparatively faster than Python as it is designed to implement the math concepts like linear algebra and matrix representations. Excellent for numerical computation, this language has multiple dispatches for defining data types like numbers and arrays.
Julia arrays use square brackets([ ]) for list comprehensions just like Python or MATLAB. It consists of three kinds of arrays. Array comprehension is a very powerful way to construct an array. The resulting array depends on the type of data used while construction.Syntax:
[expression for element = iterable]
 For 1-D Arrays:
# Julia array using for looptwice = []for i in 1:5    push!(twice, 2i)
can also be written and will give the same output as
# Using Comprehensiontwice = [2x for x=1:5]
 For 2-D Arrays:
# Creating 2D array using comprehension  u = [x + 2y for x in 1:5, y in 0:1]
 For 3-D Arrays:
# Creating 3D arrays using comprehension  p = [x + 2y + 3z for x in 1:4, y in 0:1, z in 1:3]
This does not exactly return an array type data structure but a generator type data structure. It uses parentheses ‘( )’ instead of the square brackets as in list comprehensions. The syntax else is very similar to that of the above.The object can be iterated to produce values when needed instead of allocating an array and storing them in advance. The series of data below are not allocated any memory unlike the examples above.
Syntax:
(expression for element = iterable)
 For 1-D Arrays:
# Creating 1D Array using Generators  j = (2x for x = 1:5)
 For 2-D Arrays:
# Creating 2D Arrays using Generatorsu = (x + 2y for x in 1:5, y in 0:1)
 For 3-D Arrays:
# Creating 3D arrays using Generators  p = (x + 2y + 3z for x in 1:4, y in 0:1, z in 1:3)
julia-array
Picked
Julia
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Vectors in Julia
Getting rounded value of a number in Julia - round() Method
Decision Making in Julia (if, if-else, Nested-if, if-elseif-else ladder)
Storing Output on a File in Julia
Formatting of Strings in Julia
Convert integer to string in Python
Convert string to integer in Python
How to set input type date in dd-mm-yyyy format using HTML ?
Python infinity
Matplotlib.pyplot.title() in Python
How to define a variable in HTML5 ? - GeeksforGeeks

05 Jun, 2020
In this article, we define a variable in the HTML by using the <var> tag in the document. It is a phrase tag and used to specify the variable in a mathematical equation or in the computer program. The content of this tag is displayed in an italic format in most of the browsers.
Syntax:
<var> Contents... </var>
Example:
<!DOCTYPE html><html>  <head>    <title>        How to define a        variable in HTML5?    </title>      <style>        body {            text-align: center;        }          .gfg {            font-size: 40px;            font-weight: bold;            color: green;        }          .geeks {            font-size: 25px;            font-weight: bold;        }    </style></head>  <body>    <div class="gfg">GeeksForGeeks</div>      <h2>        <var>            HTML5: How to define a variable?        </var>    </h2>      <var>GeeksforGeeks Variable</var></body>  </html>
Output:
Supported Browsers are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Design a web page using HTML and CSS
Form validation using jQuery
How to set space between the flexbox ?
Search Bar using HTML, CSS and JavaScript
How to style a checkbox using CSS?
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
How to Insert Form Data into Database using PHP ?
Hide or show elements in HTML using display property
REST API (Introduction)
VBScript StrReverse Function

The StrReverse Function reverses the specified string.
StrReverse(string) 

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         document.write("Line 1 : " & StrReverse("VBSCRIPT") & "<br />")
         document.write("Line 2 : " & StrReverse("My First VBScript") & "<br />")
         document.write("Line 3 : " & StrReverse("123.45") & "<br />")

      </script>
   </body>
</html>
When you save it as .html and execute it in Internet Explorer, then the above script will produce the following result −
Line 1 : TPIRCSBV
Line 2 : tpircSBV tsriF yM
Line 3 : 54.321


    63 Lectures 
     4 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
HTML | <body> background Attribute - GeeksforGeeks

28 Mar, 2022
The HTML <body> background Attribute is used to specify the background-image for the document. Note: It is not supported by HTML5 Instead of using this attribute we use CSS background property. 
Syntax: 
<body background="URL">
Attribute Values: It contains the value i.e URL Which specify the address of the background Image.  
Absolute URL: It points to another website.
Relative URL: It points to a file within a website.
Example:  
html
<!DOCTYPE html><html> <head>    <title>        HTML body Background Attribute    </title></head> <!-- body tag starts here --><body background="https://media.geeksforgeeks.org/wp-content/uploads/rk.png">         <center>        <h1>GeeksforGeeks</h1>        <h2>HTML <body> background Attribute</h2>                 <a href="#">            It is a Computer Science portal For Geeks        </a>    </center></body><!-- body tag ends here --> </html>
Output:  
Supported Browsers: The browser supported by <body> background Attribute are listed below:  
Google Chrome
Internet Explorer
Firefox
Safari
Opera
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
ManasChhabra2
chhabradhanvi
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to update Node.js and NPM to next version ?
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
CSS to put icon inside an input element in a form
Form validation using HTML and JavaScript
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
How to calculate the number of days between two dates in javascript?
The "\" escape character in C#

The "#", "0", ".", ",", "%", and "‰" symbols in a format string are interpreted as format specifiers.
Prevent a character from being interpreted as a format specifier, by preceding it with an escape character i.e. backslash.
To prevent interpreting as an escape character, use escape character for #", "0", and "\" characters.
Let us see an example −
Here, we are displaying #, by preceding it with an escape character i.e. backslash.
 Live Demo
using System;
using System.Globalization;
class Demo {
   static void Main() {
      int num = 20;
      Console.WriteLine(num.ToString("\\#\\# ##0 Rank"));
   }
}
## 20 Rank
F# - Tuples

A tuple is a comma-separated collection of values. These are used for creating ad hoc data structures, which group together related values.
For example, (“Zara Ali”, “Hyderabad”, 10) is a 3-tuple with two string values and an int value, it has the type (string * string * int).
Tuples could be pairs, triples, and so on, of the same or different types.
Some examples are provided here −
// Tuple of two integers.
( 4, 5 )

// Triple of strings.
( "one", "two", "three" )

// Tuple of unknown types.
( a, b )

// Tuple that has mixed types.
( "Absolute Classes", 1, 2.0 )

// Tuple of integer expressions.
( a * 4, b + 7)

This program has a function that takes a tuple of four float values and returns the average −
let averageFour (a, b, c, d) =
   let sum = a + b + c + d
   sum / 4.0

let avg:float = averageFour (4.0, 5.1, 8.0, 12.0)
printfn "Avg of four numbers: %f" avg
When you compile and execute the program, it yields the following output −
Avg of four numbers: 7.275000

The individual members of a tuple could be assessed and printed using pattern matching.
The following example illustrates the concept −
let display tuple1 =
   match tuple1 with
   | (a, b, c) -> printfn "Detail Info: %A %A %A" a b c

display ("Zara Ali", "Hyderabad", 10 )
When you compile and execute the program, it yields the following output −
Detail Info: "Zara Ali" "Hyderabad" 10

F# has two built-in functions, fst and snd, which return the first and second items in a 2-tuple.
The following example illustrates the concept −
printfn "First member: %A" (fst(23, 30))
printfn "Second member: %A" (snd(23, 30))

printfn "First member: %A" (fst("Hello", "World!"))
printfn "Second member: %A" (snd("Hello", "World!"))

let nameTuple = ("Zara", "Ali")

printfn "First Name: %A" (fst nameTuple)
printfn "Second Name: %A" (snd nameTuple)
When you compile and execute the program, it yields the following output −
First member: 23
Second member: 30
First member: "Hello"
Second member: "World!"
First Name: "Zara"
Second Name: "Ali"

 Print
 Add Notes
 Bookmark this page
How can I play a sound when a Tkinter button is pushed?

Python has many inbuilt libraries and modules that are used for building various application interfaces and components. Pygame is one of the python modules which is used to design and build video games and music. It provides a mixture to handle all sound related activities. Using music sub-module, you can stream mp3, ogg, and other variety of sounds.
To create an application that plays some sound on clicking a button, we have to follow these steps,
Make sure that Pygame is installed in your local machine. You can install pygame using pip install pygame command.
Make sure that Pygame is installed in your local machine. You can install pygame using pip install pygame command.
Initialize Pygame mixture by using pygame.mixture.init()
Initialize Pygame mixture by using pygame.mixture.init()
Create a button widget which is used further to play the music.
Create a button widget which is used further to play the music.
Define a function play_sound() and load the music by specifying the location of the file in mixture.load.music(filename).
Define a function play_sound() and load the music by specifying the location of the file in mixture.load.music(filename).
Add mixture.music.play() to play the music.
Add mixture.music.play() to play the music.
# Import the required libraries
from tkinter import *
import pygame
from PIL import Image, ImageTk

# Create an instance of tkinter frame or window
win = Tk()

# Set the size of the window
win.geometry("700x500")

# Add a background image
bg = ImageTk.PhotoImage(file="music.jpg")

label = Label(win, image=bg)
label.place(x=0, y=0)

# Initialize mixer module in pygame
pygame.mixer.init()

# Define a function to play the music
def play_sound():
   pygame.mixer.music.load("sample1.mp3")
   pygame.mixer.music.play()

# Add a Button widget
b1 = Button(win, text="Play Music", command=play_sound)
b1.pack(pady=60)

win.mainloop()
If we run the above code, it will display a window with a button in it. Now, add music location in the given function to play some music in the application.
Java program to expand a String if range is given?

To expand a String if range is given, the Java code is as follows −
 Live Demo
public class Demo {
   public static void expand_range(String word) {
      StringBuilder my_sb = new StringBuilder();
      String[] str_arr = word.split(", ");
      for (int i = 0; i < str_arr.length; i++){
         String[] split_str = str_arr[i].split("-");
         if (split_str.length == 2){
            int low = Integer.parseInt(split_str[0]);
            int high = Integer.parseInt(split_str[split_str.length - 1]);
            while (low <= high){
               my_sb.append(low + " ");
               low++;
            }
         } else {
            my_sb.append(str_arr[i] + " ");
         }
      }
      System.out.println(my_sb.toString());
   }
   public static void main(String args[]){
      String my_str = "1-4, 56-57, 99-101, 0-1";
      System.out.println("The expanded range of given numbers is ");
      expand_range(my_str);
   }
}
The expanded range of given numbers is
1 2 3 4 56 57 99 100 101 0 1
A class named Demo contains a function named ‘expand_range’, that splits the string basedon
commas, and iterates through the string and splits the numbers and increments 1 every time. This is displayed on the console. In the main function, the string is defined, and the function is called by passing this function as a parameter. Relevant message is displayed on the console.
How to set new value for an attribute using jQuery?

The jQuery attr() method is used to get the value of an attribute. It can also be used to set new value. We will set new value of attribute href to tutorialspoint.com/html5 from tutorialspoint.com/css.
You can try to run the following code to learn how to set new value for an attribute in jQuery −
Live Demo
<html>
   <head>
      <title>Selector Example</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
      <script>
         $(document).ready(function(){
            $("button").click(function(){
               $("#tpoint").attr("href", "https://www.tutorialspoint.com/html5");
            });
         });
      </script>
   </head>
   <body>
      <p><a href="https://www.tutorialspoint.com/css" id="tpoint">Tutorialspoint</a></p>
      <button>Set new value</button>
      <p>The value of above link will change on clicking the above button. This will set a new value for the attribute. Check before and after button click.</p>
   </body>
</html>
postmap - Unix, Linux Command

makemap file_type file_name < file_name


If the result files do not exist they will be created with the
same group and other read permissions as the source file.


While the table update is in progress, signal delivery is
postponed, and an exclusive, advisory, lock is placed on the
entire table, in order to avoid surprises in spectator
programs.




   key whitespace value


By default the lookup key is mapped to lowercase to make
the lookups case insensitive; as of Postfix 2.3 this case
folding happens only with tables whose lookup keys are
fixed-case strings such as btree:, dbm: or hash:. With
earlier versions, the lookup key is folded even with tables
where a lookup field can match both upper and lower case
text, such as regexp: and pcre:. This resulted in loss of
information with $number substitutions.




If a key value of - is specified, the program reads key
values from the standard input stream. The exit status is zero
when at least one of the requested keys was found.


If a key value of - is specified, the program reads key
values from the standard input stream and writes one line of
key value output for each key that was found. The exit
status is zero when at least one of the requested keys was found.


The postmap(1) command can query any supported file type,
but it can create only the following file types:


postmap(1) terminates with zero exit status in case of success
(including successful "postmap -q" lookup) and terminates
with non-zero exit status in case of failure.





postalias(1), create/update/query alias database
postconf(1), supported database types
postconf(5), configuration parameters
syslogd(8), system logging



DATABASE_README, Postfix lookup table overview



Wietse Venema
IBM T.J. Watson Research
P.O. Box 704
Yorktown Heights, NY 10598, USA


Advertisements


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Align HTML5 SVG to the center of the screen

SVG stands for Scalable Vector Graphics and it is a language for describing 2D-graphics and graphical applications in XML and the XML is then rendered by an SVG viewer.
Let us see an example of SVG −
<!DOCTYPE html>
<html>
   <head>
      <style>
         #svgelem {
            position: relative;
            left: 50%;
            -webkit-transform: translateX(-20%);
            -ms-transform: translateX(-20%);
            transform: translateX(-20%);
         }
      </style>
      <title>SVG</title>
      <meta charset="utf-8" />
   </head>
   <body>
      <h2>HTML5 SVG Circle</h2>
      <svg id = "svgelem" height = "200" xmlns = "http://www.w3.org/2000/svg">
         <circle id = "redcircle" cx = "50" cy = "50" r = "50" fill = "red" />
      </svg>
   </body>
</html>
To center it, add the CSS like the following −
# svgelem {
   margin-left:auto;
   margin-right:auto;
   display:block;
}