code-rag-bench/online-tutorials huggingface dataset:
Vernam Cipher in Cryptography

17 Jun, 2022
Vernam Cipher is a method of encrypting alphabetic text. It is one of the Substitution techniques for converting a plain text into a cipher text. In this mechanism we assign a number to each character of the Plain-Text, like (a = 0, b = 1, c = 2, ... z = 25). 
Method to take key: In Vernam cipher algorithm, we take a key to encrypt the plain text which length should be equal to the length of the plain text. 
Encryption Algorithm: 
Assign a number to each character of the plain-text and the key according to alphabetical order. Add both the number (Corresponding plain-text character number and Key character number). Subtract the number from 26 if the added number is greater than 26, if it isn’t then leave it.
Assign a number to each character of the plain-text and the key according to alphabetical order. 
Add both the number (Corresponding plain-text character number and Key character number). 
Subtract the number from 26 if the added number is greater than 26, if it isn’t then leave it.
Example: 
Plain-Text: RAMSWARUPK
Key: RANCHOBABA 
Now according to our encryption algorithm we assign a number to each character of our plain-text and key.
PT:   R  A  M   S   W   A  R   U   P   K
NO:   17 0  12  18  22  0  17  20  15  10

KEY:  R   A  N   C  H  O   B  A  B  A  
NO:   17  0  13  2  7  14  1  0  1  0 
Now add the number of Plain-Text and Key and after doing the addition and subtraction operation (if required), we will get the corresponding Cipher-Text character number. 
CT-NO: 34  0  25  20  29  14  18  20  16  10 
In this case, there are two numbers which are greater than the 26 so we have to subtract 26 from them and after applying the subtraction operation the new Cipher text character numbers are as follow: 
CT-NO:  8  0  25   20   3   14   18   20   16   10 
New Cipher-Text is after getting the corresponding character from the number. 
CIPHER-TEXT: I  A  Z  U  D  O  S  U  Q  K 
Note: For the Decryption apply the just reverse process of encryption.
abhirgonepavaram13
mukeshprasad
animeshdey
debajyotishit3
cryptography
Computer Networks
cryptography
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of Network Topology
Socket Programming in Python
GSM in Wireless Communication
Differences between IPv4 and IPv6
Secure Socket Layer (SSL)
Wireless Application Protocol
Mobile Internet Protocol (or Mobile IP)
TCP 3-Way Handshake Process
UDP Server-Client implementation in C
User Datagram Protocol (UDP)
Python – Common keys in list and dictionary

14 Oct, 2020
Given a dictionary and list, extract all the keys and list which are common.
Input : test_dict = {“Gfg”: 3, “is” : 5, “best” : 9, “for” : 0, “geeks” : 3}, test_list = [“Gfg”, “best”, “CS”]Output : [‘Gfg’, ‘best’]Explanation : Gfg and best are present in both dictionary and List.
Input : test_dict = {“Gfg”: 3, “is” : 5, “best” : 9, “for” : 0, “geeks” : 3}, test_list = [“Gfg”, “good”, “CS”]Output : [‘Gfg’]Explanation : Gfg is present in both dictionary and List.
Method #1 : Using list comprehension
This is one of the ways in which this task can be performed. In this, we iterate for all the dictionary and list values, if find a match, they are added to result.
Python3
# Python3 code to demonstrate working of # Common keys in list and dictionary# Using list comprehension  # initializing dictionarytest_dict = {"Gfg": 3, "is" : 5, "best" : 9, "for" : 0, "geeks" : 3}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # initializing test_list test_list = ["Gfg", "best", "geeks"]  # using in operator to check for match res = [ele for ele in test_dict if ele in test_list]  # printing result print("The required result : " + str(res)) 
The original dictionary is : {'Gfg': 3, 'is': 5, 'best': 9, 'for': 0, 'geeks': 3}
The required result : ['Gfg', 'best', 'geeks']

Method #2 : Using set() + intersection()
This is yet another way in which this task can be performed. In this, we convert both the containers, list and dictionary keys to set() and then intersect to find required match.
Python3
# Python3 code to demonstrate working of # Common keys in list and dictionary# Using set() + intersection()  # initializing dictionarytest_dict = {"Gfg": 3, "is" : 5, "best" : 9, "for" : 0, "geeks" : 3}  # printing original dictionaryprint("The original dictionary is : " + str(test_dict))  # initializing test_list test_list = ["Gfg", "best", "geeks"]  # intersection() used to get Common elements res = set(test_list).intersection(set(test_dict))  # printing result print("The required result : " + str(list(res))) 
The original dictionary is : {'Gfg': 3, 'is': 5, 'best': 9, 'for': 0, 'geeks': 3}
The required result : ['best', 'geeks', 'Gfg']

Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Why array index starts from zero ?

06 Oct, 2020
Prerequisite : Pointers in C/C++ 
THERE CAN BE MANY REASONS, BUT HERE ARE TWO REASONS:
Reason 1 :Consider int arr[100]. The answer lies in the fact how the compiler interprets arr[i] ( 0<=i<100). arr[i] is interpreted as *(arr + i). Now, arr is the address of the array or address of 0th index element of the array. So, address of next element in the array is arr + 1 (because elements in the array are stored in consecutive memory locations), further address of next location is arr + 2 and so on. Going with the above arguments, arr + i mean the address at i distance away from the starting element of the array. Therefore, going by this definition, i will be zero for the starting element of the array because the starting element is at 0 distance away from the starting element of the array. To fit this definition of arr[i], indexing of array starts from 0.  
CPP
#include<iostream>using namespace std; int main(){    int arr[] = {1, 2, 3, 4};     // Below two statements mean same thing    cout << *(arr + 1) << " ";    cout << arr[1] << " ";     return 0;}
2 2




 
The conclusion is, we need random access in the array. To provide random access, compilers use pointer arithmetic to reach i-th element.
Reason 2 :
Modern languages, especially C++ use row-major ordering for storing two-dimensional arrays.
Let us assume a 2D array and write a row-major formula  with two different approaches:
array indices starting from 1array indices starting from 0
array indices starting from 1
array indices starting from 0
let the 2D array be arr[m][n] of type int
let &arr be “address”
case 1 ( array indices start from 1 ) :
         &( arr[i][j] ) = address + [ ( i-1 )*n + ( j-1 ) ]*( sizeof(int) ) ] so here we are performing 6 operations
case 2 ( array indices start from 0 ) :
        &( arr[i][j] ) = address + [ ( i )*n + ( j ) ]*( sizeof(int) ) ] and here we are performing only 4 operations
So we see here that we are performing 2 less operations when we store 2D arrays and obtaining an element’s address. This looks like it doesn’t make sense but it does! While handling with huge size data this may improved performance and speed. case 1 may look user-friendly but case 2 is more efficient. That’s why most languages like C++, PYTHON, JAVA use arrays starting with index 0 and rarely languages like Lua arrays starting with index 1. 
camsboyfriend
cpp-puzzle
Arrays
C Language
C++
Arrays
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Maximum and minimum of an array using minimum number of comparisons
Top 50 Array Coding Problems for Interviews
Multidimensional Arrays in Java
Stack Data Structure (Introduction and Program)
Linear Search
std::sort() in C++ STL
Bitwise Operators in C/C++
Substring in C++
Dynamic Memory Allocation in C using malloc(), calloc(), free() and realloc()
Multidimensional Arrays in C / C++
Ruby | String each_line Method

12 Dec, 2019
each_line is a String class method in Ruby which is used to split the given string sing the supplied parameter as the record separator ($/ by default), passing each substring in turn to the supplied block. The string is split into paragraphs delimited by multiple successive newlines if a zero-length record separator is supplied,
Syntax: str.each_line(separator=$/ [, getline_args])
Parameters: Here, str is the given string.
Returns: An enumerator if the no block is given. Otherwise the splitted string.
Example 1:
# Ruby program to demonstrate # the each_line method        # Taking a string and # using the methodputs "Ruby\nString".each_line {|s| p s}
Output:
"Ruby\n"
"String"
Ruby
String

Example 2:
# Ruby program to demonstrate # the each_line method        # Taking a string and # using the methodputs "Sample\nInput".each_line {|s| p s}
Output:
"Sample\n"
"Input"
Sample
Input

Ruby String-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Make a Custom Array of Hashes in Ruby?
Ruby | Enumerator each_with_index function
Ruby | unless Statement and unless Modifier
Ruby | Array class find_index() operation
Ruby For Beginners
Ruby | String concat Method
Ruby on Rails Introduction
Ruby | Types of Variables
Ruby | Array shift() function
Golang – GOPATH and GOROOT

30 May, 2022
There is a set of programs to build and process Go source code. Instead of being run directly, programs in that set are usually invoked by the go program. GOPATH and GOROOT are environment variables that define a certain arrangement and organization for the Go source code. The paths of gopath and goroot can be modified explicitly if required. 
GOPATH, also called the workspace directory, is the directory where the Go code belongs. It is implemented by and documented in the go/build package and is used to resolve import statements. The go get tool downloads packages to the first directory in GOPATH. If the environment variable is unset, GOPATH defaults to a subdirectory named “go” in the user’s home directory. To check this, enter the following command:
On Windows: C:\Users\%USERPROFILE%\go
On Linux: $HOME/go
To check the current GOPATH enter the following command:
C:\Users\%USERPROFILE%\go env GOPATH
GOPATH contains 3 directories under it and each directory under it has specific functions:
src: It holds source code. The path below this directory determines the import path or the executable name.
pkg: It holds installed package objects. Each target operating system and architecture pair has its own subdirectory of pkg.
bin: It holds compiled commands. Every command is named for its source directory.
When using modules in Go, the GOPATH is no longer used to determine imports. However, it is still used to store downloaded source code in pkg and compiled commands bin.
GOROOT is for compiler and tools that come from go installation and is used to find the standard libraries. It should always be set to the installation directory. In order to check the current GOROOT enter the following command:
C:\Users\%USERPROFILE%\go env GOROOT
It is possible to install the Go tools to a different location. This can be done by setting the GOROOT environment variable to point to the directory in which it was installed, although this is not recommended as it comes preset with the tooling. 
Himansh_Jain
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Range Keyword in Golang
Check if the String ends with specified suffix in Golang
Time Durations in Golang
Import in GoLang
How to Map a Rune to Lowercase in Golang?
Golang - Environment Variables
Strings in Golang
Golang program that uses structs as map keys
Check if the String starts with specified prefix in Golang
Top 10 Programming Languages for Blockchain Development
Difference Between Group By and Order By in SQL

In this post, we will understand the difference between group by and order by in SQL.
It is used to group the rows which have the same value.
It is used to group the rows which have the same value.
It can be used in CREATE VIEW statement.
It can be used in CREATE VIEW statement.
In select statement, it has to be used before the ‘ORDER BY’ keyword.
In select statement, it has to be used before the ‘ORDER BY’ keyword.
Attribute can’t be in a ‘GROUP BY’ statement when it is under aggregate function.
Attribute can’t be in a ‘GROUP BY’ statement when it is under aggregate function.
The tuples are grouped based on how similar the attribute values of the tuples are.
The tuples are grouped based on how similar the attribute values of the tuples are.
It controls the presentation of the tuples/rows.
It controls the presentation of the tuples/rows.
It doesn’t use the ‘CREATE VIEW’ statement.
It doesn’t use the ‘CREATE VIEW’ statement.
The result-set is sorted in ascending or descending order.
The result-set is sorted in ascending or descending order.
It is used after the ‘group by’ keyword.
It is used after the ‘group by’ keyword.
The attribute can be under an aggregate function.
The attribute can be under an aggregate function.
It controls the presentation of columns.
It controls the presentation of columns.
Following is the syntax of Group By and Order By in a single query −
SELECT column1, column2
FROM table_name
WHERE [ conditions ]
GROUP BY column1, column2
ORDER BY column1, column2
Difference between Compile Time Errors and Runtime Errors

07 Sep, 2021
Compile-Time Errors: Errors that occur when you violate the rules of writing syntax are known as Compile-Time errors. This compiler error indicates something that must be fixed before the code can be compiled. All these errors are detected by the compiler and thus are known as compile-time errors. Most frequent Compile-Time errors are:  
Missing Parenthesis (})
Printing the value of variable without declaring it
Missing semicolon (terminator)
Below is an example to demonstrate Compile-Time Error: 
C++
C
// C++ program to illustrate// syntax error#include <iostream>using namespace std; int main(){    int x = 10;    int y = 15;     // semicolon missed    cout << " "<< (x, y);} // this code is contributed by shivanisinghss2110
// C program to illustrate// syntax error #include<stdio.h> void main(){    int x = 10;    int y = 15;     // semicolon missed    printf("%d", (x, y));}
Error:  
error: expected ';' before '}' token
Run-Time Errors: Errors which occur during program execution(run-time) after successful compilation are called run-time errors. One of the most common run-time error is division by zero also known as Division error. These types of error are hard to find as the compiler doesn’t point to the line at which the error occurs.For more understanding run the example given below. 
C++
C
// C++ program to illustrate// run-time error #include <iostream>using namespace std; int main(){    int n = 9, div = 0;       // wrong logic    // number is divided by 0,    // so this program abnormally terminates    div = n/0;         cout <<"result = " << div;} // This code is contributed by shivanisinghss2110
// C program to illustrate// run-time error #include<stdio.h> void main(){    int n = 9, div = 0;       // wrong logic    // number is divided by 0,    // so this program abnormally terminates    div = n/0;         printf("result = %d", div);}
Error:  
warning: division by zero [-Wdiv-by-zero]
     div = n/0;
In the given example, there is Division by zero error. This is an example of run-time error i.e errors occurring while running the program.The Differences between Compile-Time and Run-Time Error are: 
 
shivanisinghss2110
anikakapoor
Difference Between
Programming Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Difference between Process and Thread
Difference between Clustered and Non-clustered index
Differences between IPv4 and IPv6
Arrow operator -> in C/C++ with Examples
Modulo Operator (%) in C/C++ with Examples
Structures in C++
Decorators with parameters in Python
C# | Data Types
p5.js | angleMode() Function

31 May, 2020
The angleMode() function in p5.js is used to set the mode in which the angle is interpreted. It can be set to either degrees or radians. All the functions that use an angle as a parameter would follow the angle mode set by this function.
Syntax:
angleMode( mode )

Parameters: This function accept a single parameter as mentioned above and described below: 
mode: It is a constant that can be used to set the mode in which the angle would be interpreted. It can have the values of DEGREES or RADIANS.
The example below illustrates the angleMode() function in p5.js:Example:
javascript
let angleModeSelected;  function setup() {  createCanvas(400, 300);  textSize(18);    // Set the default angle to DEGREES  angleModeSelected = DEGREES;    // Create a button for toggling the angle mode  angleModeToggler = createButton("Toggle Angle Mode");  angleModeToggler.position(30, 40);  angleModeToggler.mouseClicked(() => {    if (angleModeSelected == DEGREES) angleModeSelected = RADIANS;    else angleModeSelected = DEGREES;  });    // Create a slider for changing the current angle  angleSlider = createSlider(-180, 180, 0, 1);  angleSlider.position(30, 120);}  function draw() {  clear();    // Get the angle from the slider  let angleToRotate = angleSlider.value();    // Convert the angle to radians  // for demonstration  let angleInRadians = (angleToRotate / 57.295).toFixed(3);    text("Angle Mode Selected: " + angleModeSelected, 20, 20);  text("Current value of rotation: " + angleToRotate + " degrees", 20, 80);  text("Current value of rotation: " + angleInRadians + " radians", 20, 100);    // Set the angle mode  // based on the selected mode  angleMode(angleModeSelected);    translate(width / 3, height / 1.5);    // Rotate the shape according to  // the angle specified  rotate(angleToRotate);    // Draw the rectangle that  // would be rotated  rect(0, 0, 100, 25);}
Output:
Online editor: https://editor.p5js.org/Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/Reference: https://p5js.org/reference/#/p5/angleMode 
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
JavaScript | Promises
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Sorting an array according to another array using pair in STL

24 Apr, 2018
We are given two arrays. We need to sort one array according to another.
Examples:
Input : 2 1 5 4 9 3 6 7 10 8
        A B C D E F G H I J

Output : 1 2 3 4 5 6 7 8 9 10 
         B A F D C G H J E I 
Here we are sorting second array
(a character array) according to 
the first array (an integer array).

We have discussed different ways in below post.Sort an array according to the order defined by another array
In this post we are focusing on using the pair container present in STL of C++.
To achieve our task we are going to make pairs of respective elements from both the arrays.Then simply use the sort function. The important thing to note is, the first element in the pairs should be from the array according to which the sorting is to be performed.
// Sort an array according to // other using pair in STL.#include <bits/stdc++.h>using namespace std;  // Function to sort character array b[]// according to the order defined by a[]void pairsort(int a[], char b[], int n){    pair<int, char> pairt[n];      // Storing the respective array    // elements in pairs.    for (int i = 0; i < n; i++)     {        pairt[i].first = a[i];        pairt[i].second = b[i];    }      // Sorting the pair array.    sort(pairt, pairt + n);          // Modifying original arrays    for (int i = 0; i < n; i++)     {        a[i] = pairt[i].first;        b[i] = pairt[i].second;    }}  // Driver functionint main(){    int a[] = {2, 1, 5, 4, 9, 3, 6, 7, 10, 8};    char b[] = {'A', 'B', 'C', 'D', 'E', 'F',                          'G', 'H', 'I', 'J'};                               int n = sizeof(a) / sizeof(a[0]);          // Function calling    pairsort(a, b, n);      for (int i = 0; i < n; i++)        cout << a[i] << " ";    cout << endl;      for (int i = 0; i < n; i++)        cout << b[i] << " ";              return 0;}
Output:
1 2 3 4 5 6 7 8 9 10 
B A F D C G H J E I 

This article is contributed by Vineet Joshi. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
cs_abhi
cpp-pair
STL
Sorting
Sorting
STL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTML - <link> Tag

The HTML <link> tag is used for defining a link to an external document. It is placed in the <head> section of the document.
<!DOCTYPE html>
<html>

   <head>
      <title>HTML link Tag</title>
      <link rel = "stylesheet" href = "stylenew.css">
   </head>

   <body>
      <div id = "contentinfo">
         <p>Welcome to our website. We provide tutorials on various subjects.</p>
      </div>
   </body>

</html>
Here is the css file stylenew.css
#contentinfo p {
   line-height: 20px;
   margin: 30px;
   padding-bottom: 20px;
   text-align: justify;
   width: 140px;
   color: red;
}
This will produce the following result −
Welcome to our website. We provide tutorials on various subjects.
This tag supports all the global attributes described in − HTML Attribute Reference
The HTML <link> tag also supports the following additional attributes −
This tag supports all the event attributes described in − HTML Events Reference
hwclock command in Linux with examples

21 May, 2019
hwclock also called Real Time Clock (RTC), is a utility for accessing the hardware clock. The hardware clock is independent of the OS(operating system) you use and works even when the machine is shut down. The hardware clock is also called a BIOS clock. A user can also change the date and time of the hardware clock from the BIOS. The hardware clock stores the values of the second, minute, hour, day, month and year. The hwclock utility saves its settings in the /etc/adjtime file, which is created when a user makes first change.
Syntax:
hwclock [function] [option...]
Functions:
-r, –show : It will display the RTC time.
–get : It is used to display the drift corrected RTC time.
–set : It is used to set the RTC according to –date.
-s, –hctosys : It will set the system time form the RTC.
-w, –systohoc : It will set the RTC from the system time i.e. the opposite of -s, –hctosys.
–systz : Used to send the timescale configurations to the kernel.
-a, –adjust : Adjust the RTC to account for systematic drift.
–predict : It will predict the drifted RTC time according to –date.
Options:
-u, –utc : Shows that RTC timescale is UTC.
-l, –localtime : Shows that RTC timescale is Local.
-D, –debug : This is used to display the debug information. Information is shown according to the demands of hwclock command.
-V, –version : Display version information and exit.
-h, –help : Display help text and exit.
Note: Use sudo with hwclock command.
Examples:
1. To display the Hardware Clock Date and Time:
2. Using adjust function:
3. Using debug option to get the debug information:
linux-command
Linux-system-commands
Picked
Technical Scripter 2018
Linux-Unix
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ZIP command in Linux with examples
tar command in Linux with examples
curl command in Linux with Examples
TCP Server-Client implementation in C
Conditional Statements | Shell Script
Tail command in Linux with examples
UDP Server-Client implementation in C
Docker - COPY Instruction
scp command in Linux with Examples
echo command in Linux with Examples
fseek() vs rewind() in C

28 May, 2017
In C, fseek() should be preferred over rewind().
Note the following text C99 standard:The rewind function sets the file position indicator for the stream pointed to by stream to the beginning of the file. It is equivalent to
(void)fseek(stream, 0L, SEEK_SET)
except that the error indicator for the stream is also cleared.
This following code example sets the file position indicator of an input stream back to the beginning using rewind(). But there is no way to check whether the rewind() was successful.
int main(){  FILE *fp = fopen("test.txt", "r");    if ( fp == NULL ) {    /* Handle open error */  }    /* Do some processing with file*/    rewind(fp);  /* no way to check if rewind is successful */    /* Do some more precessing with file */    return 0;}
In the above code, fseek() can be used instead of rewind() to see if the operation succeeded. Following lines of code can be used in place of rewind(fp);
if ( fseek(fp, 0L, SEEK_SET) != 0 ) {  /* Handle repositioning error */}
Source:https://www.securecoding.cert.org/confluence/display/seccode/FIO07-C.+Prefer+fseek%28%29+to+rewind%28%29
This article is contributed by Rahul Gupta. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
C-File Handling
secure-coding
C Language
GFacts
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Hide legend entries in a plotly figure in Python

22 Nov, 2021
In this article, we are going to see how to hide legend entries in a plotly figure using Python.
The Fig below shows the plot without hiding the legend entries:
Here we are going to set showlegend property to remove the legend entries in a plotly figure.
Python3
import pandas as pdimport plotly.offline as pyimport plotly.graph_objs as goimport cufflinks as cfcf.go_offline()  df = pd.DataFrame(data=[[2, 3, 4], [8, 27, 64]],                  columns=['A', 'B', 'C'])  # get figure propertyfig = df.iplot(kind='scatter', asFigure=True)  # set showlegend property by name of tracefor trace in fig['data']:    if(trace['name'] != 'B'):        trace['showlegend'] = False  # generate webpagepy.plot(fig)
Output: 
Here we are going to use the update function to remove all the entries
Python3
import pandas as pdimport plotly.offline as pyimport plotly.graph_objs as goimport cufflinks as cfcf.go_offline()  df = pd.DataFrame(data=[[2, 3, 4], [8, 27, 64]],                   columns=['A', 'B', 'C'])  # get figure propertyfig = df.iplot(kind='scatter', asFigure=True)  # set layout_showlegend=Falsefig.update(layout_showlegend=False)  # generate webpagepy.plot(fig)
Output:
Picked
Python-Plotly
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
Introduction To PYTHON
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
How to determine if a number is odd or even in JavaScript?

Use the modulus % operator to determine if a number if odd or even in JavaScript.
You can try to run the following code to check if a number is odd or even −
Live Demo
<!DOCTYPE html>
<html>
<body>
<script>
   var num = 5;
   document.write("Number = "+num+"<br>");
   if(num % 2 == 0) {
      document.write('Number is even!');
   } else {
      document.write('Number is odd!');
   }
</script>
</body>
</html>
Number = 5
Number is odd!
std::upper_bound and std::lower_bound for Vector in C++ STL

29 Jun, 2022
Click here for Set 1 and Set 2 of Vectors.   
Iterator lower_bound (Iterator first, Iterator last, const val) Iterator upper_bound (Iterator first, Iterator last, const val) lower_bound returns an iterator pointing to the first element in the range [first,last) which has a value not less than ‘val’. 
and if the value is not present in the vector then it returns the end iterator.upper_bound returns an iterator pointing to the first element in the range [first,last) which has a value greater than ‘val’. 
CPP
// lower_bound and upper_bound in vector #include <algorithm> // for lower_bound, upper_bound and sort#include <iostream>#include <vector> // for vector using namespace std; int main(){    int gfg[] = { 5, 6, 7, 7, 6, 5, 5, 6 };     vector<int> v(gfg, gfg + 8); // 5 6 7 7 6 5 5 6     sort(v.begin(), v.end()); // 5 5 5 6 6 6 7 7     vector<int>::iterator lower, upper;    lower = lower_bound(v.begin(), v.end(), 6);    upper = upper_bound(v.begin(), v.end(), 6);     cout << "lower_bound for 6 at position "         << (lower - v.begin() + 1) << '\n';    cout << "upper_bound for 6 at position "         << (upper - v.begin() + 1) << '\n';     return 0;}
  Output : 
lower_bound for 6 at position 4
upper_bound for 6 at position 7
Let us see the difference table with 5 useful differences that are as follows: 
Please write comments if you find anything incorrect, or if you want to share more information about the topic discussed above 
rajkamal10
lokeshsingh7695
mayank007rawa
pulkittiwari619
cpp-binary-search
cpp-containers-library
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Bitwise Operators in C/C++
Priority Queue in C++ Standard Template Library (STL)
vector erase() and clear() in C++
Substring in C++
Object Oriented Programming in C++
The C++ Standard Template Library (STL)
Inheritance in C++
C++ Classes and Objects
Sorting a vector in C++
2D Vector In C++ With User Defined Size
How to get the index value in C#? - GeeksforGeeks

28 Nov, 2019
The Index Structure is introduced in C# 8.0. It represents a type that can be used to index a collection or sequence and it can be started from the start or the end. You are allowed to get the index value with the help of Value Property provided by the Index struct.
Syntax:
public int Value { int get(); };
Example 1:
// C# program to illustrate the // concept of the value propertyusing System;  namespace example {  class GFG {      // Main Method    static void Main(string[] args)    {        // Creating new indexes        // Using Index() constructor        var val1 = new Index(1, true);        var val2 = new Index(2, true);        var val3 = new Index(1, false);        var val4 = new Index(3, false);          // Getting the value of the index        var res1 = val1.Value;        var res2 = val2.Value;        var res3 = val3.Value;        var res4 = val4.Value;          // Display index value        Console.WriteLine("Index value is : " + res1);        Console.WriteLine("Index value is : " + res2);        Console.WriteLine("Index value is : " + res3);        Console.WriteLine("Index value is : " + res4);    }}}
Output:
Index value is : 1
Index value is : 2
Index value is : 1
Index value is : 3

Example 2:
// C# program to illustrate the // concept of the value propertyusing System;  namespace example {  class GFG {      // Main Method    static void Main(string[] args)    {        // Creating and initializing an array        string[] greetings = new string[] {"Hello", "Hola", "Namaste",                                "Bonjour", "Ohayo", "Ahnyounghaseyo"};          // Creating index        // Using Index() constructor        var val1 = new Index(1, true);        var val2 = new Index(2, false);          // Checking the given both the         // index values are equal or not        if (val1.Value.Equals(val2.Value) == true)         {            Console.WriteLine("Both the indexes are equal and"+              " their elements are : {0}, {1}", greetings[val1],                                              greetings[val2]);        }          else {            Console.WriteLine("Both the indexes are not equal"+           " and their elements are : {0}, {1}", greetings[val1],                                               greetings[val2]);        }    }}}
Output:
Both the indexes are not equal and their elements are : Ahnyounghaseyo, Namaste
CSharp-8.0
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Extension Method in C#
Top 50 C# Interview Questions & Answers
Partial Classes in C#
HashSet in C# with Examples
C# | Inheritance
C# | How to insert an element in an Array?
C# | List Class
Lambda Expressions in C#
C# | Generics - Introduction
What is Regular Expression in C#?
tex - Tutorial

MathJax is a javascript based platform to draw mathematical expressions and symbols in web applications.
This tutorial will cover TEX Commands available in MathJax project.
This tutorial is designed for all those individuals who are looking for a starting point of learning TEX commands using MathJax and we cover topics suited for a beginner and an advanced user.
Before proceeding with this tutorial it is advisable for you to understand the basics concepts of MathJax and Tex commands. But the tutorial is self contained and you will be able to learn on various concepts of TEX even if you are a beginner. You just need to have a basic understanding of working with a simple text editor and command line.
We've used MathJax 2.6 using the MathJax Content Distribution Network (CDN) by putting following code snippet in head section of our demo html pages:
<script type="text/javascript"
   src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
   tex2jax: { inlineMath: [["$","$"],["\\(","\\)"]] },
   "HTML-CSS": {
      linebreaks: { automatic: true }
   },
   SVG: { 
      linebreaks: { automatic: true } 
   }
});
</script>
For most of the examples given in this tutorial you will see,the output. Just right click over the expression. Select following options from context menu: Show Math As > TeX Commands to see the source code.
$ a+1 \above 1pt b $


    14 Lectures 
     52 mins

 Ashraf Said

    11 Lectures 
     1 hours 

 Ashraf Said

    9 Lectures 
     1 hours 

 Emenwa Global, Ejike IfeanyiChukwu

    29 Lectures 
     2.5 hours 

 Mohammad Nauman

    14 Lectures 
     1 hours 

 Daniel Stern

    15 Lectures 
     47 mins

 Nishant Kumar
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

Tryit: Set height and width in percent
How to access an array element in C language?

An array is a group of related data items that share a common name. A particular value in an array is identified by using its "index number" or "subscript".
The advantage of an array is as follows −
The ability to use a single name to represent a collection of items and to refer to an item by specifying the item number enables the user to develop concise and efficient programs.
The ability to use a single name to represent a collection of items and to refer to an item by specifying the item number enables the user to develop concise and efficient programs.
The syntax for declaring array is as follows −
datatype array_name [size];
For example,
float height [50]
This declares ‘height’ to be an array containing 50 float elements.
int group[10]
This declares the ‘group’ as an array to contain a maximum of 10 integer constants.
Individual elements are identified using "array subscripts". While complete set of values are referred to as an array, individual values are called "elements".
Accessing the array elements is easy by using an array index.
Following is the C program for accessing an array −
 Live Demo
#include<stdio.h>
int main(){
   int array[5],i ;
   array[3]=12;
   array[1]=35;
   array[0]=46;
   printf("Array elements are: ");
   for(i=0;i<5;i++){
      printf("%d ",array[i]);
   }
   return 0;
}
When the above program is executed, it produces the following result −
Array elements are: 46 35 38 12 9704368
Array[2] and array[4] prints garbage values because we didn’t enter any values in that locations
How to implement a long click listener on a Android listview?

This example demonstrates about How to implement a long click listener on a Android listview.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   tools:context=".MainActivity">
   <ListView
      android:id="@+id/listView"
      android:layout_width="match_parent"
      android:layout_height="match_parent" />
</LinearLayout>
Step 3 − Add the following code to src/MainActivity.java
package app.com.sample;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
   String[] mobileArray = {"Android", "IPhone", "WindowsMobile", "Blackberry", "WebOS", "Ubuntu", "Windows7", "Max OS X"};
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      ListView listView = findViewById(R.id.listView);
      ArrayAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mobileArray);
      listView.setAdapter(adapter);
      listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
         @Override
         public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int pos, long id) {
            Toast.makeText(getApplicationContext(), "long clicked", Toast.LENGTH_SHORT).show();
            return true;
         }
      });
   }
}
Step 4 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
Click here to download the project code.
MS SQL Server - Create Users

User refers to an account in MS SQL Server database which is used to access database.
Users can be created using either of the following two methods.
Create user <username> for login <loginname>

To create user name 'TestUser' with mapping to Login name 'TestLogin' in TestDB database, run the following query.
create user TestUser for login TestLogin

Where 'TestLogin' is the login name which was created as part of the Login creation
Note − First we have to create Login with any name before creating a user account.
Let’s use Login name called 'TestLogin'.
Step 1 − Connect SQL Server and expand databases folder. Then expand database called 'TestDB' where we are going to create the user account and expand the security folder. Right-click on users and click on the new user to see the following screen.
Step 2 − Enter 'TestUser' in the user name field and click on ellipse to select the Login name called 'TestLogin' as shown in the following snapshot.
Step 3 − Click OK to display login name. Again click OK to create 'TestUser' user as shown in the following snapshot.

    32 Lectures 
     2.5 hours 

 Pavan Lalwani

    18 Lectures 
     1.5 hours 

 Dr. Saatya Prasad

    102 Lectures 
     10 hours 

 Pavan Lalwani

    52 Lectures 
     4 hours 

 Pavan Lalwani

    239 Lectures 
     33 hours 

 Gowthami Swarna

    53 Lectures 
     5 hours 

 Akshay Magre
 Print
 Add Notes
 Bookmark this page
How to set an object key inside a state object in React Hooks? - GeeksforGeeks

14 Jan, 2021
We can update a React hooks state object that has a nested object containing objects with index keys with the following approach, Before doing so, consider the following example:
Example: Following is the default state object:
const [data, setData] = useState({
   name:'',
   contact:'',
   address:{
     0:{},
     1:{},
   }
})
Following is the desired output after updating a nested object:
{
  name:'',
  contact:'',
  address:{
    0:{"city":'jaipur'},
    1:{},
  }  
}
Solution: We can use the below syntax to set an object key inside a state object:
data.address[0].city = 'jaipur';
setData({...data});
Creating React Application:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Filename: App.js
Javascript
import React, { Component, useState } from "react";  const App = () => {  const [data, setData] = useState({    name: '',    contact: '',    address: {      0: {},      1: {},    }  })    const handleUpdate = () => {    data.address[0].city = 'jaipur';    setData({ ...data });  }    return (    <div >      <button        style={{ margin: 100 }}        onClick={() => { handleUpdate() }} >        change state      </button>      { data.address[0].city + " "}    </div>  );}  export default App;
Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: 
Following will be the output before clicking the button:Before Click
Following will be the output before clicking the button:
Before Click
Following will be the output after clicking the button:After Click
Following will be the output after clicking the button:
After Click
Picked
react-js
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
How to filter object array based on attributes?
How to get selected value in dropdown list using JavaScript ?
How to remove duplicate elements from JavaScript Array ?
Angular File Upload
Remove elements from a JavaScript Array
Introduction to Object Oriented Programming in JavaScript
How to change selected value of a drop-down list using jQuery?
How to get character array from string in JavaScript?
How to adjust the line spacing in the text node in JavaFX?

The line spacing property of the javafx.scene.text.The text class specifies the line spacing between the lines of the text (node) vertically.
You can set the value to this property using the setLineSpacing() method. This method accepts a boolean value as a parameter and sets the specified space between the lines (vertically).
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Scanner;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
public class TextSpacing extends Application {
   public void start(Stage stage) throws FileNotFoundException {
      //Reading the contents of a text file.
      InputStream inputStream = new FileInputStream("D:\\sample_text.txt");
      Scanner sc = new Scanner(inputStream);
      StringBuffer sb = new StringBuffer();
      while(sc.hasNext()) {
         sb.append(" "+sc.nextLine()+"\n");
      }
      //Creating a text object
      Text text = new Text(10.0, 25.0, sb.toString());
      //Wrapping the text
      text.setWrappingWidth(565);
      //Setting the alignment
      text.setTextAlignment(TextAlignment.JUSTIFY);
      //Setting the space
      text.setLineSpacing(2.0);
      //Setting the stage
      Group root = new Group(text);
      Scene scene = new Scene(root, 595, 150, Color.BEIGE);
      stage.setTitle("Line Spacing (2.0)");
      stage.setScene(scene);
      stage.show();
   }
   public static void main(String args[]){
      launch(args);
   }
}
Assume following are the contents of the sample.txt file −
Tutorials Point originated from the idea that there exists a class of readers who respond better 
to online content and prefer to learn new skills at their own pace from the comforts of their drawing rooms.
The journey commenced with a single tutorial on HTML in 2006 and elated by the response it generated, 
we worked our way to adding fresh tutorials to our repository which now proudly flaunts a wealth of 
tutorials and allied articles on topics ranging from programming languages to web designing to academics 
and much more.
 In the same way, the following will be the output if you set the line spacing as 8.0 −
How to change the font size of main title of boxplot in base R?

The font size of the main title of boxplot can be changed by defining the font size value using par(cex.main=”size”), here size value can be changed based on our requirement. This needs to be done before creating the boxplot, otherwise, there will be no effect on the size of the main title.
 Live Demo
x<−rnorm(50)
par(cex.main=0.5)
boxplot(x,main="boxplot")
Creating the plot with different font size of main title −
par(cex.main=2.5)
boxplot(x,main="boxplot")
How to remove an element from Array List in C#?

Declare a new ArrayList and add elements to it.
ArrayList arr = new ArrayList();
arr.Add( "One" );
arr.Add( "Two" );
arr.Add( "Three" );
arr.Add( "Four" );
Now let’s say you need to remove the element “Three”. For that, use the Remove() method.
arr.Remove("Three");
The following is the complete example to remove an element from ArrayList −
 Live Demo
using System;
using System.Collections;

class Demo {

   static void Main() {
      ArrayList arr = new ArrayList();
      arr.Add( "One" );
      arr.Add( "Two" );
      arr.Add( "Three" );
      arr.Add( "Four" );

      Console.WriteLine("ArrayList...");
      foreach(string str in arr) {
         Console.WriteLine(str);
      }

      arr.Remove("Three");
      Console.WriteLine("ArrayList after removing an element...");

      foreach(string str in arr) {
         Console.WriteLine(str);
      }

      Console.ReadLine();
   }
}
ArrayList...
One
Two
Three
Four
ArrayList after removing an element...
One
Two
Four