code-rag-bench/online-tutorials huggingface dataset:
Concatenation in LINQ

Performs concatenation of two sequences and is quite similar to the Union operator in terms of its operation except of the fact that this does not remove duplicates.
using System;
using System.Collections.Generic;
using System.Linq;

namespace Operators {
   class Concat {
      static void Main(string[] args) {
      
         Pet[] cats = GetCats();
         Pet[] dogs = GetDogs();

         IEnumerable<string> query = cats.Select(cat ⇒ cat.Name).Concat(dogs.Select(dog => dog.Name));

         foreach (var e in query) {
            Console.WriteLine("Name = {0} ", e);
         }

         Console.WriteLine("\nPress any key to continue.");
         Console.ReadKey();
      }

      static Pet[] GetCats() {
         Pet[] cats = { new Pet { Name = "Barley", Age = 8 },
                       new Pet { Name = "Boots", Age = 4 },
                       new Pet { Name = "Whiskers", Age = 1 } };
         return cats;
      }

      static Pet[] GetDogs() {
         Pet[] dogs = { new Pet { Name = "Bounder", Age = 3 },
                       new Pet { Name = "Snoopy", Age = 14 },
                       new Pet { Name = "Fido", Age = 9 } };
					   
         return dogs;
      }
   }

   class Pet {
      public string Name { get; set; }
      public int Age { get; set; }
   }
}
Module Module1

   Sub Main()

      Dim cats As List(Of Pet) = GetCats()
      Dim dogs As List(Of Pet) = GetDogs()

      Dim list = cats.Cast(Of Pet)().Concat(dogs.Cast(Of Pet)()).ToList()

      For Each e In list
         Console.WriteLine("Name = {0}", e.Name)
      Next

      Console.WriteLine(vbLf & "Press any key to continue.")
      Console.ReadKey()
	  
   End Sub

   Function GetCats() As List(Of Pet)

      Dim cats As New List(Of Pet)

         cats.Add(New Pet With {.Name = "Barley", .Age = 8})
         cats.Add(New Pet With {.Name = "Boots", .Age = 4})
         cats.Add(New Pet With {.Name = "Whiskers", .Age = 1})

      Return cats
	  
   End Function

   Function GetDogs() As List(Of Pet)

      Dim dogs As New List(Of Pet)

         dogs.Add(New Pet With {.Name = "Bounder", .Age = 3})
         dogs.Add(New Pet With {.Name = "Snoopy", .Age = 14})
         dogs.Add(New Pet With {.Name = "Fido", .Age = 9})

      Return dogs
	  
   End Function

   Class Pet
      Public Property Name As String
      Public Property Age As Integer
   End Class
   
End Module
When the above code in C# or VB is compiled and executed, it produces the following result −
Barley 
Boots 
Whiskers 
Bounder 
Snoopy 
Fido

Press any key to continue.


    23 Lectures 
     1.5 hours 

 Anadi Sharma

    37 Lectures 
     13 hours 

 Trevoir Williams
 Print
 Add Notes
 Bookmark this page
MySQL Tryit Editor v1.0

SELECT DISTINCT Country FROM Customers;
​
        
Edit the SQL Statement, and click "Run SQL" to see the result.
This SQL-Statement is not supported in the WebSQL Database.
The example still works, because it uses a modified version of SQL.
Your browser does not support WebSQL.
Your are now using a light-version of the Try-SQL Editor, with a read-only Database.
If you switch to a browser with WebSQL support, you can try any SQL statement, and play with the Database as much as you like. The Database can also be restored at any time.
Our Try-SQL Editor uses WebSQL to demonstrate SQL.
A Database-object is created in your browser, for testing purposes.
You can try any SQL statement, and play with the Database as much as you like. The Database can be restored at any time, simply by clicking the "Restore Database" button.
WebSQL stores a Database locally, on the user's computer. Each user gets their own Database object.
WebSQL is supported in Chrome, Safari, and Opera.
If you use another browser you will still be able to use our Try SQL Editor, but a different version, using a server-based ASP application, with a read-only Access Database, where users are not allowed to make any changes to the data.
How to implement quick sort in JavaScript?

Quick sort is one of the most important sorting methods in javascript. It takes a pivot value(a random value) from an array. All the other elements in the array are split to two categories.They may be less than the pivot value and greater than the pivot value.
After that each of the categories(less than the pivot and greater than the pivot) are subjected to the same procedure that is a pivot is chosen then each category is divided in to sub-categories(less than the pivot and greater than the pivot).
Eventually, the sub-categories are divided in such a way that they may contain an element or no element if there are no more elements to compare. The rest of the values will be denoted as a pivots at some previous points and did not trickle down to this lowest sub category.
Live Demo
<html>
<body>
<script>
   function quickSort(originalArr) {
      if (originalArr.length <= 1) {
         return originalArr;
         } else {
               var leftArr = [];              
               var rightArr = [];
               var newArr = [];
               var pivot = originalArr.pop();      //  Take a pivot value
               var length = originalArr.length;
               for (var i = 0; i < length; i++) {
                  if (originalArr[i] <= pivot) {    // using pivot value start comparing
                     leftArr.push(originalArr[i]);      
               } else {
                       rightArr.push(originalArr[i]);
             }
           }
         return newArr.concat(quickSort(leftArr), pivot, quickSort(rightArr)); // array will be                                                                            //returned untill sorting occurs
      }
   }
   var myArray = [9, 0, 2, 7, -2, 6, 1 ];
   document.write("Original array: " + myArray);
   var sortedArray = quickSort(myArray);
   document.write("Sorted array: " + sortedArray);
</script>
</body>
</html>
Original array: 9,0,2,7,-2,6,1
Sorted array: -2,0,1,2,6,7,9
Tryit Editor v3.7

Tryit: Using CSS animations
Google Colab - Code Editing Help

The present day developers rely heavily on context-sensitive help to the language and library syntaxes. That is why the IDEs are widely used. The Colab notebook editor provides this facility.
In this chapter, let us see how to ask for context-sensitive help while writing Python code in Colab. Follow the steps that have been given wherever needed.
Step 1 − Open a new notebook and type in the following code in the Code cell −
import torch

Step 2 − Run the code by clicking on the Run icon in the left panel of the Code cell. Add another Code cell and type in the following code −
Tensor = torch.

At this point, suppose you have forgotten what are the various functions available in torch module. You can ask for the context-sensitive help on function names by hitting the TAB key. Note the presence of the DOT after the torch keyword. Without this DOT, you will not see the context help. Your screen would look like as shown in the screenshot here −
Now, select the desired function from the list and proceed with your coding.
Colab gives you the documentation on any function or class as a context-sensitive help.
Type the following code in your code window −
Tensor = torch.cos(

Now, hit TAB and you will see the documentation on cos in the popup window as shown in the screenshot here. Note that you need to type in open parenthesis before hitting TAB.
In the next chapter, we will see Magics in Colab that lets us to do more powerful things than what we did with system aliases.

    20 Lectures 
     2.5 hours 

 Asif Hussain

    7 Lectures 
     1 hours 

 Aditya Kulkarni

    33 Lectures 
     2.5 hours 

 Sasha Miller

    22 Lectures 
     1.5 hours 

 Zach Miller

    16 Lectures 
     1.5 hours 

 Sasha Miller

    23 Lectures 
     2.5 hours 

 Sasha Miller
 Print
 Add Notes
 Bookmark this page
Does C support function overloading? - GeeksforGeeks

25 Aug, 2021
First of all, what is function overloading? Function overloading is a feature of a programming language that allows one to have many functions with same name but with different signatures. This feature is present in most of the Object Oriented Languages such as C++ and Java. But C doesn’t support this feature not because of OOP, but rather because the compiler doesn’t support it (except you can use _Generic). However, one can achieve the similar functionality in C indirectly. One of the approach is as follows.Have a void * type of pointer as an argument to the function. And another argument telling the actual data type of the first argument that is being passed. 
   int foo(void * arg1, int arg2);
Suppose, arg2 can be interpreted as follows. 0 = Struct1 type variable, 1 = Struct2 type variable, etc. Here, Struct1 and Struct2 are user defined struct types.While calling the function foo at different places... 
    foo(arg1, 0);   /*Here, arg1 is pointer to struct type Struct1 variable*/
    foo(arg1, 1);    /*Here, arg1 is pointer to struct type Struct2 variable*/
Since the second argument of the foo keeps track the data type of the first type, inside the function foo, one can get the actual data type of the first argument by typecast accordingly. i.e. inside the foo function 
c
if(arg2 == 0){  struct1PtrVar = (Struct1 *)arg1;}else if(arg2 == 1){  struct2PtrVar = (Struct2 *)arg1;}else{  /*Error Handling*/}
There can be several other ways of implementing function overloading in C. But all of them will have to use pointers – the most powerful feature of C. In fact, it is said that without using the pointers, one can’t use C efficiently & effectively in a real world program!Note, that you can use “varargs” to approach this.
faranaiki
C-Functions
c-puzzle
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
fork() in C
Function Pointer in C
TCP Server-Client implementation in C
Structures in C
Enumeration (or enum) in C
std::string class in C++
Exception Handling in C++
Power Function in C/C++
Data Types in C
Taking String input with space in C (4 Different Methods)
Swift - do...while Loop

Unlike for and while loops, which test the loop condition at the top of the loop, the do...while loop checks its condition at the bottom of the loop.
A do...while loop is similar to a while loop, except that a do...while loop is guaranteed to execute at least once.
The syntax of a do...while loop in Swift is −
do {
   statement(s);
}while( condition );

It should be noted that the conditional expression appears at the end of the loop, so the statement(s) in the loop execute once before the condition is tested. If the condition is true, the control flow jumps back up to do, and the statement(s) in the loop execute again. This process repeats until the given condition becomes false.
The number 0, the strings '0' and "", the empty list(), and undef are all false in a Boolean context and all other values are true. Negation of a true value by ! or not returns a special false value.
import Cocoa
 
var index = 10

do {
   println( "Value of index is \(index)")
   index = index + 1
}while index < 20 
When the above code is executed, it produces the following result −
Value of index is 10
Value of index is 11
Value of index is 12
Value of index is 13
Value of index is 14
Value of index is 15
Value of index is 16
Value of index is 17
Value of index is 18
Value of index is 19


    38 Lectures 
     1 hours 

 Ashish Sharma

    13 Lectures 
     2 hours 

 Three Millennials

    7 Lectures 
     1 hours 

 Three Millennials

    22 Lectures 
     1 hours 

 Frahaan Hussain

    12 Lectures 
     39 mins

 Devasena Rajendran

    40 Lectures 
     2.5 hours 

 Grant Klimaytys
 Print
 Add Notes
 Bookmark this page
Python - Writing to video with OpenCV - GeeksforGeeks

17 Oct, 2021
In this article, we will discuss how to write to a video using OpenCV in Python.
Import the required libraries into the working space.
Read the video on which you have to write.
Syntax:
cap = cv2.VideoCapture("path")
Create a output file using cv2.VideoWriter_fourcc() method
Syntax:
output = cv2.VideoWriter(“path”,cv2.VideoWriter_fourcc(*’MPEG’),30,(1080,1920))
Then edit the frames of the video by adding shapes to it (for the example given here, the same can be applied to any other technique.).
Syntax:
cv2.rectangle(frame, (100,100), (500,500), (0,255,0), 3)
Then write the video.
Syntax:
output.write(frame)
Example: Program to write to video
Video Used: 
Python
import cv2    def main():        # reading the input    cap = cv2.VideoCapture("input.mp4")      output = cv2.VideoWriter(        "output.avi", cv2.VideoWriter_fourcc(*'MPEG'), 30, (1080, 1920))      while(True):        ret, frame = cap.read()        if(ret):                          # adding rectangle on each frame            cv2.rectangle(frame, (100, 100), (500, 500), (0, 255, 0), 3)                          # writing the new frame in output            output.write(frame)            cv2.imshow("output", frame)            if cv2.waitKey(1) & 0xFF == ord('s'):                break      cv2.destroyAllWindows()    output.release()    cap.release()    if __name__ == "__main__":    main()
Output:
Picked
Python-OpenCV
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
Selecting rows in pandas DataFrame based on conditions
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Python | Get unique values from a list
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
Batch Script - CHKDSK

This batch command checks the disk for any problems.
chkdsk

@echo off 
chkdsk
The above command starts checking the current disk for any errors.
 Print
 Add Notes
 Bookmark this page
Insert list as dataframe column in R - GeeksforGeeks

30 Jun, 2021
In this article, we will discuss how to add a list as a column to dataframe in R Programming Language. 
Creating dataframe for demonstration:
R
df<-data.frame(col1 = c('A', 'B', 'C', 'D', 'E'),               col2 = c(1, 2, 3, 4, 5))  df
Output:
Now to add a list as a column, create a list with required values. Then, use the name of the data frame and the new column separated by $ and assign this to the list so created.
Syntax: dataframe$column_name=list
This will assign the list to the column name given and then add it to the dataframe.
R
df <- data.frame(col1 = c('A', 'B', 'C', 'D', 'E'),                 col2 = c(1, 2, 3, 4, 5))  new_col = list(1.0, 5.8, 3.0, 5.6, 8.8)df$col3 <- new_col  df
Output:
Creating columns in such a way allows adding NA values where no data is required too. Just write NA for places where data is not there and the rest of the process is the same as above.
Example:
R
df <- data.frame(col1 = c('A', 'B', 'C', 'D', 'E'),                 col2 = c(1, 2, 3, 4, 5))  new_col=list('geeks','for','geeks', NA, NA)df$col4<-new_col  df
Output:
Picked
R DataFrame-Programs
R-DataFrame
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
Replace Specific Characters in String in R
Convert Matrix to Dataframe in R
<mat-progress-spinner> in Angular Material - GeeksforGeeks

25 Feb, 2021
Angular Material is a UI component library that is developed by the Angular team to build design components for desktop and mobile web applications. In order to install it, we need to have angular installed in our project, once you have it you can enter the below command and can download it.The <mat-progress-spinner> and <mat-spinner> tag is used to indicate the progress of an event or activity. Depending on the type they move in a circle way.
Installation:
ng add @angular/material
Approach:
First, install the angular material using the above-mentioned command.
After completing the installation, Import ‘MatProgressSpinnerModule’ from ‘@angular/material/progress-spinner’ in the app.module.ts file.
To use spinners we need to simply use <mat-spinner> tag.
They are two types of progress bars like determinate and indeterminate.
Indeterminate the spinner will not rotate but in the case of indeterminate, the spinner rotates continuously.
For determinate type spinners, we need to give value in order to display them.
If we want to change the theme then we can change it by using the color property. In angular we have 3 themes, they are primary, accent, and warn.
Once done with the above steps then serve or start the project.
Code Implementation:
app.module.ts
import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatProgressSpinnerModule } from '@angular/material';     import { AppComponent } from './example.component';     @NgModule({   declarations: [AppComponent],   exports: [AppComponent],   imports: [     CommonModule,     FormsModule,     MatProgressSpinnerModule    ], }) export class AppModule {}
app.component.html
<mat-spinner color="warn"></mat-spinner>  <br>  <mat-spinner color="primary"></mat-spinner>  <br><mat-spinner color="accent"></mat-spinner>
Output:
Angular-material
Picked
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular PrimeNG Dropdown Component
Angular PrimeNG Calendar Component
Angular 10 (blur) Event
Angular PrimeNG Messages Component
How to make a Bootstrap Modal Popup in Angular 9/8 ?
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?
matplotlib.pyplot.figure() in Python - GeeksforGeeks

22 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, etc.
The figure() function in pyplot module of matplotlib library is used to create a new figure.
Syntax: matplotlib.pyplot.figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True, FigureClass=, clear=False, **kwargs)
Parameters: This method accept the following parameters that are described below:
num : This parameter is provided, and a figure with this id already exists.
figsize(float, float): These parameter are the width, height in inches.
dpi : This parameter is the resolution of the figure.
facecolor : This parameter is the the background color.
edgecolor : This parameter is the border color.
frameon : This parameter suppress drawing the figure frame.
FigureClass : This parameter use a custom Figure instance.
clear : This parameter if True and the figure already exists, then it is cleared.
Return value: This method returns the following values:
figure : This returns the Figure instance returned will also be passed to new_figure_manager in the backends.
Below examples illustrate the matplotlib.pyplot.figure() function in matplotlib.axes:
Example #1:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport matplotlib.lines as lines    fig = plt.figure()fig.add_artist(lines.Line2D([0, 1, 0.5], [0, 1, 0.3]))fig.add_artist(lines.Line2D([0, 1, 0.5], [1, 0, 0.2]))  plt.title('matplotlib.pyplot.figure() Example\n',                fontsize = 14, fontweight ='bold')  plt.show()
Output:
Example #2:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltfrom mpl_toolkits.axisartist.axislines import Subplot  fig = plt.figure(figsize =(4, 4))  ax = Subplot(fig, 111)fig.add_subplot(ax)  ax.axis["left"].set_visible(False)ax.axis["bottom"].set_visible(False)  plt.title('matplotlib.pyplot.figure() Example\n',                 fontsize = 14, fontweight ='bold')  plt.show()
Output:
Python-matplotlib
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 create a Bibliography with HTML?

The bibliography is a section where a list of books referred is mentioned. With HTML, you can easily create a Bibliography. For that, we will be using a <ol> tag to list the books as well as <cite> to add a title of the work.
The <cite> tag is also used to add work title a song, a painting, a movie, etc. It indicates citation and whatever comes inside the tag represents work title.
Let’s see how to add a bibliography in HTML
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bibliography</title>
   </head>
   <body>
      <h1>Bibliography</h1>
      <ol>
         <li>
            <p>E.Balagurusamy, <cite>Programming with JAVA: A Primer</cite>, 3rd edition, (2007)</p>
         </li>
         <li>
            <p>Reto Meier, <cite>Professional Android 4 Application Development</cite>, 3rd edition, (2012)</p>
         </li>
      </ol>
   </body>
</html>
Python | Pandas Dataframe.plot.bar - GeeksforGeeks

06 Jan, 2019
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas DataFrame.plot.bar() plots the graph vertically in form of rectangular bars.
Syntax : DataFrame.plot.bar(x=None, y=None, **kwds)
Parameters:x : (label or position, optional) Allows plotting of one column versus another. If not specified, the index of the DataFrame is used.y : (label or position, optional) Allows plotting of one column versus another. If not specified, all numerical columns are used.**kwds : Additional keyword arguments
Returns: matplotlib.axes.Axes or np.ndarray of them
Example #1: Using DataFrame.plot.bar() to plot the graph vertically in form of rectangular bars
# importing matplotlibimport matplotlib.pyplot  # importing pandas as pdimport pandas as pd  # importing numpy as npimport numpy as np  # creating a dataframe df = pd.DataFrame(np.random.rand(10, 3), columns =['a', 'b', 'c'])  print(df)
Now we will use a function DataFrame.plot.bar() to plot a graph vertically in form of rectangular bars
# using a function df.plot.bar()df.plot.bar()
Output: Example #2: Using DataFrame.plot.bar() to plot the graph vertically in form of rectangular bars.
# importing matplotlibimport matplotlib.pyplot  # importing pandas as pdimport pandas as pd  # importing numpy as npimport numpy as np  # creating a dataframedf = pd.DataFrame(np.random.rand(10, 10),                  columns =['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'])  df
Now we will use a function DataFrame.plot.bar() to plot a graph vertically in form of rectangular bars
# using a function df.plot.bar()df.plot.bar()
Output :
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
Python
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?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
Python | Get unique values from a list
Python | Check if one dictionary is subset of other - GeeksforGeeks

26 Jul, 2019
Sometimes, while working with Python, we might have a problem in which we need to find, if a particular dictionary is a part of other i.e it is subset of other. A problem that have a huge potential in web development domain, having knowledge of solving can be useful. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using all() + items()This task can be performed using the combination of above two functions, in which we check for all the items of the subdict with the original dict using all() and fetch it’s each pair using items().
# Python3 code to demonstrate working of# Check if one dictionary is subset of other# Using all() + items()  # Initialize dictionariestest_dict1 = {'gfg' : 1, 'is' : 2, 'best' : 3, 'for' : 4, 'CS' : 5}test_dict2 = {'gfg' : 1, 'is' : 2, 'best' : 3}  # printing original dictionariesprint("The original dictionary 1 : " +  str(test_dict1))print("The original dictionary 2 : " +  str(test_dict2))  # Using all() + items()# Check if one dictionary is subset of otherres = all(test_dict1.get(key, None) == val for key, val                                 in test_dict2.items())      # printing result print("Does dict2 lie in dict1 ? : " + str(res))
The original dictionary 1 : {‘CS’: 5, ‘is’: 2, ‘best’: 3, ‘gfg’: 1, ‘for’: 4}The original dictionary 2 : {‘is’: 2, ‘best’: 3, ‘gfg’: 1}Does dict2 lie in dict1 ? : True
 
Method #2 : Using items() + <= operatorAnother alternative to perform the above task can be using the items() along with <= operator. This just checks for less than or all values of all the key value matched.
# Python3 code to demonstrate working of# Check if one dictionary is subset of other# Using items() + <= operator  # Initialize dictionariestest_dict1 = {'gfg' : 1, 'is' : 2, 'best' : 3, 'for' : 4, 'CS' : 5}test_dict2 = {'gfg' : 1, 'is' : 2, 'best' : 3}  # printing original dictionariesprint("The original dictionary 1 : " +  str(test_dict1))print("The original dictionary 2 : " +  str(test_dict2))  # Using items() + <= operator# Check if one dictionary is subset of otherres = test_dict2.items() <= test_dict1.items()      # printing result print("Does dict2 lie in dict1 ? : " + str(res))
The original dictionary 1 : {‘CS’: 5, ‘is’: 2, ‘best’: 3, ‘gfg’: 1, ‘for’: 4}The original dictionary 2 : {‘is’: 2, ‘best’: 3, ‘gfg’: 1}Does dict2 lie in dict1 ? : True
Python dictionary-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?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
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?
C# | Getting the Values in a SortedList object - GeeksforGeeks

01 Feb, 2019
SortedList.Values Property is used to get the values in a SortedList object.
Syntax:
public virtual System.Collections.ICollection Values { get; }
Property Value: An ICollection object containing the values in the SortedList object.
Below programs illustrate the use of above-discussed property:
Example 1:
// C# code to get an ICollection containing// the values in the SortedListusing System;using System.Collections;  class GFG {      // Driver code    public static void Main()    {          // Creating a SortedList        SortedList mylist = new SortedList();          // Adding elements in SortedList        mylist.Add("g", "geeks");        mylist.Add("c", "c++");        mylist.Add("d", "data structures");        mylist.Add("q", "quiz");          // Get a collection of the values        ICollection c = mylist.Values;          // Displaying the contents        foreach(string str in c)            Console.WriteLine(str + mylist[str]);    }}
c++
data structures
geeks
quiz

Example 2:
// C# code to get an ICollection containing// the values in the SortedListusing System;using System.Collections;  class GFG {      // Driver code    public static void Main()    {          // Creating a SortedList        SortedList mylist = new SortedList();          // Adding elements in SortedList        mylist.Add("India", "Country");        mylist.Add("Chandigarh", "City");        mylist.Add("Mars", "Planet");        mylist.Add("China", "Country");          // Get a collection of the values        ICollection c = mylist.Values;          // Displaying the contents        foreach(string str in c)            Console.WriteLine(str + mylist[str]);    }}
City
Country
Country
Planet

Note:
The ICollection object is a read-only view of the values of the SortedList object. Modifications made to the underlying SortedList are immediately reflected in the ICollection.
The elements of the ICollection are sorted in the same order as the values of the SortedList.
This property is similar to the GetValueList method but returns an ICollection object instead of an IList object.
This method is an O(1) operation.
Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.sortedlist.values?view=netframework-4.7.2
CSharp-Collections-Namespace
CSharp-Collections-SortedList
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# Dictionary with examples
C# | Delegates
C# | Method Overriding
C# | Abstract Classes
Difference between Ref and Out keywords in C#
Extension Method in C#
C# | Class and Object
C# | Replace() Method
C# | Constructors
Introduction to .NET Framework
Python | Find last occurrence of substring - GeeksforGeeks

29 May, 2019
Sometimes, while working with strings, we need to find if a substring exists in the string. This problem is quite common and its solution has been discussed many times before. The variation of getting the last occurrence of the string is discussed here. Let’s discuss certain ways in which this can be performed.
Method #1 : Using rindex()
This method returns the last occurrence of the substring if present in the string. The drawback of this function is that it throws the exception if there is no substring in the string and hence breaks the code.
# Python3 code to demonstrate# Find last occurrence of substring# using rindex()  # initializing string test_string = "GfG is best for CS and also best for Learning"  # initializing target word tar_word = "best"  # printing original string print("The original string : " + str(test_string))  # using rindex()# Find last occurrence of substringres = test_string.rindex(tar_word)  # print resultprint("Index of last occurrence of substring is : " + str(res))
The original string : GfG is best for CS and also best for Learning
Index of last occurrence of substring is : 28

 
Method #2 : Using rfind()
This is the alternate method to perform this task. The advantage that this function offers better than the above method is that, this function returns a “-1” if a substring is not found rather than throwing the error.
# Python3 code to demonstrate# Find last occurrence of substring# using rfind()  # initializing string test_string = "GfG is best for CS and also best for Learning"  # initializing target word tar_word = "best"  # printing original string print("The original string : " + str(test_string))  # using rfind()# Find last occurrence of substringres = test_string.rfind(tar_word)  # print resultprint("Index of last occurrence of substring is : " + str(res))
The original string : GfG is best for CS and also best for Learning
Index of last occurrence of substring is : 28

Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
MySQL - PHP Syntax

MySQL works very well in combination of various programming languages like PERL, C, C++, JAVA and PHP. Out of these languages, PHP is the most popular one because of its web application development capabilities.
This tutorial focuses heavily on using MySQL in a PHP environment. If you are interested in MySQL with PERL, then you can consider reading the PERL  Tutorial.
PHP provides various functions to access the MySQL database and to manipulate the data records inside the MySQL database. You would require to call the PHP functions in the same way you call any other PHP function.
The PHP functions for use with MySQL have the following general format −
mysqli function(value,value,...);

The second part of the function name is specific to the function, usually a word that describes what the function does. The following are two of the functions, which we will use in our tutorial −
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
mysqli->query(,"SQL statement");

The following example shows a generic syntax of PHP to call any MySQL function.
<html>
   <head>
      <title>PHP with MySQL</title>
   </head>
   
   <body>
      <?php
         $retval = mysqli - > function(value, [value,...]);
         if( !$retval ) {
            die ( "Error: a related error message" );
         }
         // Otherwise MySQL  or PHP Statements
      ?>
   </body>
</html>
Starting from the next chapter, we will see all the important MySQL functionality along with PHP.

    31 Lectures 
     6 hours 

 Eduonix Learning Solutions

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    6 Lectures 
     3.5 hours 

 DATAhill Solutions Srinivas Reddy

    60 Lectures 
     10 hours 

 Vijay Kumar Parvatha Reddy

    10 Lectures 
     1 hours 

 Harshit Srivastava

    25 Lectures 
     4 hours 

 Trevoir Williams
 Print
 Add Notes
 Bookmark this page
Batch Script - CHOICE

This batch command provides a list of options to the user.
CHOICE /c [Options] /m [Message]

Where Options is the list of options to provide to the user and Message is the string message which needs to be displayed.
@echo off 
echo "What is the file size you what" 
echo "A:10MB" 
echo "B:20MB" 
echo "C:30MB" 
choice /c ABC /m "What is your option A , B or C"
The above program produces the following output.
"What is the file size you what"
"A:10MB"
"B:20MB"
"C:30MB"
What is your option A , B or C [A,B,C]?

 Print
 Add Notes
 Bookmark this page
Union() function in Python

08 Oct, 2021
Python set Union() function returns a new set which contains all the items from the original set.
Union of two given sets is the smallest set which contains all the elements of both the sets. Union of two given sets A and B is a set which consists of all the elements of A and all the elements of B such that no element is repeated.
The symbol for denoting union of sets is ‘U’ 
Examples: 
Input: Let set A = {2, 4, 5, 6} and set B = {4, 6, 7, 8}
Output: {2, 4, 5, 6, 7, 8} 
Explanation: Taking every element of both the sets A and B, without repeating any element, we get a new set = {2, 4, 5, 6, 7, 8}.This new set contains all the elements of set A and all the elements of set B with no repetition of elements and is named as union of set A and B.  
set1.union(set2, set3, set4....) 
In parameters, any number of sets can be given
The union() function returns a set, which has the union of all sets(set1, set2, set3...) with set1. It returns a copy of set1 only if no parameter is passed. 
Python3
# Python3 program for union() function set1 = {2, 4, 5, 6}set2 = {4, 6, 7, 8}set3 = {7, 8, 9, 10} # union of two setsprint("set1 U set2 : ", set1.union(set2)) # union of three setsprint("set1 U set2 U set3 :", set1.union(set2, set3))
Output: 
set1 U set2 :  {2, 4, 5, 6, 7, 8}
set1 U set2 U set3 : {2, 4, 5, 6, 7, 8, 9, 10}
We can use “|” operator to find the union of the sets.
Python3
# Python3 program for union with | operator set1 = {2, 4, 5, 6}set2 = {4, 6, 7, 8}set3 = {7, 8, 9, 10} # union of two setsprint("set1 U set2 : ", set1 | set2) # union of three setsprint("set1 U set2 U set3 :", set1 |set2 | set3)
Output:
set1 U set2 :  {2, 4, 5, 6, 7, 8}
set1 U set2 U set3 : {2, 4, 5, 6, 7, 8, 9, 10}
kumar_satyam
Python-Built-in-functions
python-set
Python
python-set
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
Python Dictionary
How to get column names in Pandas dataframe
Taking input in Python
Enumerate() in Python
Different ways to create Pandas Dataframe
Read a file line by line in Python
How to Install PIP on Windows ?
Differences between HashMap and HashTable in Java

23 Jan, 2022
HashMap and Hashtable store key and value pairs in a hash table. When using a Hashtable or HashMap, we specify an object that is used as a key and the value that you want to be linked to that key. The key is then hashed, and the resulting hash code is used as the index at which the value is stored within the table. Now let us discuss with the help of an example.
Hashmap vs Hashtable 
HashMap is non-synchronized. It is not thread-safe and can’t be shared between many threads without proper synchronization code whereas Hashtable is synchronized. It is thread-safe and can be shared with many threads.
HashMap allows one null key and multiple null values whereas Hashtable doesn’t allow any null key or value.
HashMap is generally preferred over HashTable if thread synchronization is not needed.
Now you must be wondering why HashTable doesn’t allow null and HashMap do? 
The answer is simple. In order to successfully store and retrieve objects from a HashTable, the objects used as keys must implement the hashCode method and the equals method. Since null is not an object, it can’t implement these methods. HashMap is an advanced version and improvement on the Hashtable. HashMap was created later.
Example:
Java
// Java program to demonstrate// HashMap and HashTableimport java.util.*;import java.lang.*;import java.io.*; // Name of the class has to be "Main"// only if the class is publicclass Ideone{    public static void main(String args[])    {        //----------hashtable -------------------------        Hashtable<Integer,String> ht=new Hashtable<Integer,String>();        ht.put(101," ajay");        ht.put(101,"Vijay");        ht.put(102,"Ravi");        ht.put(103,"Rahul");        System.out.println("-------------Hash table--------------");        for (Map.Entry m:ht.entrySet()) {            System.out.println(m.getKey()+" "+m.getValue());        }         //----------------hashmap--------------------------------        HashMap<Integer,String> hm=new HashMap<Integer,String>();        hm.put(100,"Amit");        hm.put(104,"Amit");         hm.put(101,"Vijay");        hm.put(102,"Rahul");        System.out.println("-----------Hash map-----------");        for (Map.Entry m:hm.entrySet()) {            System.out.println(m.getKey()+" "+m.getValue());        }    }}
-------------Hash table--------------
103 Rahul
102 Ravi
101 Vijay
-----------Hash map-----------
100 Amit
101 Vijay
102 Rahul
104 Amit
This article is compiled by Aditya Goel. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
cu17bcs3012
SubhrodipMohanta
martialcoder
solankimayank
nishkarshgandhi
Java-HashMap
Java-HashTable
Java-Map-Programs
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Java
Split() String method in Java with examples
Arrays.sort() in Java with examples
Object Oriented Programming (OOPs) Concept in Java
Reverse a string in Java
For-each loop in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
ArrayList in Java
Java Integer bitCount() method

05 Dec, 2018
The bitCount() method of Integer class of java.lang package returns the count of the number of one-bits in the two’s complement binary representation of an int value. This function is sometimes referred to as the population count.
Syntax :
public static int bitCount(int n)
Parameter :
n : the value whose bits are to be counted
Return :
This method returns the count of the number of one-bits in the two's complement 
binary representation of an int value.

Example :To show working of java.lang.Integer.bitCount() method.
// Java program to demonstrate working// of java.lang.Integer.bitCount() methodimport java.lang.Integer;  class Gfg {    // driver code    public static void main(String args[])    {        int a = 10;          // Convert integer number to binary  format        System.out.println(Integer.toBinaryString(a));          // to print number of 1's in the number a        System.out.println(Integer.bitCount(a));    }}
Output:
1010
2

Java-Functions
Java-Integer
Java-lang package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
Stream In Java
ArrayList in Java
Collections in Java
Singleton Class in Java
Multidimensional Arrays in Java
Set in Java
Program for Fibonacci numbers in PL/SQL

Given with ‘n’ numbers the task is to generate the fibonacci numbers in PL/SQL starting from 0 to n where fibonacci series of integer is in the form
0, 1, 1, 2, 3, 5, 8, 13, 21, 34
Where, integer 0 and 1 will have fixed space, after that two digits are added for example,
0+1=1(3rd place)
1+1=2(4th place)
2+1=3(5th place) and So on
Sequence F(n) of fibonacci series will have recurrence relation defined as −
Fn = Fn-1 + Fn-2
Where, F(0)=0 and F(1)=1 are always fixed
PL/SQL is an Oracle product which is a combination of SQL and Procedural language(PL) introduced in early 90’s. It was introduced for adding more features and functionalities to the simple SQL.
   -- declare variable a = 0 for first digit in a series
   -- declare variable b = 0 for Second digit in a series
   -- declare variable temp for first digit in a series
declare
a number := 0;
b number := 1;
temp number;
n number := 10;
i number;
begin
   dbms_output.put_line('fibonacci series is :');
   dbms_output.put_line(a);
   dbms_output.put_line(b);
   for i in 2..n
   loop
      temp:= a + b;
      a := b;
      b := temp;
      dbms_output.put_line(temp);
   end loop;
end;
fibonacci series is : 0 1 1 2 3 5 8 13 21 34
Angular 10 (focus) Event

04 Jul, 2021
In this article, we are going to see what is focus event in Angular 10 and how to use it. The (focus) event is triggered when an element gains its focus.
Syntax:
<input (focus)='functionName()'/>
NgModule: Module used by focus event is:
CommonModule
Approach: 
Create an Angular app to be used.
In app.component.ts make a function that triggers on focus event.
In app.component.html make an input element and set focus event.
Serve the angular app using ng serve to see the output.
 
Example 1:
app.component.ts
import { Component } from '@angular/core';  @Component({    selector: 'app-root',    templateUrl: './app.component.html',    styleUrls: ['./app.component.css']})  export class AppComponent {    onFocus(): void {        console.log('Focus Is gained for this Element');    }}
app.component.html
<br><form>    <input placeholder="Name" (focus) = 'onFocus()'></form>
Output:
Example 2:
app.component.ts
import { Component } from '@angular/core';  @Component({    selector: 'app-root',    templateUrl: './app.component.html',    styleUrls: ['./app.component.css']})  export class AppComponent {    onFocus(): void {        console.log('Focus Is gained for this Element');    }}
app.component.html
<br><form>    <button (focus) = 'onFocus()'>Click here!</button></form>
Output:
Angular10
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Auth Guards in Angular 9/10/11
Routing in Angular 9/10
How to bundle an Angular app for production?
What is AOT and JIT Compiler in Angular ?
Angular PrimeNG Dropdown Component
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Alter a MySQL column to be AUTO_INCREMENT?

Let’s say we have a table and now there is a requirement to add AUTO_INCREMENT on column name. For that, use the MODIFY command.
Here, we will create a demo table first.
mysql>  create table AddingAutoIncrement
   -> (
   -> Id int,
   -> Name varchar(200),
   -> Primary key(Id)
   -> );
Query OK, 0 rows affected (0.47 sec)
We have created a table above and now let us alter the table to add AUTO_INCREMENT on column name ‘Id’. The syntax is as follows −
alter table yourTableNamet modify yourColumnName int AUTO_INCREMENT;
Apply the above syntax to add AUTO_INCREMENT. The query is as follows.
mysql>  ALTER table AddingAutoIncrement modify Id int AUTO_INCREMENT;
Query OK, 0 rows affected (1.19 sec)
Records: 0  Duplicates: 0  Warnings: 0
Above, we have added “AUTO_INCREMENT” on column name ‘Id’. Let us check the same with the help of DESC command. The query is as follows −
mysql> desc AddingAutoIncrement;
Sample Output.
+-------+--------------+------+-----+---------+----------------+
| Field | Type         | Null | Key | Default | Extra          |
+-------+--------------+------+-----+---------+----------------+
| Id    | int(11)      | NO   | PRI | NULL    | auto_increment |
| Name  | varchar(200) | YES  |     | NULL    |                |
+-------+--------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)

Look at the output above and column name ‘Extra’. In the column name ‘Extra’, there is a keyword auto_increment. This itself says that we have added the keyword successfully.
Now, I am going to insert records and check whether the row is increment by one or not. The query is as follows −
mysql> insert into AddingAutoIncrement(Name) values('John');
Query OK, 1 row affected (0.20 sec)

mysql>  insert into AddingAutoIncrement(Name) values('Smith');
Query OK, 1 row affected (0.12 sec)

mysql>  insert into AddingAutoIncrement(Name) values('Bob');
Query OK, 1 row affected (0.10 sec)
Display all records with the help of SELECT statement.
mysql> select *from AddingAutoIncrement;
The following is the output.
+----+-------+
| Id | Name  |
+----+-------+
|  1 | John  |
|  2 | Smith |
|  3 | Bob   |
+----+-------+
3 rows in set (0.00 sec)

As you can see in the above output, row is incremented by 1.