code-rag-bench/online-tutorials huggingface dataset:
Search in a SortedList object in C#

To search in a SortedList object, the code is as follows −
 Live Demo
using System;
using System.Collections;
public class Demo {
   public static void Main() {
      SortedList list = new SortedList();
      list.Add("1", "One");
      list.Add("2", "Two");
      list.Add("3", "Three");
      list.Add("4", "Four");
      list.Add("5", "Five");
      list.Add("6", "Six");
      list.Add("7", "Seven");
      list.Add("8", "Eight");
      Console.WriteLine("Key and Value of SortedList....");
      foreach(DictionaryEntry k in list )
      Console.WriteLine("Key: {0}, Value: {1}", k.Key , k.Value );
      Console.WriteLine("Is the SortedList having the value? "+list.ContainsValue("Three"));
      Console.WriteLine("The SortedList object has a fixed size? = "+list.IsFixedSize);
      Console.WriteLine("Does the SortedList object contains key 10? = "+list.ContainsKey("10"));
   }
}
This will produce the following output −
Key and Value of SortedList....
Key: 1, Value: One
Key: 2, Value: Two
Key: 3, Value: Three
Key: 4, Value: Four
Key: 5, Value: Five
Key: 6, Value: Six
Key: 7, Value: Seven
Key: 8, Value: Eight
Is the SortedList having the value? True
The SortedList object has a fixed size? = False
Does the SortedList object contains key 10? = False
Let us see another example −
 Live Demo
using System;
using System.Collections;
public class Demo {
   public static void Main(String[] args) {
      SortedList sortedList = new SortedList();
      sortedList.Add("A", "1");
      sortedList.Add("B", "2");
      sortedList.Add("C", "3");
      sortedList.Add("D", "4");
      sortedList.Add("E", "5");
      sortedList.Add("F", "6");
      sortedList.Add("G", "7");
      sortedList.Add("H", "8");
      sortedList.Add("I", "9");
      sortedList.Add("J", "10");
      Console.WriteLine("SortedList elements...");
      foreach(DictionaryEntry d in sortedList) {
         Console.WriteLine("Key = "+d.Key + ", Value = " + d.Value);
      }
      Console.WriteLine("Count of SortedList key-value pairs = "+sortedList.Count);
      Console.WriteLine("\nEnumerator to iterate through the SortedList...");
      IDictionaryEnumerator demoEnum = sortedList.GetEnumerator();
      while (demoEnum.MoveNext())
      Console.WriteLine("Key = " + demoEnum.Key + ", Value = "+ demoEnum.Value);
      Console.WriteLine("Does the SortedList object contains key M? = "+sortedList.ContainsKey("M"));
      Console.WriteLine("Does the SortedList object contains key H? = "+sortedList.ContainsKey("H"));
   }
}
This will produce the following output −
SortedList elements...
Key = A, Value = 1
Key = B, Value = 2
Key = C, Value = 3
Key = D, Value = 4
Key = E, Value = 5
Key = F, Value = 6
Key = G, Value = 7
Key = H, Value = 8
Key = I, Value = 9
Key = J, Value = 10
Count of SortedList key-value pairs = 10
Enumerator to iterate through the SortedList...
Key = A, Value = 1
Key = B, Value = 2
Key = C, Value = 3
Key = D, Value = 4
Key = E, Value = 5
Key = F, Value = 6
Key = G, Value = 7
Key = H, Value = 8
Key = I, Value = 9
Key = J, Value = 10
Does the SortedList object contains key M? = False
Does the SortedList object contains key H? = True
How to pass the individual members as arguments to function using structure elements?

There are three ways by which the values of structure can be transferred from one function to another. They are as follows −
Passing individual members as arguments to function.
Passing entire structure as an argument to function.
Passing the address of structure as an argument to function.
Now let’s see how to pass an individual member of structure elements as arguments to function.
Each member is passed as an argument in the function call.
Each member is passed as an argument in the function call.
They are collected independently in ordinary variables in function header.
They are collected independently in ordinary variables in function header.
Given below is a C program to demonstrate passing individual arguments of structure to a function −
 Live Demo
#include<stdio.h>
struct date{
   int day;
   int mon;
   int yr;
};
main ( ){
   struct date d= {02,01,2010}; // struct date d;
   display(d.day, d.mon, d.yr);// passing individual mem as argument to function
   getch ( );
}
display(int a, int b, int c){
   printf("day = %d\n", a);
   printf("month = %d\n",b);
   printf("year = %d\n",c);
}
When the above program is executed, it produces the following result −
day = 2
month = 1
year = 2010
Consider another example, wherein, a C program to demonstrate passing individual arguments of structure to a function is explained below −
 Live Demo
#include <stdio.h>
#include <string.h>
struct student{
   int id;
   char name[20];
   float percentage;
   char temp;
};
struct student record; // Global declaration of structure
int main(){
   record.id=1;
   strcpy(record.name, "Raju");
   record.percentage = 86.5;
   structure_demo(record.id,record.name,record.percentage);
   return 0;
}
void structure_demo(int id,char name[],float percentage){
   printf(" Id is: %d \n", id);
   printf(" Name is: %s \n", name);
   printf(" Percentage is: %.2f \n",percentage);
}
When the above program is executed, it produces the following result −
Id is: 1
Name is: Raju
Percentage is: 86.5
C++ Program to find the median of two sorted arrays using binary search approach

We shall develop a C++ program to find the median of two sorted arrays using Binary Search approach.
Begin
   Function median() with both the arrays and the start and end indexes of each array, which have two arrays and their respective elements as argument.
      A) first calculate the array length as e1 - s1, here e1 nd s1 are the end and start indices.
      B) If the length is 2 or 1, calculate the median of arrays according to even or odd length, print the result.
      C) Check if both the individual medians are equal, if yes, then print the result.
      D) If above two conditions are true then check if m>m2 then the combined median will either be in first half of the first array or in the second half of the second array.
      E) If m1<m2 then the combined median will either be in second half of the first array or in the first half of the second array.
      F) Call median() recursively, with updated start and end indexes.
End
#include<iostream>
using namespace std;
void median(float a1[], int s1, int e1, float a2[], int s2, int e2) {
   float m1, m2;
   if((e1-s1+1)%2 == 0) {
      if(e1-s1 == 1) {
         m1 = ((a1[s1]<a2[s2]?a1[s1]:a2[s2])+(a1[e1]>a2[e2]?a1[e1]:a2[e2]))/2;
         cout<<m1;
         return;
      }
      m1 = (a1[(e1+s1)/2]+a1[(e1+s1)/2+1])/2;
      m2 = (a2[(e2+s2)/2]+a2[(e2+s2)/2+1])/2;
      if(m1 == m2 ) {
         cout<<m1;
         return;
      }
      else {
         if(m1 > m2)
            median(a1, s1, (e1+s1)/2+1, a2, (e2+s2)/2, e2);
         else
            median(a1, (e1+s1)/2, e1, a2, s2, (e2+s2)/2+1);
      }
   } else {
      if(e1-s1 == 0) {
         m1 = (a1[s1]+a2[s2])/2;
         cout<<m1;
         return;
      }
      m1 = a1[(e1+s1)/2];
      m2 = a2[(e2+s2)/2];
      if(m1 == m2 ) {
         cout<<m1;
         return;
      }
      else {
         if(m1 > m2)
            median(a1, s1, (e1+s1)/2, a2, (e2+s2)/2, e2);
         else
            median(a1, (e1+s1)/2, e1, a2, s2, (e2+s2)/2);
      }
   }
   return;
}
int main() {
   int n1,n2,i;
   cout<<"\nEnter the number of elements for 1st array: ";
   cin>>n1;
   float a1[n1];
   for(i = 0; i < n1; i++) {
      cout<<"Enter element for 1st array"<<i+1<<": ";
      cin>>a1[i];
   }
   cout<<"\nEnter the number of elements for 2nd array: ";
   cin>>n2;
   float a2[n2];
   for(i = 0; i < n2; i++) {
      cout<<"Enter element for 2nd array "<<i+1<<": ";
      cin>>a1[i];
   }
   cout << "Median is ";
   median(a1, 0, n1-1, a2, 0, n2-1) ;
   return 0;
}
Enter the number of elements for 1st array: 5
Enter element for 1st array1: 6
Enter element for 1st array2: 7
Enter element for 1st array3: 9
Enter element for 1st array4: 10
Enter element for 1st array5: 11
Enter the number of elements for 2nd array: 5
Enter element for 2nd array 1: 60
Enter element for 2nd array 2: 70
Enter element for 2nd array 3: 90
Enter element for 2nd array 4: 100
Enter element for 2nd array 5: 110
Median is 35
How to loop through all the iframes elements of a page using jQuery?

To loop through all the iframes element of a page, use the jQuery each() method. You can try to run the following code to learn how to loop through all iframes. We have created three iframes below −
Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $("button").click(function(){
    $("iframe").each(function(){
      alert($(this).text())  
    });
  });
});
</script>
</head>
<body>
  <iframe src="https://www.qries.com">Qries Q/A</iframe>
  <iframe src="https://tutorialspoint.com">Tutorialspoint Free Learning</iframe>
  <iframe src="https://sendfiles.net">Send Files</iframe><br>
  <button>Loop through iFrames</button>
</body>
</html>
Implementing String Comparison in MongoDB?

To implement string comparison in MongoDB, use $strcasecmp. It performs case-insensitive comparison of two strings. It returns −
1 if first string is “greater than” the second string.
1 if first string is “greater than” the second string.
0 if the two strings are equal.
0 if the two strings are equal.
-1 if the first string is “less than” the second string.
-1 if the first string is “less than” the second string.
Let us create a collection with documents −
> db.demo490.insertOne({"Name1":"John","Name2":"john"});{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e8496ccb0f3fa88e22790bb")
}
> db.demo490.insertOne({"Name1":"David","Name2":"Bob"});{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e8496d9b0f3fa88e22790bc")
}
> db.demo490.insertOne({"Name1":"Carol","Name2":"Carol"});{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e8496e5b0f3fa88e22790bd")
}
Display all documents from a collection with the help of find() method −
> db.demo490.find();
This will produce the following output −
{ "_id" : ObjectId("5e8496ccb0f3fa88e22790bb"), "Name1" : "John", "Name2" : "john" }
{ "_id" : ObjectId("5e8496d9b0f3fa88e22790bc"), "Name1" : "David", "Name2" : "Bob" }
{ "_id" : ObjectId("5e8496e5b0f3fa88e22790bd"), "Name1" : "Carol", "Name2" : "Carol" }
Following is the query to implement string comparison in MongoDB −
> db.demo490.aggregate(
... [
...    {
...       $project:
...       {
...          Name1: 1,
...          Name2: 1,
...          Result: { $strcasecmp: [ "$Name1", "$Name2" ] }
...       }
...    }
... ]
... )
This will result the following output −
{ "_id" : ObjectId("5e8496ccb0f3fa88e22790bb"), "Name1" : "John", "Name2" : "john", "Result"
: 0 }
{ "_id" : ObjectId("5e8496d9b0f3fa88e22790bc"), "Name1" : "David", "Name2" : "Bob",
"Result" : 1 }
{ "_id" : ObjectId("5e8496e5b0f3fa88e22790bd"), "Name1" : "Carol", "Name2" : "Carol",
"Result" : 0 }
Python OpenCV – Getting and Setting Pixels

03 Nov, 2021
In this article, we will discuss Getting and Setting Pixels through OpenCV in Python. 
Image is made up of pixels. A pixel will be denoted as an array. The 3 integers represent the intensity of red, green, blue in the same order. Eg. [0,0,0] in RGB mode represent black color. There are other modes as well-
HSV
Grayscale
CMY
Image can be read using imread() function which returns the matrix of pixels (default is RGB mode).
Image Used:
Syntax:
For Image shape: image.shape
For getting a pixel: image[row][col]
For setting a pixel: image[row][col] = [r,g,b]
Example 1: Python code to display image details
Python3
# import cv2 moduleimport cv2 # resd the imageimg = cv2.imread('image.png') # shape prints the tuple (height,weight,channels)print(img.shape) # img will be a numpy array of the above shapeprint(img)
Output:
(225, 225, 3)
[[[ 87 157  14]
 [ 87 157  14]
 [ 87 157  14]
 ...
 [ 87 157  14]
 [ 87 157  14]
 [ 87 157  14]]

[[ 87 157  14]
 [ 87 157  14]
 [ 87 157  14]
 ...
 [ 87 157  14]
 [ 87 157  14]
 [ 87 157  14]]
 
...

[[ 72 133   9]
 [ 72 133   9]
 [ 72 133   9]
 ...
 [ 87 157  14]
 [ 87 157  14]
 [ 87 157  14]]

[[ 72 133   9]
 [ 72 133   9]
 [ 72 133   9]
 ...
 [ 87 157  14]
 [ 87 157  14]
 [ 87 157  14]]]
Here 225*225 pixels are there and every pixel is an array of 3 integers (Red, Green, Blue). 
Example 2: In this example, The single pixel can be extracted using indexing.
Python3
import cv2 # read the imageimg = cv2.imread('image.png') # this is pixel of 0th row and 0th columnprint(img[0][0])
Output:
[ 87 157  14]
Example 3: Python code to make the black cross on the image.
For that we will extract all (i,j) such that i==j or i+j == image width and for all pixels with index (i,j), the value of the pixel will set to [0,0,0].
Python3
# import the cv2 packageimport cv2 # read the imageimg = cv2.imread('image.png')for i, row in enumerate(img):   # get the pixel values by iterating    for j, pixel in enumerate(img):        if(i == j or i+j == img.shape[0]):                 # update the pixel value to black            img[i][j] = [0, 0, 0] # display imagecv2.imshow("output", img)cv2.imwrite("output.png", img)
Output:
Example 4: Get grayscale then the pixel will just be a number representing the intensity of white.
Python3
import cv2img = cv2.imread('image.png', 0)  # shape prints the tuple (height,weight,channels)print("image shape = ", img.shape) # img will be a numpy array of the above shapeprint("image array = ", img) print("pixel at index (5,5): ", img[5][5])
Grayscale Image:
Output:
image shape =  (225, 225)
image array =  
[[106 106 106 ... 106 106 106]
 [106 106 106 ... 106 106 106]
 [106 106 106 ... 106 106 106]
 ...
 [ 88  88  88 ... 106 106 106]
 [ 88  88  88 ... 106 106 106]
 [ 88  88  88 ... 106 106 106]]
pixel at index (5,5):  106
surinderdawra388
Picked
Python-OpenCV
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Flutter – UI Orientation

16 Oct, 2020
All applications should be able to adjust their User Interface (UI) based on the orientation of the phone. By orientation, we implicate the portrait and landscape mode in smartphones rather the physical orientation. In, Flutter it is done so by using the OrientationBuilder, which determines the app’s current orientation. We will look into the same by building a simple application and change its orientation and display the UI changes.
Follow the below steps to build the application that changes UI based on the orientation of the phone:
Create a GridView of 3 columns
Use the OrientationBuilder to alter the number of columns.
Let’s discuss them in detail.
To create a GridView of 3 columns, use the code as shown below:
Dart
GridView.count(  crossAxisCount: 3,);
As discussed earlier, the orientationBuilder determines the orientation of the current application. We will design the Orientationbuilder in such a way that it displays 3 columns in portrait mode and 4 columns in landscape mode. to do so follow the below code:
Dart
OrientationBuilder(  builder: (context, orientation) {    return GridView.count(      crossAxisCount: orientation == Orientation.portrait ? 3 : 4,    );  },);
The complete code would look like below:
Dart
import 'package:flutter/material.dart';  void main() {  runApp(MyApp());}  class MyApp extends StatelessWidget {  @override  Widget build(BuildContext context) {    final appTitle = 'GeeksForGeeks';      return MaterialApp(      title: appTitle,      home: OrientationList(        title: appTitle,      ),    );  }}  class OrientationList extends StatelessWidget {  final String title;    OrientationList({Key key, this.title}) : super(key: key);    @override  Widget build(BuildContext context) {    return Scaffold(      appBar: AppBar(          title: Text(title),          backgroundColor: Colors.green),      body: OrientationBuilder(        builder: (context, orientation) {          return GridView.count(                         //grid with 3 and 4 columns for portrait and landscape mode respectively            crossAxisCount: orientation == Orientation.portrait ? 3 : 4,                          // random item generator            children: List.generate(100, (index) {              return Center(                child: Text(                  'A $index',                  style: Theme.of(context).textTheme.headline4,                ),              );            }),          );        },      ),    );  }}
Output:
android
Flutter
Flutter-widgets
Dart
Flutter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Understanding Chebyshev’s inequality with an example

08 Apr, 2021
In this article, we will discuss the overview of Chebyshev’s inequality algorithm, and will cover the Understanding Chebyshev’s inequality with an example. Pre-requisite is to go to given below link to understand Markov’s theorem to get more deep mathematical insights behind the Chebyshev’s inequality, and it’s proof. Let’s discuss it one by one.
Pre-requisite – Understanding Markov’s theorem with example
Chebyshev’s inequality : It is based on the concept of variance. It says that given a random variable R, then ∀ x > 0, The probability that the random variable R deviates from its expected value in either side by at least x is given as follows.
          //equation -1
Where it represents the following values as follows.
Var(R) - It denotes variance of Random Variable R.
Ex(R)  - It denotes the Expected value of Random Variable R.
Proof : We know Markov’s inequality in Probability as follows.
       //equation -2
Put : R – Ex(R) in place of R in this and square this and then apply Markov’s inequality, we get the following expression as follows.
    //equation -3
         //equation -4
We also know that the following expression and with the help of this we can evaluate.
Now, put this in the fourth equation and replace LHS of the fourth equation with LHS of the third equation, we get Chebychev’s inequality as follows.
Result :
Corollary of Chebyshev’s inequality :If we replace X with c*Var(R), where c > 0 ,then we get the below equation which can be proven very easily as follows.
Example of Chebyshev’s inequality :Let’s understand the concept with the help of an example for better understanding as follows.
Example-1 :Let us say that Random Variable R = IQ of a random person. And average IQ of a person is 100, i.e, Ex(R) = 100. And Variance in R is 15. (Assuming R >0). Then what is the probability that if we pick a random person, his/her IQ is at least 250 ?
Solution –To solve this, we will use corollary of the Chebyshev’s inequality as follows.
P(R>=250) = P( R-100 >=150 ),
Comparing with the Corollary, we can say that the following result as follows.
since 150 = 10* Variance
so, c = 10.
Therefore, answer is upper bounded by 1/100 which is ≤1 %.
Example-2 :If we solve the same problem using Markov’s theorem without using the variance, we get the upper bound as follows.
P ( R >= 250 ) < = Ex(R) / 250
= 100/250 = 2/5 = 40%.
So, the Same problem is upper bounded by 40 % by Markov’s inequality and by 1% by Chebyshev’s inequality. Thus, we can say that Chebyshev’s inequality gives a better bound on probability compared to Markov’s if we know the variance of random variable R.
Engineering Mathematics
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Propositional Logic and Predicate Logic
Activation Functions
Logic Notations in LaTeX
Mathematics | Introduction of Set theory
Introduction of Statistics and its Types
Modular Arithmetic
Difference between Spline, B-Spline and Bezier Curves
Mathematics | Set Operations (Set theory)
Proof that vertex cover is NP complete
Brackets in Latex
Pyperclip module in Python

27 Feb, 2020
Pyperclip is a cross-platform Python module for copy and paste clipboard functions. It works with both Python 2 and 3. This module was created to enable cross-platform copy-pasting in Python which was earlier absent. The pyperclip module has copy() and paste() functions that can send text to and receive text from your computer’s clipboard. Sending the output of your program to the clipboard will make it easy to paste it on an email, word processor, or some other software.
Installing pyperclip:
pip install pyperclip

To copy text to the clipboard, pass a string to pyperclip.copy(). To paste the text from the clipboard, call pyperclip.paste() and the text will be returned as a string value.
Code 1:
# importing the libraryimport pyperclip as pc  text1 = "GeeksforGeeks"  # copying text to clipboardpc.copy(text1)  # pasting the text from clipboardtext2 = pc.paste()  print(text2)
Output :
GeeksforGeeks

Code 2:
# importing the libraryimport pyperclip as pc  number = 100  # copying text to clipboardpc.copy(number)  # pasting the text from clipboardtext = pc.paste()  print(text)print(type(text))
Output :
100

Note : Copy function will convert every data type to string.
python-modules
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
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
How to display errors in PHP file?

A PHP application produces many levels of errors during the runtime of the script . So in this article, we will learn how to display all the errors and warning messages.
The quickest way to display all php errors and warnings is to add these lines to your PHP code file:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
The ini_set function will try to override the configuration found in your php.ini file. If in the php.ini file display_error is turned off it will turn that on in the code. It also set display_startup_errors to true to show the error message. error_reporting() is a native PHP function that is used to display the errors. By setting it true it displays the error that occurs in the code.
But there is an again question arises what is E_ALL? The answer is simple PHP code produces different levels of errors. So let's learn what are those types of errors occurs in a PHP code.
E_ERROR :fatal runtime error execution of script has been halted
E_WARNING :nonfatal runtime error execution of script has been halted
E_PARSE :compile time error it is generated by the parser
E_NOTICE :The script found something that might be an error
E_CORE_ERROR :Fatal errors that occurred during the initial startup of script
E_CORE_WARNING :Nonfatal errors that occurred during the initial startup of script
E_ALL :All errors and warning
Unfortunately, the above code we have composed won't almost certainly show parse errors, for example, missing semicolons or missing wavy supports. For this situation, the php.ini setup must be altered.display_errors = onThe display_errors order must be set to "on" in the php.ini document. This will show every one of the errors including syntax or parse mistakes that can't be shown by simply calling the ini_set work in the PHP code.So in the above way, we can display errors in our php application.
Unfortunately, the above code we have composed won't almost certainly show parse errors, for example, missing semicolons or missing wavy supports. For this situation, the php.ini setup must be altered.
display_errors = on
The display_errors order must be set to "on" in the php.ini document. This will show every one of the errors including syntax or parse mistakes that can't be shown by simply calling the ini_set work in the PHP code.
How to Install Geopandas on Windows?

22 Sep, 2021
Geopandas is a Python library used to add geographical data to pandas as an object.  In this article, we will look into the process of installing Geopandas on a windows machine.
The only thing that you need for installing Numpy on Windows are:
Python 
PIP or Conda (depending upon user preference)
If you want the installation to be done through conda,  open up the Anaconda Powershell Prompt and use the below command:
conda install geopandas
Type y for yes when prompted.
You will get a similar message once the installation is complete:
Make sure you follow the best practices for installation using conda as:
Use an environment for installation rather than in the base environment using the below command:
conda create -n my-env
conda activate my-env
Note: If your preferred method of installation is conda-forge, use the below command:
conda config --env --add channels conda-forge
To verify if Geopandas has been successfully installed in your system run the below command in Anaconda Powershell Prompt:
conda list geopandas
You’ll get the below message if the installation is complete:
If you want the installation to be done through PIP,  open up the Command Prompt and use the below command:
pip install geopandas
You will get a similar message once the installation is complete:
To verify if the Geopandas  has been successfully installed in your system run the below command in Command Prompt:
python -m pip show geopandas
You’ll get the below message if the installation is complete:
Blogathon-2021
how-to-install
Picked
Blogathon
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
turtle.right() method in Python

16 Jul, 2020
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
The turtle.right() method is used to change the direction of the turtle by the value of the argument that it takes. It gives the moving of the head of the turtle in a direction. 
Syntax:
turtle.right(angle)

The argument it takes is angle { a number (integer or float) }. So, it turns turtle right by angle units. (Units are by default degrees but can be set via the degrees() and radians() functions.) Angle orientation depends on the mode.
Below is the implementation of the above method with some examples :
Example 1:
Python3
# importing packageimport turtle    # move the turtle forward by # 100 unit distance in the# direction of head of turtleturtle.forward(100)  # change the direction of turtle# by 90 degrees to the right.turtle.right(90)  # move the turtle forward by# 100 unit distance in the # direction of head of turtleturtle.forward(100)
Output :
Example 2:
Python3
# importing packageimport turtle    # Loop for patternfor i in range(10):      # move the turtle forward by   # 100+variable unit distance  # in the direction of head of turtle  turtle.forward(100+10*i)      # change the direction of turtle  # by 90 degrees to the right.  turtle.right(90)
Output :
Python-turtle
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Introduction To PYTHON
Python OOPs Concepts
Convert integer to string in Python
Python | os.path.join() method
Python | Merge key value lists

26 Jul, 2019
Sometimes, while working with lists, we can come forward with a problem in which we need to perform the merge function in which we have the key list and need to create dictionary mapping keys with corresponding value in other list. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using zip() + loop + defaultdict()The combination of above method can be used to perform this particular task. In this, we use zip function to match the like elements of lists with each other and loop is then used to assign the keys with value from zipped list to add value to a defaultdict.
# Python3 code to demonstrate working of# Merge key value list# Using zip() + loop + defaultdict()from collections import defaultdict  # initializing liststest_list1 = [0, 0, 0, 1, 1, 1, 2, 2]test_list2 = ['gfg', 'is', 'best', 'Akash', 'Akshat', 'Nikhil', 'apple', 'grapes']  # printing original listsprint("The original list1 is : " + str(test_list1))print("The original list2 is : " + str(test_list2))  # Using zip() + loop + defaultdict()# Merge key value listres = defaultdict(list)for i, j in zip(test_list1, test_list2):   res[i].append(j)  # printing result print("The merged key value dictionary is : " + str(dict(res)))
The original list1 is : [0, 0, 0, 1, 1, 1, 2, 2]The original list2 is : [‘gfg’, ‘is’, ‘best’, ‘Akash’, ‘Akshat’, ‘Nikhil’, ‘apple’, ‘grapes’]The merged key value dictionary is : {0: [‘gfg’, ‘is’, ‘best’], 1: [‘Akash’, ‘Akshat’, ‘Nikhil’], 2: [‘apple’, ‘grapes’]}
 
Method #2 : Using itemgetter() + groupby() + zip()This is yet another way to perform this particular task. In this, we group the keys fetched by itemgetter to the first list with the elements of other list which is linked using the zip function using groupby method.
# Python3 code to demonstrate working of# Merge key value list# Using itemgetter() + groupby() + zip()from itertools import groupbyfrom operator import itemgetter  # initializing liststest_list1 = [0, 0, 0, 1, 1, 1, 2, 2]test_list2 = ['gfg', 'is', 'best', 'Akash', 'Akshat', 'Nikhil', 'apple', 'grapes']  # printing original listsprint("The original list1 is : " + str(test_list1))print("The original list2 is : " + str(test_list2))  # Using itemgetter() + groupby() + zip()# Merge key value listres = {keys: [i for _, i in sub] for keys, sub in groupby(         zip(test_list1, test_list2), key = itemgetter(0))}  # printing result print("The merged key value dictionary is : " + str(dict(res)))
The original list1 is : [0, 0, 0, 1, 1, 1, 2, 2]The original list2 is : [‘gfg’, ‘is’, ‘best’, ‘Akash’, ‘Akshat’, ‘Nikhil’, ‘apple’, ‘grapes’]The merged key value dictionary is : {0: [‘gfg’, ‘is’, ‘best’], 1: [‘Akash’, ‘Akshat’, ‘Nikhil’], 2: [‘apple’, ‘grapes’]}
Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python PIL | Image.tell() - GeeksforGeeks

26 Aug, 2019
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The Image module provides a class with the same name which is used to represent a PIL image. The module also provides a number of factory functions, including functions to load images from files, and to create new images.
Image.tell()Returns the current frame number.
Syntax: Image.tell()
Parameters:image– take an gif image.
Returns: An Image object.
Image Used:
     # importing image object from PILfrom PIL import Image  # creating gif image object img = Image.open(r"C:\Users\System-Pc\Desktop\time.gif") img1 = img.tell() print(img1)
Output:
0

Another Example:Taking another gif image.
Image Used:
     # importing image object from PILfrom PIL import Image  # creating gif image object img = Image.open(r"C:\Users\System-Pc\Desktop\skyhigh.gif") img1 = img.tell() print(img1)
Output:
0

Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
How to push an array into the object in JavaScript ? - GeeksforGeeks

26 Jul, 2021
In order to push an array into the object in JavaScript, we need to utilize the push() function. With the help of Array push function this task is so much easy to achieve. 
push() function: The array push() function adds one or more values to the end of the array and returns the new length. This method changes the length of the array. But here we will use this function to push the whole array into an object.
Syntax:  
arr.push(element1[, ...[, elementN]])
An array can be inserted into the object with push() function, below examples illustrate the above approach:
Example 1:  
Javascript
<script>// JavaScript program to add array into// an object using push() function  // Creating a JS object to add array into itvar Obj = {                 arrayOne: [],    arrayTwo: []};  // Array to be insertedvar arraynew = ['Geeks', 'for', 'Geeks'];  // Push an array to objectObj.arrayOne.push(arraynew);       alert(Obj.arrayOne);      </script>                     
Output: 
Example 2: 
Javascript
<script>// JavaScript program to add array into// an object using push() function  // Creating a JS object to add array intovar Obj = {                 arrayOne: ['Geeks', 'for', 'Geeks'],    arrayTwo: []};  // Array to be insertedvar arraynew = ['Hello', 'World', '!!!'];   // Pushing of array into arrayTwoObj['arrayTwo'].push(arraynew);       alert(Obj.arrayTwo);      </script>                    
Output:  
Supported Browsers: The supported browser by the Array Push() Function are listed below: 
Google Chrome 1.0
Internet Explorer 5.5
Mozilla Firefox 1.0
Safari
Opera
 
JavaScript is best known for web page development but it is also used in a variety of non-browser environments. You can learn JavaScript from the ground up by following this JavaScript Tutorial and JavaScript Examples.
arorakashish0911
javascript-object
Picked
JavaScript
Web Technologies
Web technologies Questions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Python - Concatenate Random characters in String List - GeeksforGeeks

19 Jul, 2021
Given a String list, perform concatenation of random characters.
Input : test_list = [“Gfg”, “is”, “Best”, “for”, “Geeks”] Output : “GiBfe” Explanation : Random elements selected, e.g G from Gfg, etc.Input : test_list = [“Gfg”, “is”, “Best”] Output : “fst” Explanation : Random elements selected, e.g t from Best, etc.  
Method #1 : Using loop + random.choice()
In this, we extract random character using choice() and perform task of iteration using loop. The character concatenation is done using + operator.
Python3
# Python3 code to demonstrate working of# Concatenate Random characters in String List# Using loop + choice()import random # initializing listtest_list = ["Gfg", "is", "Best", "for", "Geeks"] # printing original listprint("The original list is : " + str(test_list)) res = ''for ele in test_list:         # Concatenating random elements    res += random.choice(ele)         # printing resultsprint("Concatenated String : " + str(res))
The original list is : ['Gfg', 'is', 'Best', 'for', 'Geeks']
Concatenated String : Gsere
Method #2 : Using list comprehension + choice() + join()
In this, we perform task of getting random using choice() and concatenation is done using join().
Python3
# Python3 code to demonstrate working of# Concatenate Random characters in String List# Using list comprehension + choice() + join()import random # initializing listtest_list = ["Gfg", "is", "Best", "for", "Geeks"] # printing original listprint("The original list is : " + str(test_list)) # characters joining using join()res = ''.join([random.choice(ele) for ele in test_list])         # printing resultsprint("Concatenated String : " + str(res))
The original list is : ['Gfg', 'is', 'Best', 'for', 'Geeks']
Concatenated String : Gitrk
gabaa406
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
Logger removeHandler() method in Java with Examples - GeeksforGeeks

24 Jun, 2021
removeHandler() method of a Logger class is used to remove a log Handler from Logger. A Handler is a component of JVM that takes care of actual logging to the defined output writers like a file, console out etc. It returns silently if the given Handler is not found or is null.Syntax:  
public void removeHandler(Handler handler)
                   throws SecurityException
Parameters: This method accepts one parameter handler which represents a logging Handler.Return value: This method returns nothing.Exception: This method throws SecurityException if a security manager exists, this logger is not anonymous, and the caller does not have LoggingPermission(“control”). .Below programs illustrate the removeHandler() method: Program 1:  
Java
// Java program to demonstrate// Logger.removeHandler() method import java.util.logging.*;import java.io.IOException; public class GFG {     private static Logger logger        = Logger.getLogger(            GFG.class.getName());     public static void main(String args[])        throws SecurityException, IOException    {         FileHandler filehandler            = new FileHandler("logs.txt");         // Add file handler as        // handler of logs        logger.addHandler(filehandler);         // Log message        logger.info("This is Info Message ");         // Remove file handler.        logger.removeHandler(filehandler);         logger.info("This message will "                    + "not print on filehandler");    }}
Output: The output printed on logs.txt file is shown below-  
Program 2:  
Java
// Java program to demonstrate// Logger.addHandler() method import java.util.logging.*;import java.io.IOException; public class GFG {     private static Logger logger        = Logger.getLogger(            GFG.class.getName());     public static void main(String args[])        throws SecurityException, IOException    {         // Create a ConsoleHandler object        ConsoleHandler handler            = new ConsoleHandler();         // Add console handler as        // handler of logs        logger.addHandler(handler);         // Log message        logger.info("This is Info Message ");         // Remove consolehandler        logger.removeHandler(handler);         // After removing logs print message        logger.info("Handler removed");    }}
Output: output printed on console output is shown below-  
Reference: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Logger.html#removeHandler(java.util.logging.Handler) 
gabaa406
Java - util package
Java-Functions
Java-Logger
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Internal Working of HashMap in Java
Comparator Interface in Java with Examples
Strings in Java
Overriding of Thread class start() method - GeeksforGeeks

30 Nov, 2018
Whenever we override start() method then our start() method will be executed just like a normal method call and new thread wont be created. We can override start/run method of Thread class because it is not final. But it is not recommended to override start() method, otherwise it ruins multi-threading concept.
// Java program illustrate the concept of// overriding of start() methodclass Bishal extends Thread {public void start()    {        System.out.println("Start Method");    }public void run()    {        System.out.println("Run Method");    }} class Geeks {public static void main(String[] args)    {        Bishal thread = new Bishal();        thread.start();        System.out.println("Main Method");    }}
Output:
Start Method
Main Method

NOTE : In the above program, when we are calling start() method by an object of Bishal class, then any thread won’t be created and all the functions are done by main thread only.
Runtime stack provided by JVM for the above program:
When we call start() method on thread, it internally calls run() method with newly created thread. So, if we override start() method, run() method will not be called until we write code for calling run() method.Another Example:
class GThread extends Thread{    public void run()    {        System.out.println("GThread: run()");    }       public void start()    {        System.out.println("GThread: start()");    }}   class GRunnable implements Runnable{    public void run()    {        System.out.println("GRunnable: run()");    }       public void start()    {        System.out.println("GRunnable: start()");    }}   public class MyTest {    public static void main(String args[])    {        GThread gt  =  new GThread();        GRunnable gr = new GRunnable();        Thread thread  =  new Thread(gr);        gt.start();        thread.start();    }}
Output:
GThread: start()
GRunnable: run()

When GThread.start() is called, output is : “GThread:start()”. When we call, thread.start(), the new thread will call the run() method of runnable, and we will get the “GRunnable:run()” message.
This article is contributed by Bishal Kumar Dubey. 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.
Java-Multithreading
java-overriding
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HashMap in Java with Examples
Stream In Java
Interfaces in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
Set in Java
Collections in Java
Can we declare a constructor as private in Java?

Yes, we can declare a constructor as private. If we declare a constructor as private we are not able to create an object of a class. We can use this private constructor in the Singleton Design Pattern.
A private constructor does not allow a class to be subclassed.
A private constructor does not allow to create an object outside the class.
If all the constant methods are there in our class we can use a private constructor.
If all the methods are static then we can use a private constructor.
If we try to extend a class which is having private constructor compile time error will occur.
Live Demo
class SingletonObject {
   private SingletonObject() {
      System.out.println("In a private constructor");
   }
   public static SingletonObject getObject() {
      // we can call this constructor
      if (ref == null)
         ref = new SingletonObject();
      return ref;
   }
   private static SingletonObject ref;
}
public class PrivateConstructorDemo {
   public static void main(String args[]) {
      SingletonObject sObj = SingletonObject.getObject();
   }
}
In a private constructor
How Is Infinity converted to Number in JavaScript?

Use the Number() method in JavaScript to convert to Number. You can try to run the following code to learn how to convert Infinity to Number in JavaScript.
Live Demo
<!DOCTYPE html>
<html>
   <body>
      <p>Convert Infinity to Number</p>
      <script>
         var myVal = Infinity;
         document.write("Number : " + Number(myVal));
      </script>
   </body>
</html>
How to save an R data frame as txt file?

If we want to use a data frame created in R in the future then it is better to save that data frame as txt file because it is obvious that data creation takes time. This can be done by using write.table function. For example, if we have a data frame df then we can save it as txt file by using the code write.table(df,"df.txt",sep="\t",row.names=FALSE)
Consider the below data frame −
 Live Demo
set.seed(111)
x1<-LETTERS[1:20]
x2<-sample(0:5,20,replace=TRUE)
x3<-rnorm(20,1,0.40)
x4<-rpois(20,3)
df<-data.frame(x1,x2,x3,x4)
df
   x1 x2 x3 x4
1 A 5 1.1576216 1
2 B 2 1.3190114 2
3 C 3 0.3733339 0
4 D 2 0.9656596 2
5 E 0 0.8563442 5
6 F 2 0.5225564 4
7 G 4 1.1456747 3
8 H 2 1.1446650 1
9 I 3 1.1387857 3
10 J 1 1.0758946 3
11 K 0 0.9361693 2
12 L 4 1.1306197 7
13 M 4 1.2393017 1
14 N 1 0.2633863 4
15 O 3 2.0872222 1
16 P 5 1.0764978 5
17 Q 1 0.4794816 1
18 R 0 -0.2452869 2
19 S 2 0.6234570 1
20 T 0 1.5601035 2
Saving the above data frame as txt file by naming the txt file as newdf:
write.table(df,"newdf.txt",sep="\t",row.names=FALSE)
Searching Algorithms - GeeksQuiz

10 Jun, 2019
The function is iterative implementation of Binary Search.  

k keeps track of current middle element.

i and j keep track of left and right corners
of current subarray
Total comparison 
= n(n+1)/2

For average comparison 
= (n(n+1)/2) / n 
= (n+1)/2 
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Best Time to Buy and Sell Stock
Must Do Coding Questions for Product Based Companies
C Program For Deleting A Node In A Linked List
Axios in React: A Guide for Beginners
Tailwind CSS vs Bootstrap
BigInt (BIG INTEGERS) in C++ with Example
Different Ways to Run Applet in Java
Python input() Function
What is Coaxial Cable ?
How to Install Flutter on Visual Studio Code?
Explain intersection operation in relational algebra (DBMS)?

Query is a question or requesting information. Query language is a language which is used to retrieve information from a database.
Query language is divided into two types −
Procedural language
Procedural language
Non-procedural language
Non-procedural language
Information is retrieved from the database by specifying the sequence of operations to be performed.
For Example − Relational algebra.
Structure Query language (SQL) is based on relational algebra.
Relational algebra consists of a set of operations that take one or two relations as an input and produces a new relation as output.
The different types of relational algebra operations are as follows −
Select operation
Select operation
Project operation
Project operation
Rename operation
Rename operation
Union operation
Union operation
Intersection operation
Intersection operation
Difference operation
Difference operation
Cartesian product operation
Cartesian product operation
Join operation
Join operation
Division operation
Division operation
Union, intersection, difference, cartesian, join, division comes under binary operation (operate on two tables).
It displays the common values in R1 & R2. It is denoted by ∩.
∏regno(R1) ∩ ∏regno(R2)
Consider two sets,
A={1,2,4,6} and B={1,2,7}
Intersection of A and B
A ∩ B ={1,2}
Elements that are present in both sets A and B are present in the set obtained by intersection of A and B.
In relational algebra if R1 and R2 are two instances of relation then,
R1 ∩ R2 ={ x | x€ R1 and x € R2}
That is, the intersection of R1 and R2 only those tuples will be present that are in both R1 and R2
Find all the customers whose account is in the bank and have taken out a loan.
The expression is as follows −
∏Name(Depositor) ∩ ∏Name(Borrower)
So, the intersection of depositor and borrower is as follows −