code-rag-bench/online-tutorials huggingface dataset:
TypeScript | Array every() Method

18 Jun, 2020
The Array.every() is an inbuilt TypeScript function which is used to check for all the elements in an array passes the test implemented by the provided function. Syntax:
array.every(callback[, thisObject])
Parameter: This method accepts two parameter as mentioned above and described below:
callback : This parameter is the Function to test for each element.
thisObject : This parameter is the Object to use as this when executing callback.
Return Value: This method returns true if every element in this array satisfies the provided testing function. Below examples illustrate Array every() method in TypeScript
Example 1: 
JavaScript
<script>    // Check for positive number     function ispositive(element, index, array)    {        return element > 0;    }         // Driver code    var arr = [ 11, 89, 23, 7, 98 ];           // Check for positive number     var value = arr.every(ispositive);     console.log( value );</script>
Output: 
true
Example 2: 
JavaScript
<script>    // Check for odd number     function isodd(element, index, array)     {         return (element % 2 == 1);      }       // Driver code    var arr = [ 11, 89, 23, 7, 98 ];           // Check for positive number     var value = arr.every(isodd);     console.log( value );</script>
Output: 
false
TypeScript
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to append HTML code to a div using JavaScript ?
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 ?
Select Rows With Multiple Filters in Pandas

24 Jan, 2021
In this article, we are going to select rows using multiple filters in pandas. We will select multiple rows in pandas using multiple conditions, logical operators and using loc() function.
Selecting rows with logical operators i.e. AND and OR can be achieved easily with a combination of >, <, <=, >= and == to extract rows with multiple filters. loc() is primarily label based, but may also be used with a boolean array to access a group of rows and columns by label or a boolean array.
Dataset Used:
Creating a dataframe with columns Name, Class, Marks in English, Marks in Maths, and Marks in History. We are going to use the below dataset for all operations:   
Python
import pandas as pd  # initialize list of listsdata = [['John', 8, 7, 6, 5], ['Paul', 8, 3, 6, 4],        ['Juli', 9, 10, 9, 9], ['Geeta', 9, 5, 4, 4]]  # Create the pandas DataFramedf = pd.DataFrame(    data, columns=['Name', 'Class', 'English',                    'Maths', 'History'])  # print dataframe.print(df)
Output
Below are various operations which implement the selection of rows with multiple filters:
Selecting row with students having marks is English greater than 6 and marks is maths greater than 8.
Python
df1 = df[(df.English>6) & (df.Maths>8)]print(df1)
Output:
Selecting rows with students having marks in English greater than equal to 5 or marks is history greater than 7.
Python
df1 = df[(df.English>=5) | (df.History>7)]print(df1)
Output
Selecting rows with students of class 9 having marks in English greater than equal to 5 or marks is history greater than 7.
Python
df1 = df[(df.Class == 9) & ((df.English>=5) | (df.History>7))]print(df1)
Output:
Selecting row with students having marks in English less than equal to 5 and marks is maths less than equal to 5 and marks is history less than equal to 5.
Python
df1 = df[(df.English<=5) & (df.Maths<=5) & (df.History<=5)]print(df1)
Output:
Selecting rows with students of class 8 having marks in English less than equal to 5 or marks is maths greater than 5 or marks is history less than equal to 5.
Python
df1 = df[(df.Class == 8) & ((df.English<=5) | (df.Maths>5) | (df.History<=5))]print(df1)
Output:
Selecting rows with loc() having marks in English greater than 6 and marks in maths greater than 6.
Python
df1 = df.loc[(df['English']>6) & (df['Maths']>6)]print(df1)
Output:
Selecting rows with loc() having students marks in English greater than 6 or marks in maths greater than 4. We only display columns with Name and Class.
Python
df1 = df.loc[((df['English']>6) | (df['Maths']>4)),['Name','Class']]print(df1)
Output:
Picked
Python Pandas-exercise
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 OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
Recursive Relationships in ER diagrams

10 Jun, 2021
Prerequisite – ER Model A relationship between two entities of a similar entity type is called a recursive relationship. Here the same entity type participates more than once in a relationship type with a different role for each instance. In other words, a relationship has always been between occurrences in two different entities. However, the same entity can participate in the relationship. This is termed a recursive relationship. 
 
Example – Let us suppose that we have an employee table. A manager supervises a subordinate. Every employee can have a supervisor except the CEO and there can be at most one boss for each employee. One employee may be the boss of more than one employee. Let’s suppose that REPORTS_TO is a recursive relationship on the Employee entity type where each Employee plays two roles.
SupervisorSubordinate 
Supervisor
Subordinate 
 
Supervisors and subordinates are called “Role Names”. Here the degree of the REPORTS_TO relationship is 1 i.e. a unary relationship.  
The minimum cardinality of the Supervisor entity is ZERO since the lowest level employee may not be a manager for anyone.
The maximum cardinality of the Supervisor entity is N since an employee can manage many employees.
Similarly, the Subordinate entity has a minimum cardinality of ZERO to account for the case where CEO can never be a subordinate.
Its maximum cardinality is ONE since a subordinate employee can have at most one supervisor.
Note – Here none of the participants have total participation since both minimum cardinalities are Zero. Hence, the relationships are connected by a single line instead of a double line in the ER diagram. 
To implement a recursive relationship, a foreign key of the employee’s manager number would be held in each employee record. A Sample table would look something like this:- 
Emp_entity( Emp_no,Emp_Fname, Emp_Lname, Emp_DOB, Emp_NI_Number, Manager_no);

Manager no - (this is the employee no of the employee's manager)
This article is contributed by Siddhant Bajaj 2. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. 
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
magbene
vaibhavsinghtanwar
DBMS
GATE CS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL | Join (Inner, Left, Right and Full Joins)
SQL | WITH clause
SQL query to find second highest salary?
CTE in SQL
Difference between Clustered and Non-clustered index
Layers of OSI Model
TCP/IP Model
Types of Operating Systems
Page Replacement Algorithms in Operating Systems
Introduction of Operating System - Set 1
How to convert a string into kebab case using JavaScript ?

01 Apr, 2021
Given a string with space-separated or camel case or snake case letters, the task is to find the kebab case of the following string. 
For examples :
Input:  Geeks For Geeks
Output: geeks-for-geeks

Input:   GeeksForGeeks
Output:  geeks-for-geeks

Input:  Geeks_for_geeks
Output: geeks-for-geeks
This can be achieved by following ways:
Approach 1: By using the replace method
Here we have a function named kebabCase which takes a string and returns a string after converting the kebab case. Here we are using replace method two times because the first replace method is to get all the letters that are near to the uppercase letters and replacing them with a hyphen. And the second replace function is used for getting the spaces and underscores and replacing them with a hyphen. 
Javascript
<script>    const kebabCase = string => string        .replace(/([a-z])([A-Z])/g, "$1-$2")        .replace(/[\s_]+/g, '-')        .toLowerCase();      console.log(kebabCase('Geeks For Geeks'));    console.log(kebabCase('GeeksForGeeks'));    console.log(kebabCase('Geeks_For_Geeks'));</script>
Output:
geeks-for-geeks
geeks-for-geeks
geeks-for-geeks
Approach 2: By using the match method
Here, we use the map method that checks for space, capital letters, and underscores. It creates an array and pushes the words that separate the strings. Now join the array with the hyphen using the join(). After that convert the whole string into a lower case.
Javascript
<script>    const kebabCase = str => str        .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)        .join('-')        .toLowerCase();      console.log(kebabCase('Geeks For Geeks'));    console.log(kebabCase('GeeksForGeeks'));    console.log(kebabCase('Geeks_For_Geeks'));</script>
Output:
geeks-for-geeks
geeks-for-geeks
geeks-for-geeks
JavaScript-Methods
JavaScript-Questions
regular-expression
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
JavaScript String includes() Method
Implementation of LinkedList in Javascript
DOM (Document Object Model)
Installation of Node.js on Linux
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to create footer to stay at the bottom of a Web page?
How to set the default value for an HTML <select> element ?
SAS - Correlation Analysis

Correlation analysis deals with relationships among variables. The correlation coefficient is a measure of linear association between two variables.Values of the correlation coefficient are always between -1 and +1. SAS provides the procedure PROC CORR to find the correlation coefficients between a pair of variables in a dataset.
The basic syntax for applying PROC CORR in SAS is −
PROC CORR DATA = dataset options;
VAR variable;

Following is the description of the parameters used −
Dataset is the name of the dataset.
Dataset is the name of the dataset.
Options is the additional option with procedure like plotting a matrix etc.
Options is the additional option with procedure like plotting a matrix etc.
Variable is the variable name of the dataset used in finding the correlation.
Variable is the variable name of the dataset used in finding the correlation.
Correlation coefficients between a pair of variables available in a dataset can be obtained by use their names in the VAR statement.In the below example we use the dataset CARS1 and get the result showing the correlation coefficients between horsepower and weight.
PROC SQL;
create table CARS1 as
SELECT invoice, horsepower, length, weight
   FROM 
   SASHELP.CARS
   WHERE make in ('Audi','BMW')
;
RUN;

proc corr data = cars1 ;
VAR horsepower weight ;
BY make;
run;

When the above code is executed, we get the following result −
Correlation coefficients between all the variables available in a dataset can be obtained by simply applying the procedure with the dataset name.
In the below example we use the dataset CARS1 and get the result showing the correlation coefficients between each pair of the variables.
proc corr data = cars1 ;
run;

When the above code is executed, we get the following result −
We can obtain a scatterplot matrix between the variables by choosing the option to plot matrix in the PROC statement.
In below example we get the matrix between horsepower and weight.
proc corr data = cars1 plots = matrix ;
VAR horsepower weight ;
run;

When the above code is executed, we get the following result −

    50 Lectures 
     5.5 hours 

 Code And Create

    124 Lectures 
     30 hours 

 Juan Galvan

    162 Lectures 
     31.5 hours 

 Yossef Ayman Zedan

    35 Lectures 
     2.5 hours 

 Ermin Dedic

    167 Lectures 
     45.5 hours 

 Muslim Helalee
 Print
 Add Notes
 Bookmark this page
Python | Get Kth Column of Matrix - GeeksforGeeks

30 Dec, 2020
Sometimes, while working with Python Matrix, one can have a problem in which one needs to find the Kth column of Matrix. This is a very popular problem in Machine Learning Domain and having solution to this is useful. Let’s discuss certain ways in which this problem can be solved.
Method #1 : Using list comprehensionThis problem can be solved using list comprehension in which we can iterate through all the rows and selectively gather all the elements occurring at Kth index.
# Python3 code to demonstrate working of# Get Kth Column of Matrix# using list comprehension  # initialize listtest_list = [[4, 5, 6], [8, 1, 10], [7, 12, 5]]  # printing original listprint("The original list is : " + str(test_list))  # initialize KK = 2  # Get Kth Column of Matrix# using list comprehensionres = [sub[K] for sub in test_list]  # printing resultprint("The Kth column of matrix is : " + str(res))
The original list is : [[4, 5, 6], [8, 1, 10], [7, 12, 5]]
The Kth column of matrix is : [6, 10, 5]

 
Method #2 : Using zip()This task can also be performed using zip(). This does the similar task of gathering elements like is done by above list comprehension and offers compact but slower execution. Works with Python2 only.
# Python code to demonstrate working of# Get Kth Column of Matrix# using zip()  # initialize listtest_list = [[4, 5, 6], [8, 1, 10], [7, 12, 5]]  # printing original listprint("The original list is : " + str(test_list))  # initialize KK = 2  # Get Kth Column of Matrix# using zip()res = list(zip(*test_list)[K])  # printing resultprint("The Kth column of matrix is : " + str(res))
The original list is : [[4, 5, 6], [8, 1, 10], [7, 12, 5]]
The Kth column of matrix is : [6, 10, 5]

Python list-programs
Python matrix-program
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?
PHP | mt_rand( ) Function - GeeksforGeeks

07 Mar, 2018
While working with algorithms we often come across situations when we need to generate random integers. The most common way to generate random numbers is using Mersenne Twister.The Mersenne Twister is a pseudorandom number generator which got its name derived from the fact that its period length is chosen to be a Mersenne prime. It was the first pseudorandom number generator to provide fast generation of high-quality pseudorandom integers. It was designed specifically to rectify most of the flaws found in older pseudorandom number generators.So in PHP, there is an inbuilt function mt_rand() which is based on Mersenne Twister which helps in generating random numbers.
The mt_rand() function generates a random integer between the specified minimum and maximum values. It produces a better random value and is faster than the rand() function. You may also refer to the article on PHP | rand() Function which is another inbuilt function in PHP to generate random numbers.
Syntax:
int mt_rand($min, $max)
Parameters: This function accepts two parameter which are described below:
$min : It is an optional parameter. It specifies the lowest number to be returned.The default value is 0.$max : It is an optional parameter. It specifies the highest number to be returned.
$min : It is an optional parameter. It specifies the lowest number to be returned.The default value is 0.
$max : It is an optional parameter. It specifies the highest number to be returned.
Return Value: It returns a random number between min (or 0) and max and the return type is integer.
Examples:
Input : mt_rand()
Output : 34567

Input : mt_rand(15, 50)
Output : 49

Below programs illustrate the working of mt_rand() in PHP:
Program 1:
<?php  echo mt_rand();  ?>
Output:
34567
Program 2:
<?php  echo mt_rand(15, 50);  ?>
Output:
49
Important points to note :
mt_rand() function generates a random integer using the Mersenne Twister algorithm.
It produces a better random value and is faster than the rand() function.
Reference:http://php.net/manual/en/function.mt-rand.php
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to Upload Image into Database and Display it using PHP ?
How to check whether an array is empty using PHP?
PHP | Converting string to Date and DateTime
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?
How to Convert a String to ArrayList in Java? - GeeksforGeeks

19 Jan, 2021
Converting String to ArrayList means each character of the string is added as a separator character element in the ArrayList.
Example:
Input: 0001
Output: 0
        0
        0
        1
        
Input: Geeks
Output: G
        e
        e
        k
        s
We can easily convert String to ArrayList in Java using the split() method and regular expression.
Parameters:
regex – a delimiting regular expression
Limit – the resulting threshold
Returns: An array of strings computed by splitting the given string.
Throws: PatternSyntaxException – if the provided regular expression’s syntax is invalid.  
Approach:
Splitting the string by using the Java split() method and storing the substrings into an array.
Creating an ArrayList while passing the substring reference to it using Arrays.asList() method.
Java
// Java program to convert String to ArrayList  import java.util.ArrayList;import java.util.Arrays;  public class Main {      public static void main(String[] args)    {          String str = "Geeks";          // split string by no space        String[] strSplit = str.split("");          // Now convert string into ArrayList        ArrayList<String> strList = new ArrayList<String>(            Arrays.asList(strSplit));          // Now print the ArrayList        for (String s : strList)            System.out.println(s);    }}
G
e
e
k
s
Java-ArrayList
Java-Strings
Java
Java Programs
Java-Strings
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
How to Iterate HashMap in Java?
Program to print ASCII Value of a character
Python | sympy.Pow() method - GeeksforGeeks

28 Aug, 2019
With the help of sympy.Pow() method, we can find a raised to the power of b where a and b are parameters to the method.
Syntax: Pow(a, b)Parameter:a – It denotes an integer.b – It denotes an integer.
Returns: Returns an integer which is equal to a raised to the power of b, i. e., a^b.
Example #1:
# import Pow() method from sympyfrom sympy import Pow  a = 3b = 3  # Use Pow() method pow_a_b = Pow(a, b)       print("{}^{} = {}".format(a, b, pow_a_b))
Output:
3^3 = 27

Example #2:
# import Pow() method from sympyfrom sympy import Pow  a = 5b = 4  # Use Pow() method pow_a_b = Pow(a, b)       print("{}^{} = {}".format(a, b, pow_a_b))
Output:
5^4 = 625

SymPy
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
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
Convert integer to string in Python
quit driver method - Selenium Python - GeeksforGeeks

15 May, 2020
Selenium’s Python Module is built to perform automated testing with Python. Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. To open a webpage using Selenium Python, checkout – Navigating links using get method – Selenium Python. Just being able to go to places isn’t terribly useful. What we’d really like to do is to interact with the pages, or, more specifically, the HTML elements within a page. There are multiple strategies to find an element using Selenium, checkout – Locating Strategies. Selenium WebDriver offers various useful methods to control the session, or in other words, browser. For example, adding a cookie, pressing back button, navigating among tabs, etc.
This article revolves around quit driver method in Selenium. quit method quits the driver and closes every associated window.
Syntax –
driver.quit()
Example –Now one can use quit method as a driver method as below –
diver.get("https://www.geeksforgeeks.org/")
driver.quit()

To demonstrate, quit method of WebDriver in Selenium Python. Let’ s visit https://www.geeksforgeeks.org/ and operate on driver object. Let’s quit window,
Program –
# import webdriverfrom selenium import webdriver  # create webdriver objectdriver = webdriver.Firefox()  # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/")    # quit window positiondriver.quit()
Output –Screenshot added –
Python-selenium
selenium
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?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
Rename Columns of a Data Frame in R Programming - rename() Function - GeeksforGeeks

19 Jun, 2020
rename() function in R Language is used to rename the column names of a data frame, based on the older names.
Syntax: rename(x, names)
Parameters:x: Data framenames: Old name and new name
Example 1:
# R program to rename a Data Frame     # Adding Package df <- library(plyr)     # Creating a Data Frame df<-data.frame(row1 = 0:2, row2 = 3:5, row3 = 6:8) print("Original Data Frame") print(df) print("Modified Data Frame")     # Renaming Data Frame rename(df, c("row1"="one", "row2"="two", "row3"="three")) 
Output:
[1] "Original Data Frame"
  row1 row2 row3
1    0    3    6
2    1    4    7
3    2    5    8
[1] "Modified Data Frame"
  one two three
1   0   3     6
2   1   4     7
3   2   5     8

Example 2:
# R program to modify names of a data frame  # Loading librarydf <- library(plyr)  # Creating a data framedf = data.frame(   "col1" = c("abc", "def", "ghi"),   "col2" = c("R", "Python", "Java"),   "col3" = c(22, 25, 45) ) df  # Calling rename() functionrename(df, c("col1" = "Name", "col2" = "Language", "col3" = "Age"))
Output:
  col1   col2 col3
1  abc      R   22
2  def Python   25
3  ghi   Java   45
  Name Language Age
1  abc        R  22
2  def   Python  25
3  ghi     Java  45

R DataFrame-Function
R Language
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
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
R - if statement
How to import an Excel File into R ?
Plot mean and standard deviation using ggplot2 in R
How to filter R dataframe by multiple conditions?
How to use Rating Component in ReactJS ? - GeeksforGeeks

13 Apr, 2021
Rating Component helps capture the user feedback in form of rating. With the help of this feature, users can also rate the products they have purchased. Material UI for React has this component available for us, and it is very easy to integrate. We can use the following approach in ReactJS to use the Rating Component.
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 material-ui module using the following command:npm install @material-ui/core
npm install @material-ui/lab
Step 3: After creating the ReactJS application, Install the material-ui module using the following command:
npm install @material-ui/core
npm install @material-ui/lab
Project Structure: It will look like the following.
Project Structure
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 Rating from '@material-ui/lab/Rating';import Typography from '@material-ui/core/Typography';import Box from '@material-ui/core/Box';  export default function App() {    const [ratingValue, setRatingValue] = React.useState(0);    return (    <div style={{ display: 'block', padding: 30 }}>      <h4>How to use Rating Component in ReactJS?</h4>      <Box component="fieldset" mb={3} borderColor="transparent">        <Typography component="legend">            Please Rate our app        </Typography>        <Rating          name="Rating Label"          value={ratingValue}          onChange={(event, newValue) => {            setRatingValue(newValue);          }}        />      </Box>    </div>  );}
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:
Reference: https://material-ui.com/components/rating/
Material-UI
ReactJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ReactJS useNavigate() Hook
How to set background images in ReactJS ?
Axios in React: A Guide for Beginners
How to create a table in ReactJS ?
How to navigate on path by button click in react router ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
Difference between var, let and const keywords in JavaScript
What does $$ (dollar dollar or double dollar) means in PHP ? - GeeksforGeeks

22 Feb, 2019
The $x (single dollar) is the normal variable with the name x that stores any value like string, integer, float, etc. The $$x (double dollar) is a reference variable that stores the value which can be accessed by using $ symbol before $x value.From the given figure below, it can be easily understood that:
$x stores the value “Geeks” of String type.
Now reference variable $$x stores the value “for Geeks” in it of String type.
So, the value of “for geeks” can be accessed by two ways which are listed below:
By using Reference variable directly. Example: echo $$x;
By using the value stored at variable $x as a variable name for accessing the “for Geeks” value. Example: echo $Geeks; which will give output as “for Geeks” (without quote marks).
Examples:
Input : $x = "Geeks";  
        $$x = for Geeks;  
        echo "$x ";  
        echo "$$x;";   
        echo $Geeks;
Output : Geeks 
         for Geeks
         for Geeks

Input : $x = "Rajnish";  
        $$x = "Noida";  
        echo "$x lives in " . $Rajnish;
Output : Rajnish lives in Noida

Below examples illustrate the use of $ and $$ in PHP:
Example-1:
<?php   // Declare variable and initialize it$x = "Geeks";       // Reference variable$$x = "GeeksforGeeks";  // Display value of xecho $x . "\n";   // Display value of $$x ($Geeks)echo $$x . "\n";   // Display value of $Geeksecho "$Geeks";  ?>
Geeks
GeeksforGeeks
GeeksforGeeks

Example-2:
<?php   // Declare variable and initialize it$var = "Geeks";   // Reference variable${$var}="GeeksforGeeks";   // Use double reference variable${${$var}}="computer science";  // Display the value of variableecho $var . "\n"; echo $Geeks . "\n"; echo $GeeksforGeeks . "\n";   // Double referenceecho ${${$var}}. "\n";   ?> 
Geeks
GeeksforGeeks
computer science
computer science

Picked
PHP
PHP Programs
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to fetch data from localserver database and display on HTML table using PHP ?
How to create admin login page using PHP?
PHP str_replace() Function
How to pass form variables from one page to other page in PHP ?
Different ways for passing data to view in Laravel
How to call PHP function on the click of a Button ?
How to fetch data from localserver database and display on HTML table using PHP ?
How to create admin login page using PHP?
How to pass form variables from one page to other page in PHP ?
PHP | Ternary Operator
HTML5 <dialog> Tag - GeeksforGeeks

17 Mar, 2022
The <dialog> tag is used to specify the dialog box or window. This tag is used to create a popup dialog and models on a web page. This tag is new in HTML5. 
Syntax: 
<dialog open> Contents... </dialog>
Attributes: This tag accepts a single attribute open which is used to specify the dialog element is active and the user can interact with the tag element.Example: 
HTML
<!DOCTYPE html><html>      <body>        <h1><dialog> tag</h1>                <!--This is an open dialog Tag-->        <dialog open>Welcome to GeeksforGeeks</dialog>    </body></html>
Output:  
Supported Browsers: 
Google Chrome 37.0
Firefox 59.0
Opera 24.0
Safari 6.0
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
shubham_singh
shubhamyadav4
HTML-Tags
HTML5
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
How to position a div at the bottom of its container using CSS?
How to change the font size of scientific notation in Matplotlib?

To change the fontsize of scientific notation in matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Set the figure size and adjust the padding between and around the subplots.
Make a list of x and y values.
Make a list of x and y values.
Plot x and y data points using plot() method.
Plot x and y data points using plot() method.
To change the font size of scientific notation, we can use style="sci" class by name.
To change the font size of scientific notation, we can use style="sci" class by name.
To display the figure, use show() method.
To display the figure, use show() method.
from matplotlib import pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

x = [10000, 20000, 300000, 34, 1, 10000]
y = [1, 2, 0, 4, 1, 5]

plt.plot(x, y, color='red')
plt.ticklabel_format(axis="x", style="sci", scilimits=(0, 0))

plt.show()
How to read a cookie using JavaScript?

Following is the code to read a cookie using JavaScript −
Note − A local server would be needed to run this example.
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 18px;
      font-weight: 500;
      color: blueviolet
   }
</style>
</head>
<body>
<h1>Read a cookie using JavaScript</h1>
<div class="result"></div>
<button class="Btn">Click here</button>
<h3>Click on the above button to read the cookie</h3>
<script>
   let BtnEle = document.querySelector(".Btn");
   let resEle = document.querySelector(".result");
   document.cookie = "Name=Rohan Sharma";
   BtnEle.addEventListener("click", () => {
      resEle.innerHTML = document.cookie;
   });
</script>
</body>
</html>
On clicking the ‘CLICK HERE’ button −
Functions that are executed before and after main() in C

Here we will see how to write a code where two functions are present, and one function will be executed before the main function, and another function will be executed after the main function. These features are used to do some startup task before executing the main, and some cleanup task after executing main.
To do this task we have to put attribute for these two functions. When the attribute is constructor attribute, then it will be executed before main(), and when the attribute is destructor type, then it will be executed after main().
#include<stdio.h>
void before_main() __attribute__((constructor));
void after_main() __attribute__((destructor));
void before_main() {
   printf("This is executed before main.\n");
}
void after_main() {
   printf("This is executed after main.");
}
main() {
   printf("Inside main\n");
}
This is executed before main.
Inside main
This is executed after main.
|| operator in Java - GeeksforGeeks

01 Nov, 2020
|| is a type of Logical Operator and is read as “OR OR” or “Logical OR“. This operator is used to perform “logical OR” operation, i.e. the function similar to OR gate in digital electronics.  
One thing to keep in mind is the second condition is not evaluated if the first one is true, i.e. it has a short-circuiting effect. Used extensively to test for several conditions for making a decision.Syntax:  
Condition1 || Condition2

// returns true if one of the conditions is true.

Below is an example to demonstrate || operator:Example:  
Java
// Java program to illustrate// logical OR operator import java.util.*; public class operators {    public static void main(String[] args)    {         char ch = 'a';         // check if character is alphabet or digit        // using || operator        if (ch >= 65 && ch <= 90            || ch >= 97 && ch <= 122)            System.out.println(                ch                + " is an alphabet.");        else if (ch >= 48 && ch <= 57)            System.out.println(                ch                + " is a digit.");        else            System.out.println(                ch                + " is a special character.");    }}
a is an alphabet.



 
user_uxfa
Java-Operators
Picked
Java
Java-Operators
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
HashMap in Java with Examples
Interfaces in Java
Object Oriented Programming (OOPs) Concept in Java
ArrayList in Java
How to iterate any Map in Java
Initialize an ArrayList in Java
Singleton Class in Java
Overriding in Java
Collections in Java
Multithreading in Java
Adding options to a <select> using jQuery?

To add options to a <select>, you need to use append(). Following is the JavaScript code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>

<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<select name="mySelection" id="selectCategory">
<option value="Book">Book</option>
<option value="TV">TV</option>
</select>
<script>
   var mySelection = new Option("Mobile", "Samsung Mobile");
   $(mySelection).html("Samsung Mobile");
   $("#selectCategory").append(mySelection);
</script>
</body>
</html>
To run the above program, save the file name anyName.html(index.html) and right-click on the file and select the option open with live server in VS Code editor.
Syntax Tree – Natural Language Processing

12 Jul, 2021
Natural Language Processing (NLP) is a field of study that deals with understanding, interpreting, and manipulating human spoken languages using computers. Since most of the significant information is written down in natural languages such as English, French, German, etc. thus, NLP helps computers communicate with humans in their own languages and perform other language-related tasks. In conclusion, NLP makes it possible for computers to read the text, hear speech, interpret and realize it, understand the sentiment, and identify important parts of a text or speech.What is Syntax?A natural language typically follows a hierarchical structure, and contains the following components:  
Sentences
Clauses
Phrases
Words
Syntax refers to the set of rules, principles, processes that govern the structure of sentences in a natural language. One basic description of syntax is how different words such as Subject, Verbs, Nouns, Noun Phrases, etc. are sequenced in a sentence.Some of the syntactic categories of a natural language are as follows: 
Sentence(S)
Noun Phrase(NP)
Determiner(Det)
Verb Phrase(VP)
Prepositional Phrase(PP)
Verb(V)
Noun(N)
Syntax Tree: A Syntax tree or a parse tree is a tree representation of different syntactic categories of a sentence. It helps us to understand the syntactical structure of a sentence.Example:The syntax tree for the sentence given below is as follows: I drive a car to my college.  
Code: Syntax Tree in Python  
Python3
# Import required librariesimport nltknltk.download('punkt')nltk.download('averaged_perceptron_tagger')from nltk import pos_tag, word_tokenize, RegexpParser  # Example textsample_text = "The quick brown fox jumps over the lazy dog"  # Find all parts of speech in above sentencetagged = pos_tag(word_tokenize(sample_text))  #Extract all parts of speech from any textchunker = RegexpParser("""                       NP: {<DT>?<JJ>*<NN>}    #To extract Noun Phrases                       P: {<IN>}               #To extract Prepositions                       V: {<V.*>}              #To extract Verbs                       PP: { <p> <NP>}          #To extract Prepositional Phrases                       VP: {<V> <NP|PP>*}      #To extract Verb Phrases                       """) # Print all parts of speech in above sentenceoutput = chunker.parse(tagged)print("After Extracting\n", output)
Output:  
Code: To draw the syntax free for the above sentence  
Python3
# To draw the parse treeoutput.draw()
Output:  
 
gabaa406
Natural-language-processing
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read and Write path in Cassandra

24 Jul, 2020
Prerequisites –
Introduction to Apache Cassandra
Apache Cassandra (NOSQL database)
Architecture of Cassandra
Write Path Execution in Cassandra :
In Cassandra, while writing data, writes are written to any node in the cluster (coordinator).
when any user will insert data, it means they write the data first to commit log then to memtable.
When any user will write the data, every write will include a timestamp.
Once memtable starts getting full then it is flushed to disk periodically (SSTable).
After that a new memtable is created in memory.
In the case of write path execution, deletes are special write cases which are called a tombstone.
Inserting Data :In case of inserting data in Cassandra, we will create a keyspace and then create a table and then insert data into the table.
Example –
// Creating a keyspace
create keyspace UniersityData
replication = {'class': 'SimpleStrategy', 'replication_factor' : '3' };

// Creating a table and declaring the columns
create table CSE_Student(
student_id int,
name text,
email text,
primary key(student_id)
);

// Using the newly created keyspace
use UniersityData;

// Inserting values in the table for all the columns
Insert into CSE_student(student_id, name, email) 
values(012345, 'Ashish', 'ashish@gmail.com');

Insert into CSE_student(student_id, name, email) 
values(012346, 'Abi', 'abi@gmail.com');

Insert into CSE_student(student_id, name, email) 
values(012347, 'Rana', 'rana@gmail.com');

Insert into CSE_student(student_id, name, email) 
values(012348, 'Aayush', 'aayush@gmail.com');

Insert into CSE_student(student_id, name, email) 
values(012349, 'harsh', 'haarsh@gmail.com'); 
Read Path Execution :
In Cassandra while reading data, any server may be queried which acts as the coordinator.
when we want to access read data then we contact nodes with requested key.
In a data center, on each node, data is pulled from SStable and is merged.
In Cassandra, while considering read consistency, we can check –Consistency < ALL performs read repair in the background (read_repair_chance).
Reading Data :Write a cqlsh query to read data from CSE_student and give output for the same.
select * 
from CSE_student;

Output :
Apache
DBMS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Finding Inverse of a Matrix in R Programming - inv() Function - GeeksforGeeks

19 Jun, 2020
inv() function in R Language is used to calculate inverse of a matrix.
Note: Determinant of the matrix must not be zero
Syntax: inv(x)
Parameters:x: Matrix
Example 1:
# R program to calculate # inverse of a matrix  # Loading librarylibrary(matlib)  # Create 3 different vectors. a1 <- c(3, 2, 8) a2 <- c(6, 3, 2) a3 <- c(5, 2, 4)     # Bind the 3 matrices row-wise  # using the rbind() function. A <- rbind(a1, a2, a3)     # find inverse using the inv() function. print(inv(A))
Output:
           [, 1]       [, 2]       [, 3]
[1, ] -0.2857143 -0.2857143  0.7142857
[2, ]  0.5000000  1.0000000 -1.5000000
[3, ]  0.1071429 -0.1428571  0.1071429

Example 2:
# R program to calculate# inverse of a matrix  # Loading Librarylibrary(matlib)  # Creating a matrixA = matrix(c(2, 5, 3, 4, 5, 2, 6, 3, 4), 3, 3)   det(A)  # Calling inv() functioncat("Inverse of A:\n") inv(A)
Output:
[1] -46
Inverse of A:
           [, 1]        [, 2]       [, 3]
[1, ] -0.3043478  0.08695652  0.3913044
[2, ]  0.2391304  0.21739130 -0.5217391
[3, ]  0.1086957 -0.17391304  0.2173913

R Matrix-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Filter data by multiple conditions in R using Dplyr
How to change Row Names of DataFrame in R ?
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
K-Means Clustering in R Programming
Replace Specific Characters in String in R
Remove rows with NA in one column of R DataFrame
How to filter R DataFrame by values in a column?
Python | Pandas Series.shape - GeeksforGeeks

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.shape attribute returns a tuple of the shape of the underlying data for the given series objects.
Syntax:Series.shape
Parameter : None
Returns : shape
Example #1: Use Series.shape attribute to find the shape of the underlying data of the given series object.
# importing pandas as pdimport pandas as pd  # Creating the Seriessr = pd.Series(['New York', 'Chicago', 'Toronto', 'Lisbon', 'Rio'])  # Creating the row axis labelssr.index = ['City 1', 'City 2', 'City 3', 'City 4', 'City 5']   # Print the seriesprint(sr)
Output :
Now we will use Series.shape attribute to find the shape of the underlying data of the given Series object.
# return the shapesr.shape
Output :
As we can see in the output, the Series.shape attribute has returned a tuple indicating the shape of the underlying data of the given series object. Example #2 : Use Series.shape attribute to find the shape of the underlying data of 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.shape attribute to find the shape of the underlying data of the given Series object.
# return the shapesr.shape
Output :As we can see in the output, the Series.shape attribute has returned a tuple indicating the shape of the underlying data of the given series object.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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 | Get unique values from a list
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
Scala Stack toList() method with example - GeeksforGeeks

03 Nov, 2019
In Scala Stack class, the toList() method is utilized to return a list consisting of all the elements of the stack.
Method Definition: def toList: List[A]
Return Type: It returns a list consisting of all the elements of the stack.
Example #1:
// Scala program of toList() // method   // Import Stack import scala.collection.mutable._  // Creating object object GfG {       // Main method     def main(args:Array[String])     {               // Creating stack        val s1 = Stack(1, 2, 3, 4, 5)                   // Print the stack         println(s1)                    // Applying toList method          val result = s1.toList                  // Display output         print("Elements in the list: ")                     for(elem <- result)             print(elem + " ")              } } 
Stack(1, 2, 3, 4, 5)
Elements in the list: 1 2 3 4 5

Example #2:
// Scala program of toList() // method   // Import Stack import scala.collection.mutable._  // Creating object object GfG {       // Main method     def main(args:Array[String])     {               // Creating stack        val s1 = Stack(5, 2, 13, 7, 1)                   // Print the stack         println(s1)                    // Applying toList method          val result = s1.toList                  // Display output         print("Elements in the list: ")                     for(elem <- result)             print(elem + " ")              } } 
Stack(5, 2, 13, 7, 1)
Elements in the list: 5 2 13 7 1

Scala
scala-collection
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Type Casting in Scala
Class and Object in Scala
Scala Lists
Scala Tutorial – Learn Scala with Step By Step Guide
Operators in Scala
Scala Constructors
Scala String substring() method with example
Scala | Arrays
How to get the first element of List in Scala
Lambda Expression in Scala