code-rag-bench/online-tutorials huggingface dataset:
Python List reverse()

03 Aug, 2021
Python List reverse() is an inbuilt method in the Python programming language that reverses objects of the List in place.
Syntax: 
list_name.reverse()
Parameters: 
There are no parameters.
Returns: 
The reverse() method does not return any value but reverses the given object from the list.
Error:
When anything other than list is used in place of list, then it returns an AttributeError
Python3
# Python3 program to demonstrate the# use of reverse method  # a list of numberslist1 = [1, 2, 3, 4, 1, 2, 6]list1.reverse()print(list1) # a list of characterslist2 = ['a', 'b', 'c', 'd', 'a', 'a']list2.reverse()print(list2)
Output: 
[6, 2, 1, 4, 3, 2, 1]
['a', 'a', 'd', 'c', 'b', 'a']
Python3
# Python3 program to demonstrate the# error in reverse() method  # error when string is used in place of liststring = "abgedge"string.reverse()print(string)
Output: 
Traceback (most recent call last):
  File "/home/b3cf360e62d8812babb5549c3a4d3d30.py", line 5, in 
    string.reverse() 
AttributeError: 'str' object has no attribute 'reverse' 
Given a list of numbers, check if the list is a palindrome. 
Note: Palindrome-sequence that reads the same backward as forwards.
Python3
# Python3 program for the# practical application of reverse() list1 = [1, 2, 3, 2, 1] # store a copy of listlist2 = list1.copy()  # reverse the listlist2.reverse() # compare reversed and original listif list1 == list2:    print("Palindrome")else:    print("Not Palindrome")
Output: 
Palindrome
AmiyaRanjanRout
python-list
python-list-functions
Reverse
Python
python-list
Reverse
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
p5.js | color() Function

25 Jul, 2019
The color() function is used to create color and store it into variables. The parameters of color function are RGB or HSB value depending on the current colorMode() function. The default mode of color() function is RGB value from 0 to 255. Therefore, the function color(255, 204, 0) will return a bright yellow color.
Syntax:
color(gray, alpha)
color(v1, v2, v3, alpha)
color(value)
color(values)
color(color)

Parameters:
gray: It is used to set the gray value between white and black.
alpha: It is used to set the transparency of the drawing.
v1: It is used to set the red or hue value relative to current color range.
v2: It is used to set the green or saturation value relative to current color range.
v3: It is used to set the blue or brightness value relative to current color range.
value: It is used to set the value of color string.
values: It is an array containing the red, green, blue and alpha value.
color: It is used to set the stroke color.
Return Value: It returns the resulting color value.
Example 1:
function setup() {           // Create Canvas of given size     createCanvas(400, 300);   }   function draw() {           background(220);          // Use color() function    let c = color('green');      // Use fill() function to fill color    fill(c);        // Draw a circle     circle(200, 150, 150);     } 
Output:
Example 2:
function setup() {           // Create Canvas of given size     createCanvas(400, 300); }   function draw() {           // Set the background color     background(220);           // Use color() function    let c = color(0, 155, 0);          // Use fill() function to fill color    fill(c)        // Draw a line     rect(50, 50, 250, 150);   } 
Output:
Reference: https://p5js.org/reference/#/p5/color
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JavaScript | Callbacks

17 Jul, 2018
Callbacks are a great way to handle something after something else has been completed. By something here we mean a function execution. If we want to execute a function right after the return of some other function, then callbacks can be used.
JavaScript functions have the type of Objects. So, much like any other objects (String, Arrays etc.), They can be passed as an argument to any other function while calling.
<script>     // add() function is called with arguments a, b   // and callback, callback will be executed just    // after ending of add() function   function add(a, b , callback){   document.write(`The sum of ${a} and ${b} is ${a+b}.` +"<br>");   callback();   }        // disp() function is called just   // after the ending of add() function    function disp(){   document.write('This must be printed after addition');   }        // Calling add() function   add(5,6,disp);         </script>
Output:
The sum of 5 and 6 is 11.
This must be printed after addition
Explanation:Here are the two functions – add(a, b, callback) and disp(). Here add() is called with the disp() function i.e. passed in as the third argument to the add function along with two numbers.
As a result, the add() is invoked with 1, 2 and the disp() which is the callback. The add() prints the addition of the two numbers and as soon as that is done, the callback function is fired! Consequently, we see whatever is inside the disp() as the output below the addition output.
Code #2:An alternate way to implement above code is shown below with anonymous functions being passed.
<script>     // add() function is called with arguments a, b   // and callback, callback will be executed just    // after ending of add() function   function add(a, b , callback){   document.write(`The sum of ${a} and ${b} is ${a+b}.` +"<br>");   callback();   }      // add() function is called with arguments given below   add(5,6,function disp(){   document.write('This must be printed after addition.');   });     </script>
Output:
The sum of 5 and 6 is 11.
This must be printed after addition.
Callbacks are primarily used while handling asynchronous operations like – making an API request to the Google Maps, fetching/writing some data from/into a file, registering event listeners and related stuff. All the operations mentioned uses callbacks. This way once the data/error from the asynchronous operation is returned, the callbacks are used to do something with that inside our code.
javascript-basics
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python List append() Method

04 Aug, 2021
The Python List append() method is used for appending and adding elements to the end of the List. 
Syntax: list.append(item)
Parameters:
item: an item to be added at the end of the list
Returns:
The method doesn’t return any value 
Python
# my_listmy_list = ['geeks', 'for']  # Add 'geeks' to the listmy_list.append('geeks')  print my_list
Output:
['geeks', 'for', 'geeks']
Python
# my_listmy_list = ['geeks', 'for', 'geeks']  # another listanother_list = [6, 0, 4, 1]  # append another_list to my_listmy_list.append(another_list)  print my_list
Output:
['geeks', 'for', 'geeks', [6, 0, 4, 1]]
Note: A list is an object. If you append another list onto a list, the parameter list will be a single object at the end of the list.
python-list
python-list-functions
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JP Morgan Archives - GeeksforGeeks

JP Morgan Chase Interview Questions
JP Morgan Chase & Co. (JPMC) Interview Experience | (Full time Software Engineer)
JPMorgan Chase & Co. Code for Good Internship Interview Experience 2021
JP Morgan Chase - Code for Good Interview Experience for Software Engineer FTE
JP Morgan Interview Experience for Quantitative Researcher | On-Campus 2022
Convert given Array of Strings to a Camel Case format sentence
JPMorgan Chase - Code for Good Interview Experience for Software Engineer FTE
JP Morgan Interview experience | SDET Role for Experienced
JP Morgan Code for Good Internship Interview Experience 2021
JP Morgan Chase Interview Experience for Software Engineer 2021
Python | PanedWindow Widget in Tkinter

07 Jun, 2019
Tkinter supports a variety of widgets to make GUI more and more attractive and functional. The PanedWindow widget is a geometry manager widget, which can contain one or more child widgets panes. The child widgets can be resized by the user, by moving separator lines sashes using the mouse.
Syntax: PanedWindow(master, **options)
Parameters:master: parent widget or main Tk() objectoptions: which are passed in config method or directly in the constructor
PanedWindow can be used to implement common 2-panes or 3-panes but multiple panes can be used.
Code #1:PanedWindow with only two panes
# Importing everything from tkinter modulefrom tkinter import * from tkinter import ttk  # main tkinter windowroot = Tk()  # panedwindow objectpw = PanedWindow(orient ='vertical')  # Button widgettop = ttk.Button(pw, text ="Click Me !\nI'm a Button")top.pack(side = TOP)  # This will add button widget to the panedwindowpw.add(top)  # Checkbutton Widgetbot = Checkbutton(pw, text ="Choose Me !")bot.pack(side = TOP)  # This will add Checkbutton to panedwindowpw.add(bot)  # expand is used so that widgets can expand# fill is used to let widgets adjust itself# according to the size of main windowpw.pack(fill = BOTH, expand = True)  # This method is used to show sashpw.configure(sashrelief = RAISED)  # Infinite loop can be destroyed by# keyboard or mouse interruptmainloop()
Output: Code #2: PanedWindow with multiple panes
# Importing everything from tkinter modulefrom tkinter import * from tkinter import ttk  # main tkinter windowroot = Tk()  # panedwindow objectpw = PanedWindow(orient ='vertical')  # Button widgettop = ttk.Button(pw, text ="Click Me !\nI'm a Button")top.pack(side = TOP)  # This will add button widget to the panedwindowpw.add(top)  # Checkbutton Widgetbot = Checkbutton(pw, text ="Choose Me !")bot.pack(side = TOP)  # This will add Checkbutton to panedwindowpw.add(bot)  # adding Label widgetlabel = Label(pw, text ="I'm a Label")label.pack(side = TOP)  pw.add(label)  # Tkinter string variablestring = StringVar()  # Entry widget with some styling in fontsentry = Entry(pw, textvariable = string, font =('arial', 15, 'bold'))entry.pack()  # Focus force is used to focus on particular# widget that means widget is already selected for operationsentry.focus_force()  pw.add(entry)  # expand is used so that widgets can expand# fill is used to let widgets adjust itself# according to the size of main windowpw.pack(fill = BOTH, expand = True)  # This method is used to show sashpw.configure(sashrelief = RAISED)  # Infinite loop can be destroyed by# keyboard or mouse interruptmainloop()
Output:
Python-gui
Python-tkinter
Python
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
How to get column names in Pandas dataframe
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 ?
Iterate over a list in Python
cmd | cls command

29 Sep, 2020
Cls is a internal command found inside windows command interpreter cmd, that is used for clearing the console window.It does so by removing the entry of all previously entered commands, and their corresponding outputs. The command was first introduced in the MSDOS Version 2. Initially it was for command.com (command processor for MSDOS), which is the predecessor of cmd.exe (AKA Command Prompt).It is one of the most used commands, and is offered by all Operating Systems in one way or another (ex. Linux has a command named clear which serves the same purpose). In this article, we would learn about this command and how to use it.
Description of the Command :
CLS : Clears the screen.

Note –In order to obtain the above text execute the cls /? command on cmd.
Using Command :The command serves only one purpose, and that is to clear the output screen. For doing so execute the command without any parameters.
Example –For this example, we would be using the following console window.
This window currently contains output from the dir command. In order to clear this output (and others before it) execute the CLS command. After command execution, the windows appear as follows.
It is clear that from the above image, that all the previous output has been removed.
Misc
Misc
Misc
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Event Binding in Angular 8

14 Sep, 2020
In Angular 8, event binding is used to handle the events raised by the user actions like button click, mouse movement, keystrokes, etc. When the DOM event happens at an element(e.g. click, keydown, keyup), it calls the specified method in the particular component. 
Using Event Binding we can bind data from DOM to the component and hence can use that data for further purposes.
Syntax:
< element (event) = function() >
Approach: 
Define a function in the app.component.ts file which will do the given task.
In the app.component.html file, bind the function to the given event on the HTML element.
Example 1: Using click event on the input element.
app.component.html
HTML
<h1>  GeeksforGeeks</h1><input (click)="gfg($event)" value="Geeks">
app.component.ts
Javascript
import { Component } from '@angular/core';    @Component({      selector: 'app-root',      templateUrl: './app.component.html',      styleUrls: ['./app.component.css']    })    export class AppComponent {      gfg(event) {    console.log(event.toElement.value);  }    }
Output:
Example 2: Using keyup event on the input element.
app.component.html
HTML
<!-- event is passed to function --><input (keyup)="onKeyUp($event)">      <p>{{text}}</p>
app.component.ts
Javascript
import { Component } from '@angular/core';    @Component({      selector: 'app-root',      templateUrl: './app.component.html',      styleUrls: ['./app.component.css']    })    export class AppComponent {     text = '';   onKeyUp(x) {       // Appending the updated value    // to the variable     this.text += x.target.value + ' | ';   } }
Output:
AngularJS-Misc
Picked
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
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Python - Heat Maps

A heatmap contains values representing various shades of the same colour for each value to be plotted. Usually the darker shades of the chart represent higher values than the lighter shade. For a very different value a completely different colour can also be used.  
The below example is a two-dimensional plot of values which are mapped to the indices and columns of the chart.
from pandas import DataFrame
import matplotlib.pyplot as plt

data=[{2,3,4,1},{6,3,5,2},{6,3,5,4},{3,7,5,4},{2,8,1,5}]
Index= ['I1', 'I2','I3','I4','I5']
Cols = ['C1', 'C2', 'C3','C4']
df = DataFrame(data, index=Index, columns=Cols)

plt.pcolor(df)
plt.show()
Its output is as follows −
Python | Find maximum value in each sublist

14 Feb, 2019
Given list of lists in Python, write a Python program to find maximum value of list each sub-list.
Examples:
Input : [[10, 13, 454, 66, 44], [10, 8, 7, 23]]
Output :  [454, 23]

Input : [[15, 12, 27, 1, 33], [101, 58, 77, 23]]
Output :  [33, 101]
 Method #1: Using list comprehension.
# Python code to Find maximum of list in nested list  # Initialising Lista = [[10, 13, 454, 66, 44], [10, 8, 7, 23]]  # find max in listb = [max(p) for p in a]  # Printing maxprint(b)
[454, 23]

 Method #2: Using map
# Python code to Find maximum of list in nested list  # Initialising Lista = [[10, 13, 454, 66, 44], [10, 8, 7, 23]]  # find max in listans = list(map(max, a))  # Printing maxprint(ans)
[454, 23]

Python list-programs
python-list
Python
python-list
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
Convert class object to JSON in Python

29 Dec, 2020
Conversion of the class object to JSON is done using json package in Python. json.dumps() converts Python object into a json string. Every Python object has an attribute which is denoted by __dict__ and this stores the object’s attributes. 
Object is first converted into dictionary format using __dict__ attribute.This newly created dictionary is passed as a parameter to json.dumps() which then yields a JSON string.
Object is first converted into dictionary format using __dict__ attribute.
This newly created dictionary is passed as a parameter to json.dumps() which then yields a JSON string.
Syntax: json.dumps(Object obj)
Parameter: Expects a dictionary object.
Return: json string
Following python code converts a python class Student object to JSON.
Python3
# import required packagesimport json  # custom classclass Student:    def __init__(self, roll_no, name, batch):        self.roll_no = roll_no        self.name = name        self.batch = batch    class Car:    def __init__(self, brand, name, batch):        self.brand = brand        self.name = name        self.batch = batch    # main functionif __name__ == "__main__":        # create two new student objects    s1 = Student("85", "Swapnil", "IMT")    s2 = Student("124", "Akash", "IMT")      # create two new car objects    c1 = Car("Honda", "city", "2005")    c2 = Car("Honda", "Amaze", "2011")      # convert to JSON format    jsonstr1 = json.dumps(s1.__dict__)    jsonstr2 = json.dumps(s2.__dict__)    jsonstr3 = json.dumps(c1.__dict__)    jsonstr4 = json.dumps(c2.__dict__)      # print created JSON objects    print(jsonstr1)    print(jsonstr2)    print(jsonstr3)    print(jsonstr4)
Output:
{"roll_no": "85", "name": "Swapnil", "batch": "IMT"}
{"roll_no": "124", "name": "Akash", "batch": "IMT"}
{"brand": "Honda", "name": "city", "batch": "2005"}
{"brand": "Honda", "name": "Amaze", "batch": "2011"}
Python json-programs
Python-json
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Create a directory in Python
Java Program to check Armstrong Number

27 Sep, 2021
Problem Statement – Given a number x. Write a Java Program to determine whether the given number is Armstrong’s number or not. 
Examples – 
Input : 153
Output : Yes
153 is an Armstrong number.
1*1*1 + 5*5*5 + 3*3*3 = 153

Input : 120
Output : No
120 is not a Armstrong number.
1*1*1 + 2*2*2 + 0*0*0 = 9

Input : 1253
Output : No
1253 is not a Armstrong Number
1*1*1*1 + 2*2*2*2 + 5*5*5*5 + 3*3*3*3 = 723

Input : 1634
Output : Yes
1*1*1*1 + 6*6*6*6 + 3*3*3*3 + 4*4*4*4 = 1634
In a mathematical number system, the Armstrong number is the number in any given number base, which makes the total of the same number when each of its digits is raised to the power of the total number of digits in the number. In simple words, we can say that a positive integer of n digits is called an Armstrong number of order n (order is the total number of digits present in a number) if, 
abcd... = pow(a,n) + pow(b,n) + pow(c,n) + pow(d,n) + .... 
For example, using a simple number 153 and the decimal system, we see 3 digits in it. If we do a simple mathematical operation of raising each of its digits to the power of 3, and then totaling the sum obtained, we get 153. 
13 + 53 + 33=153. The number 153 is an example of the Armstrong number. 
Java
// Java program to determine whether the number is// Armstrong number or notpublic class Armstrong {    /* Function to calculate x raised to the       power y */    int power(int x, long y)    {        if (y == 0)            return 1;        if (y % 2 == 0)            return power(x, y / 2) * power(x, y / 2);        return x * power(x, y / 2) * power(x, y / 2);    }      /* Function to calculate order of the number */    int order(int x)    {        int n = 0;        while (x != 0) {            n++;            x = x / 10;        }        return n;    }      // Function to check whether the given number is    // Armstrong number or not    boolean isArmstrong(int x)    {        // Calling order function        int n = order(x);        int temp = x, sum = 0;        while (temp != 0) {            int r = temp % 10;            sum = sum + power(r, n);            temp = temp / 10;        }          // If satisfies Armstrong condition        return (sum == x);    }      // Driver Program    public static void main(String[] args)    {        Armstrong ob = new Armstrong();        int x = 153;        System.out.println(x + " : " + ob.isArmstrong(x));        x = 1253;        System.out.println(x + " : " + ob.isArmstrong(x));    }}
153 : true
1253 : false
nishkarshgandhi
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Set isEmpty() method in Java with Examples

31 Dec, 2018
The java.util.Set.isEmpty() method is used to check if a Set is empty or not. It returns True if the Set is empty otherwise it returns False.
Syntax:
boolean isEmpty()
Parameters: This method does not take any parameter
Return Value: The method returns True if the set is empty else returns False.
Below program illustrate the java.util.Set.isEmpty() method:
// Java code to illustrate isEmpty()import java.io.*;import java.util.*;  public class SetDemo {    public static void main(String args[])    {        // Creating an empty Set        Set<String> set = new HashSet<String>();          // Use add() method to add elements into the Set        set.add("Welcome");        set.add("To");        set.add("Geeks");        set.add("4");        set.add("Geeks");          // Displaying the Set        System.out.println("Set: " + set);          // Check for the empty set        System.out.println("Is the set empty? " + set.isEmpty());          // Clearing the set using clear() method        set.clear();          // Again Checking for the empty set        System.out.println("Is the set empty? " + set.isEmpty());    }}
Set: [4, Geeks, Welcome, To]
Is the set empty? false
Is the set empty? true

Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Set.html#isEmpty()
Java-Collections
Java-Functions
java-set
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Introduction to Java
Constructors in Java
Exceptions in Java
Generics in Java
Functional Interfaces in Java
Java Programming Examples
Strings in Java
Differences between JDK, JRE and JVM
Abstraction in Java
Firebase - Data

The Firebase data is representing JSON objects. If you open your app from Firebase dashboard, you can add data manually by clicking on the + sign.
We will create a simple data structure. You can check the image below.
In the previous chapter, we connected Firebase to our app. Now, we can log Firebase to the console.
console.log(firebase)
We can create a reference to our player’s collection.
  
var ref = firebase.database().ref('players');

console.log(ref);
We can see the following result in the console.

    60 Lectures 
     5 hours 

 University Code

    28 Lectures 
     2.5 hours 

 Appeteria

    85 Lectures 
     14.5 hours 

 Appeteria

    46 Lectures 
     2.5 hours 

 Gautham Vijayan

    13 Lectures 
     1.5 hours 

 Nishant Kumar

    85 Lectures 
     16.5 hours 

 Rahul Agarwal
 Print
 Add Notes
 Bookmark this page
How to get the number of days between two Dates in JavaScript?

To get the number of days between two dates, use the Maths.floor() method.
You can try to run the following code to get days between two dates −
Live Demo
<html>
   <head>
      <title>JavaScript Get Days</title>
   </head>
   <body>
      <script>
         var date1, date2;
         date1 = new Date();
         document.write(""+date1);
         date2 = new Date( "Dec 10, 2015 20:15:10" );
         document.write("<br>"+date2);
         // get total seconds between two dates
         var res = Math.abs(date1 - date2) / 1000;
         var days = Math.floor(res / 86400);
         document.write("<br>Difference: "+days);
      </script>
   </body>
</html>
Mon May 28 2018 09:32:56 GMT+0530 (India Standard Time)
Thu Dec 10 2015 20:15:10 GMT+0530 (India Standard Time)
Difference: 899
Pair in C++ Standard Template Library (STL)

In this tutorial, we will be discussing a program to understand pair in C++ Standard Template Library.
Pair is a container defined in the utility header that contains two values. It is used to combine two values and associate them even if they are of different types.
 Live Demo
#include <iostream>
#include <utility>
using namespace std;
int main(){
   //initializing a pair
   pair <int, char> PAIR1 ;
   PAIR1.first = 100;
   PAIR1.second = 'G' ;
   cout << PAIR1.first << " " ;
   cout << PAIR1.second << endl ;
   return 0;
}
100 G
Using Jupyter Notebook in Virtual Environment

14 Sep, 2021
In this article, we are going to see how to set Virtual Environment in Jupyter. Sometimes we want to use the Jupyter notebook in a virtual environment so that only selected packages are available in the scope of the notebook. To do this we have to add a new kernel for the virtual environment in the list of kernels available for the Jupyter notebook. Let’s see how to do that:
Step 1: Create a virtual environment
Open the directory where you want to create your project. open cmd/powershell and navigate to the same directory and run the following commands to create a virtual environment.
python -m venv venv
Step 2: Activate the virtual environment
Now as we have our virtual environment let’s activate it.
venv\Scripts\activate
Step 3: Install jupyter kernel for the virtual environment using the following command:
Running the following command will create a kernel that can be used to run jupyter notebook commands inside the virtual environment.
ipython kernel install --user --name=venv
Step 4: Select the installed kernel when you want to use jupyter notebook in this virtual environment
Let’s now check if our kernel is created. Just run “jupyter notebook” command in the command prompt or Powershell and the jupyter environment will open up. Click on the kernel and click change kernel you will be able to see the kernel you just created.
You can see now you have the kernel in the list of kernels and now you can have separate dependencies for the jupyter notebook and be more organized. After you are done with the project and no longer need the kernel you can uninstall it by running the following code:
jupyter-kernelspec uninstall venv
Jupyter-notebook
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
java.nio.file.Paths Class in Java

12 Mar, 2021
java.nio.file.Paths class contains static methods for converting path string or URI into Path.
Class declaration :
public final class Paths
extends Object
Methods:
get(String first, String... more) 
This method converts a path string, or a sequence of strings that when joined form a path string, to a Path.
get(URI uri)
This method converts the given URI to a Path object.
1. public static Path get(String first, String... more): 
Returns a Path by converting given strings into a Path. If “more” doesn’t specify any strings than “first” is the only string to convert. If “more” specify extra strings then “first” is the initial part of the sequence and the extra strings will be appended to the sequence after “first” separated by “/”.
Parameters:
first – initial part of the Path.more – extra strings to be joined to the Path.
first – initial part of the Path.
more – extra strings to be joined to the Path.
Returns: resulting Path
Throws: 
InvalidPathException – if a given string cannot be converted to a Path
Java
// Java program to demonstrate// java.nio.file.Path.get(String first,String... more)// method  import java.io.IOException;import java.nio.file.Path;import java.nio.file.Paths;  public class GFG {    public static void main(String[] args)        throws IOException    {          // create object of Path        Path path = (Path)Paths.get("/usr", "local", "bin");          // print Path        System.out.println(path);    }}
/usr/local/bin

2.public static Path get(URI uri): Returns a Path by converting given Uri into a Path.
Parameters: 
uri – to be converted
Returns: resulting Path
Throws:
IllegalArgumentException – if the parameter of URI is not appropriateFileSystemNotFoundException – if the file system, which is identified by URI does not existSecurityException – if security manager denies access to file system
IllegalArgumentException – if the parameter of URI is not appropriate
FileSystemNotFoundException – if the file system, which is identified by URI does not exist
SecurityException – if security manager denies access to file system
Java
// Java program to demonstrate// java.nio.file.Path.get(URI uri) method  import java.io.IOException;import java.net.URI;import java.net.URISyntaxException;import java.nio.file.Paths;  public class Path {    public static void main(String[] args)        throws IOException, URISyntaxException    {        String uribase = "https://www.geeksforgeeks.org/";        // Constructor to create a new URI        // by parsing the string        URI uri = new URI(uribase);          // create object of Path        Path path = (Path)Paths.get(uri);          // print ParentPath        System.out.println(path);    }}
Output:
https://www.geeksforgeeks.org/
Java-NIO package
Picked
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
ArrayList in Java
Multidimensional Arrays in Java
Collections in Java
Stream In Java
Set in Java
Singleton Class in Java
Tailwind CSS Rotate

23 Mar, 2022
This class accepts lots of value in tailwind CSS in which all the properties are covered in class form. This class is used to rotate an element based on the given angle as an argument. The angle can be set in terms of degrees, radians, or turns. In CSS, we can do that by using the CSS rotate() function.
Rotate classes:
rotate-0: This class is for no rotation.
rotate-1: This class is used to rotate 1 degree clockwise.
rotate-2: This class is used to rotate 2 degrees clockwise.
rotate-3: This class is used to rotate 3 degrees clockwise.
rotate-6: This class is used to rotate 6 degrees clockwise.
rotate-12: This class is used to rotate 12 degrees clockwise.
rotate-45: This class is used to rotate 45 degrees clockwise.
rotate-90: This class is used to rotate 90 degrees clockwise.
rotate-180: This class is used to rotate 180 degrees clockwise.
-rotate-1: This class is used to rotate 1 degree anti-clockwise.
-rotate-2: This class is used to rotate 2 degrees anti-clockwise.
-rotate-3: This class is used to rotate 3 degrees anti-clockwise.
-rotate-6: This class is used to rotate 6 degrees anti-clockwise.
-rotate-12: This class is used to rotate 12 degrees anti-clockwise.
-rotate-45: This class is used to rotate 45 degrees anti-clockwise.
-rotate-90: This class is used to rotate 90 degrees anti-clockwise.
-rotate-180: This class is used to rotate 180 degrees anti-clockwise.
Syntax:
<element class="rotate-{degree}">...</element>
Example:
HTML
<!DOCTYPE html> <html> <head>     <link href= "https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"    rel="stylesheet"> </head>   <body class="text-center">     <h1 class="text-green-600 text-5xl font-bold">        GeeksforGeeks     </h1>     <b>Tailwind CSS Rotate Class</b>     <div class="bg-green-300                 mx-16                p-4                justify-between                 grid grid-flow-col">     <div class="bg-no-repeat                w-16 h-16 transform rotate-0"         style=         "background-image:url( https://media.geeksforgeeks.org/wp-content/uploads/20210222211217/Screenshot20210222211207.png)">     </div>     <div class="bg-no-repeat                 w-16 h-16 transform rotate-45"         style=         "background-image:url( https://media.geeksforgeeks.org/wp-content/uploads/20210222211217/Screenshot20210222211207.png)">     </div>    <div class="bg-no-repeat                 w-16 h-16 transform rotate-90"         style="background-image:url( https://media.geeksforgeeks.org/wp-content/uploads/20210222211217/Screenshot20210222211207.png)">     </div>     <div class="bg-no-repeat                 w-16 h-16 transform rotate-180"         style="background-image:url( https://media.geeksforgeeks.org/wp-content/uploads/20210222211217/Screenshot20210222211207.png)">     </div>    </div> </body> </html> 
Output:
Tailwind CSS
Tailwind-Transforms
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Create a Donut Chart using Recharts in ReactJS - GeeksforGeeks

27 Jul, 2021

Introduction: Rechart JS is a library that is used for creating charts for React JS. This library is used for building Line charts, Bar charts, Pie charts, etc, with the help of React and D3 (Data-Driven Documents).  
To create Donut Chart using Recharts, we create a dataset that contains actual data. Then we define the slices using donaut element with data property which will have the data of the dataset created and with datakey property which is the property name with a value for the slices.
Creating React Application And Installing Module:

Step 1: Create a React application using the following command.
npx create-react-app foldername

Step 1: Create a React application using the following command.
npx create-react-app foldername

Step 2: After creating your project folder i.e. foldername, move to it using the following command.
cd foldername

Step 2: After creating your project folder i.e. foldername, move to it using the following command.
cd foldername

Step 3: After creating the ReactJS application, Install the required modules using the following command.
npm install --save recharts

Step 3: After creating the ReactJS application, Install the required modules using the following command.
npm install --save recharts
Project Structure: It will look like the following.
Example: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
App.js
 

 
 










import React from 'react'; 
import { PieChart, Pie} from 'recharts'; 
  
  
const App = () => { 
  
// Sample data 
const data = [ 
  {name: 'Geeksforgeeks', students: 400}, 
  {name: 'Technical scripter', students: 700}, 
  {name: 'Geek-i-knack', students: 200}, 
  {name: 'Geek-o-mania', students: 1000} 
]; 
  
  
return ( 
        <PieChart width={700} height={700}> 
          <Pie data={data} dataKey="students" outerRadius={250} innerRadius={150} fill="green" /> 
        </PieChart> 
); 
} 
  
export default App; 






Step to Run Application: Run the application using the following command from the root directory of the project:
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output:
Output

React-Questions


Recharts


JavaScript


ReactJS


Web Technologies

Writing code in comment? 
                                    Please use ide.geeksforgeeks.org, 
                                    generate link and share the link here.
                                
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
How to filter object array based on attributes?
How to get selected value in dropdown list using JavaScript ?
How to remove duplicate elements from JavaScript Array ?
How to fetch data from an API in ReactJS ?
How to redirect to another page in ReactJS ?
How to pass data from child component to its parent in ReactJS ?
How to pass data from one component to other component in ReactJS ?
ReactJS Functional Components
PHP - Function MySQLi Fetch Object

mysqli_fetch_object(result,classname,params);

It returns the current row of a result set, as an object.
It returns string properties for the fetched row or NULL if there are no more rows in the result set
result
It specifies the result set identifier returned by mysqli_query(), mysqli_store_result() or mysqli_use_result()
classname
It specifies the name of the class to instantiate
params
It specifies an array of parameters to pass to the constructor for classname objects
Try out the following example
<?php
   $connection_mysql = mysqli_connect("localhost","user","password","db");
   
   if (mysqli_connect_errno($connection_mysql)){
      echo "Failed to connect to MySQL: " . mysqli_connect_error();
   }
   
   $sql = "SELECT name FROM emp";
   
   if ($result = mysqli_query($connection_mysql,$sql)){
      while ($obj = mysqli_fetch_object($result)){
         print $obj->name;
         print "\n";
      }
      mysqli_free_result($result);
   }
   mysqli_close($connection_mysql);
?>

    45 Lectures 
     9 hours 

 Malhar Lathkar

    34 Lectures 
     4 hours 

 Syed Raza

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    17 Lectures 
     1 hours 

 Nivedita Jain

    100 Lectures 
     34 hours 

 Azaz Patel

    43 Lectures 
     5.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
Extracting Keywords from a Text Using R Regex (Easy) | by Deborah Kewon | Towards Data Science

When you have a large volume of text files, extracting only relevant information is not so easy. It is complicated and time-consuming. For this reason, I want to show you how I used Regex to extract locations from U.S. job description.
Here is the structure of a job description. My goal is to extract only states from this text column.
The state has a trailing space, which is located at the end of a line without any characters following it. If you do not remove it (\\n), you will end up extracting extra words.
Also, it is important to keep the state abbreviation in capital letters (‘CA’ rather than ‘ca’ for California) because if you don’t do this, it will extract all the words that have ‘ca’ in them.
# deleting punctuationsdescription$text<-gsub("[[:punct:][:blank:]]+", " ", description$text)# deleting trailing spacedescription$text<-gsub("\\n"," ", description$text)
After cleaning, you can split the job description text by space and find the string that matches the list of state abbreviations (dictionary). Once it is done, you can assign it to the location column as below.
#creating a location columndescription$location <- NA #using for loop to extract all the states for (i in 1:length(description$text)){    #split the text by space  split <- strsplit(description$text[i]," ")[[1]]     #comparing split with the state abbreviation   state <- match(split, stateabbreviation$Abbreviation)    #if it matches, get the position of each state  state <- which(!is.na(state))    #extract the state based on the position  state_split <- split[state]    #adding states to the new column   description$location[i] <- state_split[1]  }
In order to find the state abbreviations in the job description, I used the dictionary “stateabbreviation” I created.
And...Voila! Here is the result.
If you want to also extract the cities, you can simply use the same code with ‘which(!is.na(location))-1’. You use ‘-1’ because the cities come right before the states.
Now you can visualize it to have a better understanding of your finding.
library(ggplot2)state_count<-table(description$location)state_count<-as.data.frame(state_count)ggplot(state_count, aes(x = as.character(state_count$Var1), y = state_count$Freq)) + geom_bar(stat="identity") + theme(axis.text.x = element_text(angle = 60, vjust = )) + labs(y = "Frequency", x= "States")
This is part of my work to have a better understanding of the current data science job market. According to this result, California, New York, and Texas are in high need of data/tech-savvy professionals.
For more details regarding my text mining project, please feel free to visit my GitHub page. Thank you for reading!
Also, feel free to check out my other articles:
How to Get Twitter Notifications on Currency Exchange Rate: Web Scraping and Automation
Databricks: How to Save Data Frames as CSV Files on Your Local Computer
Difference between grep and fgrep command - GeeksforGeeks

27 Dec, 2018
The grep filter searches a file for a particular pattern of characters and displays all lines that contain that pattern. The fgrep filter searches for fixed-character strings in a file or files.
Syntax of grep command:
grep [options] pattern [files]

Syntax of fgrep command:
fgrep [options] pattern [files]

The main difference between both commands is:
String matching algorithm used by them.
fgrep always uses the Aho-Corasick algorithm that worst O(m+n) complexity.
grep command always uses the modified version of Commentz-Walter algorithm which has worst case O(mn) complexity.
fgrep command interprets the PATTERN as a list of fixed strings separated by newlines. But grep always interpreted as regular expressions.
Consider the below file named as para2
Hi, are you using geeksforgeeks for learning computer science concepts.
Geeksforgeeks is best for learning.

Consider the below Words :
are
using
geeksforgeeks
learning
concepts

Using grep Command:
$grep -f word para

Output:
Hi, are you using geeksforgeeks for learning computer science concepts.
Geeksforgeeks is best for learning.

Using fgrep Command:
$fgrep -f word para

Output:
Hi, are you using geeksforgeeks for learning computer science concepts.
Geeksforgeeks is best for learning.

Consider the below File :
Hi, @re you usin.g geeks*forgeeks for learni\ng computer science con/cepts.
Geeks*forgeeks is best for learni\ng.

Consider the below Words :
@re
usin.g
geeks*forgeeks
learni\ng
con/cepts

Using grep Command:
grep -f word para

Output:
Hi, @re you usin.g geeks*forgeeks for learni\ng computer science con/cepts.

Using fgrep Command:
fgrep -f word para

Output:
Hi, @re you usin.g geeks*forgeeks for learni\ng computer science con/cepts.
Geeks*forgeeks is best for learni\ng.

linux-command
Technical Scripter 2018
Difference Between
Linux-Unix
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Difference Between Method Overloading and Method Overriding in Java
Difference between Prim's and Kruskal's algorithm for MST
Difference between Internal and External fragmentation
Differences and Applications of List, Tuple, Set and Dictionary in Python
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
cut command in Linux with examples
TCP Server-Client implementation in C
Python | Pandas Series.ix

28 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 series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
Pandas Series.ix attribute is a primarily label-location based indexer, with integer position fallback. It takes the label as input and returns the value corresponding to that label.
Syntax:Series.ix
Parameter : None
Returns : value
Example #1: Use Series.ix attribute to return a value lying at the specified label in the given Series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series(['New York', 'Chicago', 'Toronto', 'Lisbon'])  # Creating the row axis labelssr.index = ['City 1', 'City 2', 'City 3', 'City 4']   # Print the seriesprint(sr)
Output :
Now we will use Series.ix attribute to return the value lying corresponding to the ‘City 4’ label.
# return the valuesr.ix['City 4']
Output :
As we can see in the output, the Series.ix attribute has returned ‘Lisbon’ as the value corresponding to the ‘City 4’ label in the given Series object. Example #2 : Use Series.ix attribute to return a value lying at the specified label in the given Series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series(['1/1/2018', '2/1/2018', '3/1/2018', '4/1/2018'])  # Creating the row axis labelssr.index = ['Day 1', 'Day 2', 'Day 3', 'Day 4']  # Print the seriesprint(sr)
Output :
Now we will use Series.ix attribute to return the value lying corresponding to the ‘Day 3’ label.
# return the valuesr.ix['Day 3']
Output :As we can see in the output, the Series.ix attribute has returned ‘3/1/2018’ as the value corresponding to the ‘Day 3’ label in the given Series object.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python | os.path.join() method
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Python | datetime.timedelta() function
Matplotlib.axes.Axes.axvline() in Python

21 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.axvline() function in axes module of matplotlib library is used to add a vertical line across the axis.
Syntax: Axes.axvline(self, x=0, ymin=0, ymax=1, **kwargs)
Parameters: This method accept the following parameters that are described below:
x: This parameter is the x position in data coordinates of the vertical line with default value of 0.
ymin: This parameter should be between 0 and 1, 0 being the bottom of the plot, 1 the top of the plot.Its default value of 0.
ymax: This parameter should be between 0 and 1, 0 being the bottom of the plot, 1 the top of the plot. Its default value of 1.
Returns: This returns the following:
lines:This returns the list of Line2D objects representing the plotted data.
Below examples illustrate the matplotlib.axes.Axes.axhline() function in matplotlib.axes:
Example 1:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as npimport matplotlib.collections as collections  t = np.arange(0.0, 5, 0.01)s1 = np.sin(4 * np.pi * t)  fig, ax = plt.subplots()  ax.plot(t, s1, color ='black', alpha = 0.75, lw = 1)ax.axvline(3, color ='green', lw = 2, alpha = 0.75)ax.set_title('matplotlib.axes.Axes.axvline() Example')plt.show()
Output:
Example 2:
# Implementation of matplotlib functionimport matplotlib.pyplot as pltimport numpy as np  t = np.linspace(-10, 10, 100)sig = 1 / t**2fig, ax = plt.subplots()  plt.axvline(color ="green", alpha = 0.8, lw = 1.5)plt.plot(t, sig, linewidth = 1.5, color ="black",         alpha = 0.6,         label = r"$\sigma(t) = \frac{1}{x ^ 2}$")  plt.xlim(-10, 10)plt.xlabel("t")plt.legend(fontsize = 14)  ax.set_title('matplotlib.axes.Axes.axvline() Example')plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.