code-rag-bench/online-tutorials huggingface dataset:
Pandas - Analyzing DataFrames

One of the most used method for getting a quick overview of the DataFrame, is the head() method.
The head() method returns the headers and 
a specified number of rows, starting from the top.
Get a quick overview by printing the first 10 rows of the DataFrame:
In our examples we will be using a CSV file called 'data.csv'.
Download data.csv, or open
data.csv in your browser.
Note: if the number of rows is not specified, the head() method 
  will return 
  the top 5 rows.
Print the first 5 rows of the DataFrame:
There is also a tail() method for viewing the 
last rows of the DataFrame.
The tail() method returns the headers and 
a specified number of rows, starting from the bottom.
Print the last 5 rows of the DataFrame:
The DataFrames object has a method called info(), that 
gives you more information about 
the data set.
Print information about the data:

  <class 'pandas.core.frame.DataFrame'>
  RangeIndex: 169 entries, 0 to 168
  Data columns (total 4 columns):
   #   Column    Non-Null Count  Dtype  
  ---  ------    --------------  -----  
   0   Duration  169 non-null    int64  
   1   Pulse     169 non-null    int64  
   2   Maxpulse  169 non-null    int64  
   3   Calories  164 non-null    float64
  dtypes: float64(1), int64(3)
  memory usage: 5.4 KB
  None
    
The result tells us there are 169 rows and 4 columns:

  RangeIndex: 169 entries, 0 to 168
  Data columns (total 4 columns):


And the name of each column, with the data type:

   #   Column    Non-Null Count  Dtype  
  ---  ------    --------------  -----  
   0   Duration  169 non-null    int64  
   1   Pulse     169 non-null    int64  
   2   Maxpulse  169 non-null    int64  
   3   Calories  164 non-null    float64


The info() method also tells us how many Non-Null values there are present in each column,
and in our data set it seems like there are 164 of 169 Non-Null values in the "Calories" column.
Which means that there are 5 rows with no value at all, in the "Calories" column, for whatever reason.
Empty values, or Null values, can be bad when analyzing data,
and you should consider removing rows with empty values.
This is a step towards what is called cleaning data,
and you will learn more about that in the next chapters.
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
What is the difference between replace() and replaceAll() in Java?

The replace method of the String class accepts two characters and it replaces all the occurrences of oldChar in this string with newChar.
import java.io.*;
public class Test {
   public static void main(String args[]) {
      String Str = new String("Welcome to Tutorialspoint.com");
      System.out.print("Return Value :" );
      System.out.println(Str.replace('o', 'T'));
      System.out.print("Return Value :" );
      System.out.println(Str.replace('l', 'D'));
   }
}
Return Value :WelcTme tT TutTrialspTint.cTm
Return Value :WeDcome to TutoriaDspoint.com
The replaceAll() method replaces each substring of this string that matches the given regular expression with the given replacement.
import java.io.*;
public class Test {
   public static void main(String args[]) {
      String Str = new String("Welcome to Tutorialspoint.com");
      System.out.print("Return Value :" );
      System.out.println(Str.replaceAll("(.*)Tutorials(.*)", "AMROOD"));
   }
}
Return Value :AMROOD
Iterate through KeyValue Tuple in Java

To iterate through the KeyValue tuple in Java, use the Iterable and loop it through using the for loop. Let us first see what we need to work with JavaTuples. To work with KeyValue class in JavaTuples, you need to import the following package:
import org.javatuples.KeyValue;
Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples:
Steps: How to run JavaTuples program in Eclipse
The following is an example to iterate through KeyValue Tuple in Java:
import org.javatuples.KeyValue;
public class Demo {
   public static void main(String[] args) {
      KeyValue<Integer, String> kValue = KeyValue.with(77, "Rank");
      System.out.println("Iterating through the values of the KeyValue Tuple = ");
      for (Object ele : kValue) System.out.println(ele);
      boolean res = kValue.contains("Rank");
      System.out.println("Does the value exist in the Tuple? = "+res);
   }
}
Iterating through the values of the KeyValue Tuple =
77
Rank
Does the value exist in the Tuple? = true
C# Object.GetHashCode() Method with Examples

The Object.GetHashCode() method in C# is used to serve as the default hash function.
public virtual int GetHashCode ();
Let us now see an example -
 Live Demo
using System;
public class Demo {
   public static void Main() {
      Object ob = new Object();
      String str = "Jim";
      Type type1 = ob.GetType();
      Type type2 = str.GetType();
      Console.WriteLine("Hash Code = "+type1.GetHashCode());
      Console.WriteLine("Hash Code = "+type2.GetHashCode());
   }
}
Hash Code =30015890
Hash Code =21083178
Let us now see another example:
using System;
public struct Value {
   private int v1;
   private int v2;
   private int v3;
   public Value(int v1, int v2, int v3) {
      this.v1 = v1;
      this.v2 = v2;
      this.v3 = v3;
   }
   public override int GetHashCode() {
      return Tuple.Create(v1, v2, v3).GetHashCode();
   }
}
public class Demo {
   public static void Main() {
      Value v = new Value(1, 7, 12);
      Console.WriteLine(v.GetHashCode());
      v = new Value(12, 8, 7);
      Console.WriteLine(v.GetHashCode());
      v = new Value(8, 7, 12);
      Console.WriteLine(v.GetHashCode());
   }
}
This will produce the following output -
1258
12803
8931
Check if values in a vector are True or not in R Programming – all() and any() Function

23 Dec, 2021
In this article, we are going to check if the values in a vector are true or not in R Programming Language.
all() function in R Language will check in a vector whether all the values are true or not.
Syntax: all(x, na.rm) 
Parameters: 
x: vector
na.rm: logical, if NA value to removed before result
Example 1: Basic example of all() function in r
R
# R program to illustrate# all function # Example vector<x1 <- c(1, 2, 3, - 4, 5)                        all(x1 < 0)
Output:
FALSE
Here in the above code, we have created an example vector and applied all() functions to it. Clearly, all the values are not less than zero, one value -4 is less than zero, so the answer is FALSE.
Example 2: Using na.rm argument
R
# R program to illustrate# all function with na.rm # Example vector with NA valuex2 <- c(1, 2, 3, -4, 5, NA) # Apply all function with na.rm = TRUEall(x2 < - 10, na.rm = TRUE)
Output:
TRUE
Here in the above code, we set the value of na.rm to TRUE. So the output is TRUE. As all of them are greater than -10 in the above code.
any() function in R Programming language will check in vector whether any of the values is true.
Syntax: any(x, na.rm)
Parameters: 
x: vector 
na.rm: logical, if NA value to removed before result
Example 1: any() function
R
# R program to illustrate# any() function # Example vectorx1 <- c(1, 2, 3, - 4, 5, )                        # Apply any function in Rany(x1 < 0)                                           
Output:
TRUE
Here in the above code, we have applied any() function. Since one value is “-4” (lesser than 0), so the answer is TRUE.
Example 2: Any function using na.rn argument
R
# R program to illustrate# any function with na.rm # Example vector with NA valuex2 <- c(1, 2, 3, -4, 5, NA) # Apply any function with na.rm = TRUEany(x2 < - 10, na.rm = TRUE)                           
Output:
FALSE
Here in the above code, we set the value of na.rm to TRUE. So the output is False. As all of them are lesser than -10 in the above code.
kumar_satyam
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Creating a Private Repository and Push an Image to That Private Repository - GeeksforGeeks

16 Oct, 2020
In this article, we show how to create a docker hub account and pull the image from the docker hub repository and pushing our image to the docker hub repository. As docker hub is a public repository that can be accessed by anyone so one can create their own private repository to which they can push and pull their image. For this, there is a registry container from the docker itself.
Installed docker software in your respective operating system.
A pulled image in your docker container which you want to push into your private repository.
Step 1:The first step is to use the docker run command to download the private registry.
sudo docker -d -p 5000:5000 --name registry registry:2


Description of commands:
-d: This option is used to run the container in detached mode i.e the container can run in the background.
-p: This option is used to map our port number with 5000 port numbers on our localhost.
registry: It is a container provided by docker to host our private repositories.
2: It is a tag to a registry to differentiate on the docker host.
You can use the docker ps command to see the running registry container.
sudo docker ps

Step 2: In this step, we are going to tag our existing image so that we can push that image to our local repository. 
sudo docker tag image_id tag_name

Description of commands:
image_id: The id of the image you want to push to your private repository.
tag_name: The name you want to give to your tag.
Step 3: We have tagged our image now it is ready to push to the private repository.
sudo docker push tag_name

Step 4: Now delete the local images so that we can pull it from a private repository. To delete the image use rmi command.
sudo rmi image_id

Step 5: In the previous step, we have deleted all the images now we pull the image from the private repository by docker pull command.
sudo docker pull image_tag

Advanced Computer Subject
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
ML | Stochastic Gradient Descent (SGD)
Copying Files to and from Docker Containers
Principal Component Analysis with Python
ML | Principal Component Analysis(PCA)
ML | Types of Learning – Supervised Learning
Q-Learning in Python
Classifying data using Support Vector Machines(SVMs) in R
Classifying data using Support Vector Machines(SVMs) in Python
Getting Started with System Design
Deep Learning | Introduction to Long Short Term Memory
How to Use Light Dependent Resistor (LDR) with Arduino?

The resistance of a Light Dependent Resistor (LDR) changes depending on the intensity of the light falling on it. Interfacing an LDR with Arduino is quite straightforward. You just create a voltage divider as shown below −
One end of the LDR is connected to 5V, the other end to a resistor (whose resistance should be approx. the same order of magnitude as the max resistance of the LDR). For instance, we are using an LDR with a resistance of 90K and the resistor has the maximum resistance of 150K. The other end of the resistor is connected to GND, and the common terminal of the LDR and the resistor is fed to an Analog pin (A0) in this case.
Now all you need to do is read the analog voltage using analogRead(A0). And try covering the LDR with your hand and later uncovering it and flashing a torch on it. The resistance will be at two extremes in the two cases, and the readings will also be at two opposite extremes.
The code is given below −
int ldrPin = A0;
void setup() {
   // put your setup code here, to run once:
    Serial.begin(9600);
}
void loop() {
   // put your main code here, to run repeatedly:
   Serial.println(analogRead(ldrPin));
   delay(100);
}
Single and Double Quotes in Perl

You can use double quotes or single quotes around literal strings as follows −
 Live Demo
#!/usr/bin/perl
print "Hello, world\n";
print 'Hello, world\n';
This will produce the following result −
Hello, world
Hello, world\n$
There is an important difference between single and double-quotes. Only double quotes interpolate variables and special characters such as newlines \n, whereas a single quote does not interpolate any variable or special character. Check below example where we are using $a as a variable to store a value and later printing that value −
 Live Demo
#!/usr/bin/perl
$a = 10;
print "Value of a = $a\n";
print 'Value of a = $a\n';
This will produce the following result −
Value of a = 10
Value of a = $a\n$
Node.js zlib flush() Method - GeeksforGeeks

11 Oct, 2021
The flush() method is called on a compression stream so that it can compel zlib to return as much output as achievable at present. This output may be returned at the cost of corrupt compression quality but it can be useful when data is required to be accessible as early as possible.
Syntax:
zlib.flush()
Parameters: This method does not accept any parameters.
Return Value: It returns the data as much as possible at present.
Below examples illustrate the use of zlib.flush() method in Node.js:
Example 1:
// Node.js program to demonstrate the     // zlib.flush() method   // Including zlib moduleconst zlib = require('zlib');   // Constructing createGzip and createGunzipconst input = zlib.createGzip();const output = zlib.createGunzip();   // Pipinginput.pipe(output);   // Write to streaminput.write('GeeksforGeeks');   // Calling flush methodinput.flush();   // Check outputoutput.on('data', (d) => {    console.log('Input: Data flush received '     + d.length + ' bytes');});console.log("Program Complete!");
Output:
Program Complete!
Input: Data flush received 13 bytes
Example 2:
// Node.js program to demonstrate the     // zlib.flush() method  // Including zlib moduleconst zlib = require('zlib');  // Constructing createGzip and createGunzipconst input = zlib.createGzip();const output = zlib.createGunzip();  // Pipinginput.pipe(output);  // Writing to a stream of data 19000 bytesinput.write('G'.repeat(19000));  // Calling flush method with callbackinput.flush(() => {});  // Check outputoutput.on('data', (d) => {    console.log('Input: Data flush with callback received '     + d.length + ' bytes');});console.log("Program Complete!");
Output: So, after the byte size exceeds 16384 bytes then you need to callback flush method else data won’t be flushed fully.
Program Complete!
Input: Data flush with callback received 16384 bytes
Input: Data flush with callback received 2616 bytes

Reference: https://nodejs.org/api/zlib.html#zlib_flushing
Node.js-Zlib-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Express.js express.Router() Function
Mongoose Populate() Method
Mongoose find() Function
Express.js req.params Property
Mongoose | findOneAndDelete() Function
Express.js express.Router() Function
How to set input type date in dd-mm-yyyy format using HTML ?
Differences between Functional Components and Class Components in React
How to create footer to stay at the bottom of a Web page?
How to float three div side by side using CSS?
PHP Array Operators

PHP defines following set of symbols to be used as operators on array data types
The Union operator appends the right-hand array appended to left-hand array. ; If a key exists in both arrays, the elements from the left-hand array will be used, and the matching elements from the right-hand array will be ignored.
Following example shows use of define() function to define constants
 Live Demo
<?php
$arr1=array("phy"=>70, "che"=>80, "math"=>90);
$arr2=array("Eng"=>70, "Bio"=>80,"CompSci"=>90);
$arr3=$arr1+$arr2;
var_dump($arr3);
?>
Following result will be displayed
array(6) {
["phy"]=>
int(70)
["che"]=>
int(80)
["math"]=>
int(90)
["Eng"]=>
int(70)
["Bio"]=>
int(80)
["CompSci"]=>
int(90)
}
Two arrays are said to be equal if they have same key-value pairs. Following example has an indexed array and other associative array with keys corresponding to index of elements in first. Hence both are equal
 Live Demo
<?php
$arr1=array(0=>70, 2=>80, 1=>90);
$arr2=array(70,90,80);
var_dump ($arr1==$arr2);
var_dump ($arr2!=$arr1);
?>
Following result will be displayed
bool(true)
bool(false)
Arrays are identical if and only if both of them have same set of key-value pairs and in same order
 Live Demo
<?php
$arr1=array(0=>70, 1=>80, 2=>90);
$arr2=array(70,90,80);
var_dump ($arr1===$arr2);
$arr3=[70,80,90];
var_dump ($arr3===$arr1);
?>
Following result will be displayed
bool(false)
bool(true)
\frac - Tex Command

\frac - Used to draw fractions.
{ \frac #1 #2 }
\frac command is used to draw fractions.

\frac a b

ab


\frac{a-1}b-1

a−1b−1


\frac{a-1}{b-1}

a−1b−1



\frac a b

ab


\frac a b
Trigraphs in C++ with Examples

17 Jul, 2020
In C++, a trigraph is a three-character sequence that represents a single character. It means that trigraph sequences are the set of three characters starting from double question marks (??). These characters are constructed using a sequence of 3 characters called trigraphs and these set of the characters are replaces by a single character.
Syntax:
??=define
Becomes,
#define


Below is the basic implementation example of the Trigraphs sequences:
C++
// C++ implementation to // illustrate the example // of trigraph sequences   # include <iostream>using namespace std;   ??=define MSG "GeeksforGeeks"??=define Program "C++"   // Driver Codeint main()??< // Here ??< denotes {    cout << "My message to " << MSG << endl;    cout << "My program is " << Program;           return 0;??> // Here ??> denotes }
My message to GeeksforGeeks
My program is C++

Below is another example of the Trigraph sequences:
C++
// C++ program to demonstrate // the example // of trigraph sequences   # include <iostream>using namespace std;   // Here ??= denotes #??=define Name "Kalpana"??=define Age "23"??=define Qualification "B.tech"??=define From "Delhi"   // Driver Codeint main()??<    cout << "My Name is: " << Name << endl;    cout << "My Age is: " << Age << endl;              cout << "My Qualification is: "         << Qualification << endl;    cout << "I'm From " << From;           return 0;??>
My Name is: Kalpana
My Age is: 23
My Qualification is: B.tech
I'm From Delhi

C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting a vector in C++
Polymorphism in C++
Pair in C++ Standard Template Library (STL)
Friend class and function in C++
std::string class in C++
Queue in C++ Standard Template Library (STL)
std::find in C++
Unordered Sets in C++ Standard Template Library
List in C++ Standard Template Library (STL)
vector insert() function in C++ STL
How to create a matrix of random integers in Python ?

11 Dec, 2020
Prerequisites: numpy
To create a matrix of random integers in Python, randint() function of the numpy module is used. This function is used for random sampling i.e. all the numbers generated will be at random and cannot be predicted at hand.
Syntax :  numpy.random.randint(low, high=None, size=None, dtype=’l’)
Parameters :
low : [int] Lowest (signed) integer to be drawn from the distribution.But, it works as a highest integer in the sample if high=None. 
high : [int, optional] Largest (signed) integer to be drawn from the distribution. 
size : [int or tuple of ints, optional] Output shape. If the given shape is, e.g., (m, n, k), then m * n * k samples are drawn. Default is None, in which case a single value is returned. 
dtype : [optional] Desired output data-type.
Return : Array of random integers in the interval [low, high) or a single such random int if size not provided.
Example 1:
Python3
# importing numpy libraryimport numpy as np    # random is a function, doing random sampling in numpy.array = np.random.randint(10, size=(20))  # the array will be having 20 elements.print(array)
Output:
 [2 6 1 4 3 3 6 5 0 3 6 8 9 1 6 4 0 5 4 1]
Example 2:
Python3
import numpy as np  # 1st argument --> numbers ranging from 0 to 9, # 2nd argument, row = 2, col = 3array = np.random.randint(10, size=(2, 3))print(array)
Output:  
[[8 6 7]
 [2 9 9]]
Example 3:
Python3
import numpy as np    array = np.random.randint(2, size=(5, 5))print(array)
Output:
 [[0 0 1 0 0] 
 [1 0 1 1 0] 
 [0 1 0 1 0] 
 [0 1 0 0 1]
[0 1 0 1 0]]
Python numpy-Matrix Function
Python-numpy
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 | os.path.join() method
Python OOPs Concepts
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
Java program to count the characters in each word in a given sentence

To count the characters in each word in a given sentence, the Java code is as follows −
 Live Demo
import java.util.*;
public class Demo{
   static final int max_chars = 256;
   static void char_occurence(String my_str){
      int count[] = new int[max_chars];
      int str_len = my_str.length();
      for (int i = 0; i < str_len; i++)
         count[my_str.charAt(i)]++;
      char ch[] = new char[my_str.length()];
      for (int i = 0; i < str_len; i++){
         ch[i] = my_str.charAt(i);
         int find = 0;
         for (int j = 0; j <= i; j++){
            if (my_str.charAt(i) == ch[j])
               find++;
         }
         if (find == 1)
            System.out.println("The number of occurrence of " + my_str.charAt(i) + " is :" +
            count[my_str.charAt(i)]);
      }
   }
   public static void main(String[] args){
      Scanner my_scan = new Scanner(System.in);
      String my_str = "This is a sample";
      char_occurence(my_str);
   }
}
The number of occurrence of T is :1
The number of occurrence of h is :1
The number of occurrence of i is :2
The number of occurrence of s is :3
The number of occurrence of is :3
The number of occurrence of a is :2
The number of occurrence of m is :1
The number of occurrence of p is :1
The number of occurrence of l is :1
The number of occurrence of e is :1
A class named Demo contains the function ‘char_occurence’ that iterates through the string and
counts every character and assigns its count to the respective character in the count array. In the main function, a Scanner class object is created to read the input from the console. The function is called on string and the count of every character is displayed on the console.
GATE | GATE-CS-2006 | Question 57

28 Jun, 2021
Consider this C code to swap two integers and these five statements after it:
void swap(int *px, int *py) {    *px = *px - *py;    *py = *px + *py;    *px = *py - *px; }
S1: will generate a compilation errorS2: may generate a segmentation fault at runtime depending on the arguments passedS3: correctly implements the swap procedure for all input pointers referring to integers stored in memory locations accessible to the processS4: implements the swap procedure correctly for some but not all valid input pointersS5: may add or subtract integers and pointers.
(A) S1(B) S2 and S3(C) S2 and S4(D) S2 and S5Answer: (C)Explanation: Same as https://www.geeksforgeeks.org/c-pointers-question-14/Quiz of this Question
GATE-CS-2006
GATE-GATE-CS-2006
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2014-(Set-3) | Question 20
GATE | GATE CS 2008 | Question 40
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE CS 2008 | Question 46
GATE | GATE CS 2011 | Question 49
GATE | GATE CS 1996 | Question 38
GATE | GATE-CS-2004 | Question 31
Find first and last element of ArrayList in java

11 Dec, 2018
Prerequisite: ArrayList in Java
Given an ArrayList, the task is to get the first and last element of the ArrayList in Java,
Examples:
Input: ArrayList = [1, 2, 3, 4] 
Output: First = 1, Last = 4

Input: ArrayList = [12, 23, 34, 45, 57, 67, 89] 
Output: First = 12, Last = 89

Approach:
Get the ArrayList with elements.Get the first element of ArrayList with use of get(index) method by passing index = 0.Get the last element of ArrayList with use of get(index) method by passing index = size – 1.
Get the ArrayList with elements.
Get the first element of ArrayList with use of get(index) method by passing index = 0.
Get the last element of ArrayList with use of get(index) method by passing index = size – 1.
Below is the implementation of the above approach:
// Java code to find first and last element// of ArrayList  import java.util.ArrayList;  public class GFG {      // main method    public static void main(String[] args)    {          // creating an Empty Integer ArrayList        ArrayList<Integer> list = new ArrayList<Integer>(5);          // using add() to initialize values        list.add(1);        list.add(2);        list.add(3);        list.add(4);          // printing initial value ArrayList        System.out.print("ArrayList: " + list);          // find first element        int first = list.get(0);          // find last element        int last = list.get(list.size() - 1);          // print first and last element of ArrayList        System.out.println("\nFirst : " + first                           + ", Last : " + last);    }}
ArrayList: [1, 2, 3, 4]
First : 1, Last : 4

Java-ArrayList
Java-Collections
Java-List-Programs
Technical Scripter 2018
Java
Technical Scripter
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Print hexadecimal values in Arduino

In order to print hexadecimal equivalents of numbers or characters, adding 'HEX' as the second argument of Serial.print() will be sufficient.
The following code demonstrates this −
void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.println();
   Serial.println(75);
   Serial.println(75, HEX);
   Serial.println('A');
   Serial.println('A',HEX);
}
void loop() {
   // put your main code here, to run repeatedly:
   
}
The corresponding Serial monitor output is −
Now, the conversion of the decimal number 75 to a hexadecimal value is straightforward and you can even verify that 0x4B is the correct hexadecimal representation of 75. But what does the hexadecimal representation of 'A' mean?
Well, it is the hexadecimal representation of the number corresponding to A in the ASCII system. You can have a look at the ASCII table here: https://www.cs.cmu.edu/~pattis/15-1XX/common/handouts/ascii.html
As you can see, 'A' corresponds to number 65, whose hex representation would be 41.
Please note that hex representations do not work for floating point numbers. Serial.println(1.912,HEX); will only print 1.912.
Program to find the Centroid of the Triangle in C++

In this problem, we are given a 2D array that denotes coordinates of three
vertices of the triangle. Our task is to create a program to find the Centroid
of the Triangle in C++.
Centroid of a triangle is the point at which the three medians of the triangles intersect.
Median of a triangle is the line that connects the vertex of the triangle with the center point of the line opposite to it.
Let’s take an example to understand the problem,
(-3, 1), (1.5, 0), (-3, -4)
(-3.5, -1)
Centroid (x, y) = ((-3+2.5-3)/3, (1 + 0 - 4)/3) = (-3.5, -1)
For solving the problem, we will use the geometrical formula for the
centroid of the triangle.
For points (ax, ay), (bx, by), (cx, cy)
Centroid, x = (ax + bx + cx) / 3
y = (ay + by + cy) / 3
Program to illustrate the working of our solution,
 Live Demo
#include <iostream>
using namespace std;
int main() {
   float tri[3][2] = {{-3, 1},{1.5, 0},{-3, -4}};
   cout<<"Centroid of triangle is (";
   cout<<((tri[0][0]+tri[1][0]+tri[2][0])/3)<<" , ";
   cout<<((tri[0][1]+tri[1][1]+tri[2][1])/3)<<")";
   return 0;
}
Centroid of triangle is (-1.5 , -1)
Differences between pass by value and pass by reference in C++

In C++ we can pass arguments into a function in different ways. These different ways are −
Call by Value
Call by Reference
Call by Address
Sometimes the call by address is referred to as call by reference, but they are different in C++. In call by address, we use pointer variables to send the exact memory address, but in call by reference we pass the reference variable (alias of that variable). This feature is not present in C, there we have to pass the pointer to get that effect. In this section we will see what are the advantages of call by reference over call by value, and where to use them
In call by value, the actual value that is passed as argument is not changed after performing some operation on it. When call by value is used, it creates a copy of that variable into the stack section in memory. When the value is changed, it changes the value of that copy, the actual value remains the same.
 Live Demo
#include<iostream>
using namespace std;

void my_function(int x) {
   x = 50;
   cout << "Value of x from my_function: " << x << endl;
}

main() {
   int x = 10;
   my_function(x);
   cout << "Value of x from main function: " << x;
}
Value of x from my_function: 50
Value of x from main function: 10
In call by reference the actual value that is passed as argument is changed after performing some operation on it. When call by reference is used, it creates a copy of the reference of that variable into the stack section in memory. Is uses a reference to get the value. So when the value is changed using the reference it changes the value of the actual variable.
 Live Demo
#include<iostream>
using namespace std;

void my_function(int &x) {
   x = 50;
   cout << "Value of x from my_function: " << x << endl;
}

main() {
   int x = 10;
   my_function(x);
   cout << "Value of x from main function: " << x;
}
Value of x from my_function: 50
Value of x from main function: 50
The call by reference is mainly used when we want to change the value of the passed argument into the invoker function.
The call by reference is mainly used when we want to change the value of the passed argument into the invoker function.
One function can return only one value. When we need more than one value from a function, we can pass them as an output argument in this manner.
One function can return only one value. When we need more than one value from a function, we can pass them as an output argument in this manner.
How to compare two numbers in JavaScript?

To compare two numbers in JavaScript, use the == operator. You can try to run the following code to compare numbers −
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <script>
         var a = 10;
         var b = 20 ;
         if(a == b) {
            document.write("True");
         }else {
            document.write("False");
         }
      </script>
   </body>
</html>
false
C# Program to Pause a Thread

You need to set the milliseconds for which you want the thread to pause, for example, for 5 seconds, use −
Thread.Sleep(5000);
Let us see how to loop through and set the sleep method to pause the thread.
Live Demo
using System;
using System.Threading;
namespace Sample {
   class Demo {
      static void Main(string[] args) {
         for (int i = 0; i < 10; i++) {
            Console.WriteLine("Sleep for 1 second!");
            Thread.Sleep(1000);
         }
         Console.ReadLine();
      }
   }
}
Sleep for 1 second!
Sleep for 1 second!
Sleep for 1 second!
Sleep for 1 second!
Sleep for 1 second!
Sleep for 1 second!
Sleep for 1 second!
Sleep for 1 second!
Sleep for 1 second!
Sleep for 1 second!
Python | Pandas Series.factorize()

13 Feb, 2019
Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.factorize() function encode the object as an enumerated type or categorical variable. This method is useful for obtaining a numeric representation of an array when all that matters is identifying distinct values.
Syntax: Series.factorize(sort=False, na_sentinel=-1)
Parameter :sort : Sort uniques and shuffle labels to maintain the relationship.na_sentinel : Value to mark “not found”.
Returns :labels : ndarrayuniques : ndarray, Index, or Categorical
Example #1: Use Series.factorize() function to encode the underlying data of the given series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series(['New York', 'Chicago', 'Toronto', None, 'Rio'])  # Create the Indexsr.index = ['City 1', 'City 2', 'City 3', 'City 4', 'City 5']   # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.factorize() function to encode the underlying data of the given series object.
# encode the valuesresult = sr.factorize()  # Print the resultprint(result)
Output :As we can see in the output, the Series.factorize() function has successfully encoded the underlying data of the given series object. Notice missing values has been assigned a code of -1. Example #2 : Use Series.factorize() function to encode the underlying data of the given series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series([80, 25, 3, 80, 24, 25])  # Create the Indexindex_ = ['Coca Cola', 'Sprite', 'Coke', 'Fanta', 'Dew', 'ThumbsUp']  # set the indexsr.index = index_  # Print the seriesprint(sr)
Output :
Now we will use Series.factorize() function to encode the underlying data of the given series object.
# encode the valuesresult = sr.factorize()  # Print the resultprint(result)
Output :As we can see in the output, the Series.factorize() function has successfully encoded the underlying data of the given series object.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Convert integer to string in Python
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Dockerize your Python script and connect to external SQL Server | by Radu Nedelcu | Towards Data Science

This guide is written assuming you already have:
Docker installed and switched to using Linux containers
SQL Server instance running
You need to create 3 files:
Dockerfile
main.py (which is your main Python code)
requirements.txt
FROM python:3WORKDIR /appADD requirements.txt .ADD main.py .#OptionalENV https_proxy=http://[proxy]:[port]ENV http_proxy=http://[proxy]:[port]# install FreeTDS and dependenciesRUN apt-get update \ && apt-get install unixodbc -y \ && apt-get install unixodbc-dev -y \ && apt-get install freetds-dev -y \ && apt-get install freetds-bin -y \ && apt-get install tdsodbc -y \ && apt-get install --reinstall build-essential -y# populate "ocbcinst.ini" as this is where ODBC driver config sitsRUN echo "[FreeTDS]\n\Description = FreeTDS Driver\n\Driver = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so\n\Setup = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so" >> /etc/odbcinst.ini#Pip command without proxy settingRUN pip install -r requirements.txt#Use this one if you have proxy settingRUN pip --proxy http://[proxy:port] install -r requirements.txtCMD ["python","-i","main.py"]
Option 1
Create a text file and add one line as follows:
pyodbc==4.0.28
Option 2
Use Python terminal if you use PyCharm or any terminal and run pip freeze command:
pip freeze > requirements.txt
This will produce a file with all required modules.
Finally we want to build and run the image.
#Build the imagedocker build -t my-app .#Run itdocker run my-app#Find container namedocker ps --last 1#Check logsdocker logs <container name>
If you want to explore the container and run the script manually then modify last line of the Dockerfile, build and run again:
#CMD ["python","-i","main.py"]CMD tail -f /dev/null
This will make the container long running, enabling you to open a bash shell within using:
docker exec -ti <container name> bash
Then you would be able to explore the container and execute main.py manually.
If you want to stop or remove your container use:
#List all containersdocker ps -a#List all container iddocker ps -aq#Stop containerdocker stop <container_name>#Will remove all your containersdocker rm -f $(docker ps -aq)
1’s and 2’s complement of a Binary Number?

Binary Number is expressed in base 2. It uses only two digits ‘0’ and ‘1’. Each digit in a binary number is a bit.
Sample binary Number − 0100010111
One's complement of a binary number is obtained by reversing the digits of the binary number i.e. transforming 1 with 0 and 0 with 1.
1’s Complement of 101100 = 010011
Two’s complement of a binary number is obtained by adding one to the one’s complement of a binary number i.e. 1’s complement + 1.
2’s complement of 101101 is 010011.
Code to find One’s and two’s complement −
#include <iostream>
#include<string.h>
using namespace std;
int main() {
   char binary[10] = "01001011";
   cout<<“Binary number is ”<<binary;
   //once complement....
   int length = strlen(binary);
   for(int i=0;i<length;i++) {
      if(binary[i] == '0') {
         binary[i]= '1';
      } else
         binary[i] = '0';
   }
   cout<<“One’s Complement is ”<<binary<<endl;
   // cout<<binary[length-1];
   for(int i = length-1; i>=0; i--) {
      // cout<<binary[i];
      if(binary[i] == '0') {
         binary[i] = '1';
         //cout<<binary[i];
         break;
      } else {
         binary[i] = '0';
      }
   }
   cout<<“Two’s complement is ”<<binary;
   return 0;
}
Binary number is 01001011
One’s complement is 10110100
Two’s complement is 10110101
Tryit Editor v3.7

Tryit: HTML HSL color values
Difference between notify() and notifyAll() in Java

Both notify and notifyAll are the methods of thread class and used to provide notification for the thread.But there are some significant differences between both of these methods which we would discuss below.
Following are the important differences between notify and notifyAll.
ThreadA.java
 Live Demo
public class ThreadA {
   public static void main(String[] args){
      ThreadB b = new ThreadB();
      b.start();
      synchronized(b){
         try{
            System.out.println("Waiting for b to complete...");
            b.wait();
         }
         catch(InterruptedException e){
            e.printStackTrace();
         }
         System.out.println("Total is: " + b.total);
      }
   }
}
class ThreadB extends Thread{
   int total;
   public void run(){
      synchronized(this){
         for(int i=0; i<100 ; i++){
            total += i;
         }
         notify();
      }
   }
}
Waiting for b to complete...
Total is: 4950
Ternary Operator in Dart Programming

The ternary operator is a shorthand version of an if-else condition. There are two types of ternary operator syntax in Dart, one with a null safety check and the other is the same old one we encounter normally.
condition ? expressionOne : expressionTwo;
The above syntax implies that if a certain condition evaluates to true then we evaluate the expressionOne first and then the expressionTwo.
Let's explore a Dart example where we make use of the above syntax of the ternary operator.
Consider the example shown below −
 Live Demo
void main(){
   var ans = 10;
   ans == 10 ? print("Answer is 10") : print("Oh no!");
}
In the above example, we declared a variable named ans with a value 10, and then in the next line, we have a condition of the ternary operator where we are checking if it is equal to 10. If so, then evaluate the first expression else evaluate the expression after the colon (:).
Answer is 10
expression1 ?? expression2
It depicts a conditional statement that is similar to a ternary operator statement. The only difference is that in the above syntax if expression1 is not null, then it gets evaluated else expression2 is evaluated.
Consider the example shown below −
void main(){
   var ans;
   ans ?? print("ans is null");
}
ans is null
Collect.js isNotEmpty() Method - GeeksforGeeks

27 Nov, 2020
The isNotEmpty() method is used to check the given collection is not empty or empty and returns the corresponding boolean value. If the collection is not empty then it returns true otherwise returns false.
Syntax:
collect(array).isNotEmpty()
Parameters: The collect() method takes one argument that is converted into the collection and then isNotEmpty() method is applied on it.
Return Value: This method checks the given collection is not empty or empty and returns the corresponding boolean value.
Below example illustrate the isNotEmpty() method in collect.js:
Example 1:
const collect = require('collect.js');  let arr = [];  const collection = collect(arr);  const isemp = collection.isNotEmpty();  console.log(isemp);
Output:
false
Example 2:
const collect = require('collect.js');  const collection = collect({});  const isemp1 = collection.isNotEmpty();  console.log(isemp1);  const collection1 = collect([10, 20, 30]);  const isemp2 = collection1.isNotEmpty();  console.log(isemp2);
Output:
false
true

Collect.js
JavaScript
Web Technologies
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 get character array from string in JavaScript?
Remove elements from a JavaScript Array
How to filter object array based on attributes?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
Program to reverse linked list by groups of size k in Python

Suppose we have a singly linked list, and another value k, we have to reverse every k contiguous group of nodes.
So, if the input is like List = [1,2,3,4,5,6,7,8,9,10], k = 3, then the output will be [3, 2, 1, 6, 5, 4, 9, 8, 7, 10, ]
To solve this, we will follow these steps −
tmp := a new node with value 0
next of tmp := node
prev := null, curr := null
lp := temp, lc := curr
cnt := k
while curr is not null, doprev := nullwhile cnt > 0 and curr is not null, dofollowing := next of currnext of curr := prevprev := curr, curr := followingcnt := cnt - 1next of lp := prev, next of lc := currlp := lc, lc := currcnt := k
prev := null
while cnt > 0 and curr is not null, dofollowing := next of currnext of curr := prevprev := curr, curr := followingcnt := cnt - 1
following := next of curr
next of curr := prev
prev := curr, curr := following
cnt := cnt - 1
next of lp := prev, next of lc := curr
lp := lc, lc := curr
cnt := k
return next of tmp
Let us see the following implementation to get better understanding −
class ListNode:
   def __init__(self, data, next = None):
      self.val = data
      self.next = next
def make_list(elements):
   head = ListNode(elements[0])
   for element in elements[1:]:
      ptr = head
      while ptr.next:
         ptr = ptr.next
      ptr.next = ListNode(element)
   return head
def print_list(head):
   ptr = head print('[', end = "")
   while ptr:
      print(ptr.val, end = ", ")
      ptr = ptr.next
      print(']')
class Solution:
   def solve(self, node, k):
      tmp = ListNode(0)
      tmp.next = node
      prev, curr = None, node
      lp, lc = tmp, curr
      cnt = k
      while curr:
         prev = None
         while cnt > 0 and curr:
            following = curr.next
            curr.next = prev
            prev, curr = curr, following
            cnt -= 1
         lp.next, lc.next = prev, curr
         lp, lc = lc, curr
         cnt = k
      return tmp.next
ob = Solution()
head = make_list([1,2,3,4,5,6,7,8,9,10])
print_list(ob.solve(head, 3))
[1,2,3,4,5,6,7,8,9,10], 3
[3, 2, 1, 6, 5, 4, 9, 8, 7, 10, ]
Python | PoS Tagging and Lemmatization using spaCy

29 Mar, 2019
spaCy is one of the best text analysis library. spaCy excels at large-scale information extraction tasks and is one of the fastest in the world. It is also the best way to prepare text for deep learning. spaCy is much faster and accurate than NLTKTagger and TextBlob.
How to Install ?
pip install spacy
python -m spacy download en_core_web_sm

 Top Features of spaCy:1. Non-destructive tokenization2. Named entity recognition3. Support for 49+ languages4. 16 statistical models for 9 languages5. Pre-trained word vectors6. Part-of-speech tagging7. Labeled dependency parsing8. Syntax-driven sentence segmentation
 Import and Load Library:
import spacy  # python -m spacy download en_core_web_smnlp = spacy.load("en_core_web_sm")
 POS-Tagging for Reviews:
It is a method of identifying words as nouns, verbs, adjectives, adverbs, etc.
import spacy  # Load English tokenizer, tagger, # parser, NER and word vectorsnlp = spacy.load("en_core_web_sm")  # Process whole documentstext = ("""My name is Shaurya Uppal. I enjoy writing articles on GeeksforGeeks checkoutmy other article by going to my profile section.""")  doc = nlp(text)  # Token and Tagfor token in doc:  print(token, token.pos_)  # You want list of Verb tokensprint("Verbs:", [token.text for token in doc if token.pos_ == "VERB"])
Output:
My DET
name NOUN
is VERB
Shaurya PROPN
Uppal PROPN
. PUNCT
I PRON
enjoy VERB
writing VERB
articles NOUN
on ADP
GeeksforGeeks PROPN
checkout VERB
my DET
other ADJ
article NOUN
by ADP
going VERB
to ADP
my DET
profile NOUN
section NOUN
. PUNCT

# Verb based Tagged Reviews:-
Verbs: ['is', 'enjoy', 'writing', 'checkout', 'going']

 Lemmatization:
It is a process of grouping together the inflected forms of a word so they can be analyzed as a single item, identified by the word’s lemma, or dictionary form.
import spacy  # Load English tokenizer, tagger,# parser, NER and word vectorsnlp = spacy.load("en_core_web_sm")  # Process whole documentstext = ("""My name is Shaurya Uppal. I enjoy writing          articles on GeeksforGeeks checkout my other          article by going to my profile section.""")  doc = nlp(text)  for token in doc:  print(token, token.lemma_)
Output:
My -PRON-
name name
is be
Shaurya Shaurya
Uppal Uppal
. .
I -PRON-
enjoy enjoy
writing write
articles article
on on
GeeksforGeeks GeeksforGeeks
checkout checkout
my -PRON-
other other
article article
by by
going go
to to
my -PRON-
profile profile
section section
. .

Natural-language-processing
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Iterate over a list in Python
Python Classes and Objects
Introduction To PYTHON