code-rag-bench/online-tutorials huggingface dataset:
JavaScript String split() Method

17 May, 2022
Below is the example of the String split() Method.  
Example:  
JavaScript
<script>// JavaScript Program to illustrate split() function function func() {    //Original string    var str = 'Geeks for Geeks'    var array = str.split("for");    document.write(array);} func();</script>
Output:  
Geeks , Geeks
str.split() method is used to split the given string into array of strings by separating it into substrings using a specified separator provided in the argument.Syntax:  
str.split(separator, limit)
 
separator: It is used to specified the character, or the regular expression, to use for splitting the string. If the separator is unspecified then the entire string becomes one single array element. The same also happens when the separator is not present in the string. If the separator is an empty string (“”) then every character of the string is separated.
limit: Defines the upper limit on the number of splits to be found in the given string. If the string remains unchecked after the limit is reached then it is not reported in the array.
Return value This function returns an array of strings that is formed after splitting the given string at each point where the separator occurs.Examples for the above function are provided below:Example 1:  
var str = 'It iS a 5r&e@@t Day.'
var array = str.split(" ");
print(array);
Output:  
[It,iS,a,5r&e@@t,Day.]
In this example the function split() creates an array of strings by splitting str wherever ” “ occurs.Example 2:  
var str = 'It iS a 5r&e@@t Day.'
var array = str.split(" ",2);
print(array);
Output:  
[It,iS]
In this example the function split() creates an array of strings by splitting str wherever ” “ occurs. The second argument 2 limits the number of such splits to only 2.Codes for the above function are provided below:Program 1: 
JavaScript
<script>// JavaScript Program to illustrate split() function function func() {    //Original string    var str = 'It iS a 5r&e@@t Day.'    var array = str.split(" ");    document.write(array); } func();</script>
Output:  
[It,iS,a,5r&e@@t,Day.]
Program 2: 
JavaScript
<script>// JavaScript Program to illustrate split() function function func() {     // Original string    var str = 'It iS a 5r&e@@t Day.'     // Splitting up to 2 terms    var array = str.split(" ",2);    document.write(array);} func();</script>
Output:  
[It,iS]
Supported Browser:
Chrome 1 and above
Edge 12 and above
Firefox 1 and above
Internet Explorer 4 and above
Opera 3 and above
Safari 1 and above  
JavaScript is best known for web page development but it is also used in a variety of non-browser environments. You can learn JavaScript from the ground up by following this JavaScript Tutorial and JavaScript Examples.
 
shubham_singh
ysachin2314
surinderdawra388
JavaScript-Methods
javascript-string
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to create a temperature converter with HTML and JavaScript?

To create a temperature converter with HTML and JavaScript, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
   body{
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
   }
   input,span{
      font-size: 20px;
   }
</style>
</head>
<body>
<h1>Temperature Converter</h1>
<h2>Type Temperature in celcius to convert it into fahrenheit</h2>
<p>
<label>Celcius</label>
<input id="inputKG" type="number" placeholder="Celcius"
oninput="CtoFConverter(this.value)" onchange="CtoFConverter(this.value)">
</p>
<p>Fahrenheit: <span class="fahrenheit"></span></p>
<script>
   function CtoFConverter(temp) {
      document.querySelector(".fahrenheit").innerHTML=(temp-32)/1.8;
   }
</script>
</body>
</html>
The above code will produce the following output −
On entering temperature in celcius −
How to Disable Browser Back Button using jQuery ? - GeeksforGeeks

10 Aug, 2021
While working with some privacy-related projects, we have to make sure that our programming doesn’t have any kind of loopholes. In this article, we will see how we can disable the back button of the browser intentionally so that users cannot get back and access the content. We have many scenarios where we could use this kind of functionality. 
For example, in the payment gateways pages, we can disable the back button so that if the user unintentionally clicks on the back button the payment does not get canceled. For implementing this feature on our page we will toggle through two pages and after that, we will restrict users to get back on the first page.
Example: Create two HTML files in the same folder as we use page1.html and page2.html. In page1.html, add the following code.
index.html
<!DOCTYPE html><html>  <head>    <title>Disabling browser back button</title>    <script src=        "https://code.jquery.com/jquery-3.6.0.min.js"         integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="         crossorigin="anonymous">    </script></head>  <body>    <a href="test2.html">Next page</a>      <script>        $(document).ready(function() {            function disableBack() {                window.history.forward()            }            window.onload = disableBack();            window.onpageshow = function(e) {                if (e.persisted)                    disableBack();            }        });    </script></body>  </html>
 
On the second page, page2.html add the following code. The second page could be anything, first page is important because we are using the script on the first page.
test2.html
<!DOCTYPE html><html>  <body>    Click on back button of browser or     use the backspace key on keyboard.</body>  </html>
Output:
You can also block the browser’s back button by using Vanilla JavaScript for that you can follow this How to stop the browser back button using JavaScript article.
jQuery-Methods
jQuery-Questions
Picked
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
jQuery | ajax() Method
How to prevent Body from scrolling when a modal is opened using jQuery ?
How to get a DOM Element from a jQuery Selector ?
How to get the value in an input text box using jQuery ?
How to generate a simple popup using jQuery ?
Installation of Node.js on Linux
Roadmap to Become a Web Developer in 2022
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to match one of the two given expressions using Java RegEx?

Using the or logical operator | of Java regular expressions you can match either of two given expressions.
For example, if you need your regular expression should match more than one expression you can do so by separating the required expressions by “|”.
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
   public static void main(String args[]) {
      //Reading String from user
      System.out.println("Enter a String");
      Scanner sc = new Scanner(System.in);
      String input = sc.nextLine();
      //Regular expression to match string that starts with hello or ends with bye
      String regex = "^hello|bye$";
      //Compiling the regular expression
      Pattern pattern = Pattern.compile(regex);
      //Retrieving the matcher object
      Matcher matcher = pattern.matcher(input);
      if(matcher.find()) {
         System.out.println("Match occurred");
      } else {
         System.out.println("Match not occurred");
      }
   }
}
Enter a String
hello how are you
Match occurred
Enter a String
This is a sample string
Match not occurred
import java.util.Scanner;
public class RegexExample {
   public static void main( String args[] ) {
      //Regular expression to match either yes or no String regex = "yes|no";
      System.out.println("Enter input value: ");
      Scanner sc = new Scanner(System.in);
      String input = sc.nextLine();
      boolean bool = input.matches(regex);
      if(bool) {
         System.out.println("match occurred");
      } else {
         System.out.println("match not accepted");
      }
   }
}
Enter input value:
yes
match occurred
Enter input value:
hello
match not accepted
Create a temporary table in a MySQL procedure?

To create a temporary table in a MySQL procedure, following is the syntax −
CREATE PROCEDURE yourProcedureName()
   BEGIN
      CREATE TEMPORARY TABLE yourTemporaryTableName SELECT yourValue;
   END
Let us implement the above syntax to create a temporary table and insert some records in the table. Following is the query to create a stored procedure and a temporary table in it −
mysql> DELIMITER //
mysql> CREATE PROCEDURE create_Temporary_Table()
   -> BEGIN
   ->    CREATE TEMPORARY TABLE tmpDemoTable SELECT 500;
   -> END//
Query OK, 0 rows affected (0.15 sec)
Following is the query to insert record in the table −
mysql> CREATE PROCEDURE insert_Record_InTempTable()
   -> BEGIN
   ->    INSERT INTO tmpDemoTable VALUES (300);
   -> END//
Query OK, 0 rows affected (0.06 sec)
mysql> DELIMITER
Now you can call the above stored procedure to create a temporary table −
mysql> call create_Temporary_Table();
Query OK, 1 row affected (0.00 sec)

mysql> call insert_Record_InTempTable();
Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select *from tmpDemoTable;
This will produce the following output −
+-----+
| 500 |
+-----+
| 500 |
| 300 |
+-----+
2 rows in set (0.00 sec)
C++ Program to Check Leap Year

A leap year contains one additional day that is added to keep the calendar year synchronized with the astronomical year.
A year that is divisible by 4 is known as a leap year. However, years divisible by 100 are not leap years while those divisible by 400 are.
The program that checks if a year is leap year or not is as follows −
 Live Demo
#include<iostream>
using namespace std;
int main() {
   int year = 2016;
   if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
   cout<<year<<" is a leap year";
   else
   cout<<year<<" is not a leap year";
   return 0;
}
2016 is a leap year
In the above program, if a year is divisible by 4 and not divisible by 100, then it is a leap year. Also, if a year is divisible by 400, it is a leap year.
This is demonstrated by the following code snippet.
if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
cout<<year<<" is a leap year";
else
cout<<year<<" is not a leap year";
The program to check if a year is leap year or not can also be written using nested if statements. This is given as follows −
 Live Demo
#include <iostream>
using namespace std;
int main() {
   int year = 2020;
   if (year % 4 == 0) {
      if (year % 100 == 0) {
         if (year % 400 == 0)
         cout << year << " is a leap year";
         else
         cout << year << " is not a leap year";
      } else
      cout << year << " is a leap year";
   } else
   cout << year << " is not a leap year";
   return 0;
}
2020 is a leap year
In the above program, if the year is divisible by 4, then it is checked if it is divisible by 100. If it is divisible by 100, then it is checked if it is divisible by 400. It yes, then the year is a leap year.Otherwise, it is not. If the year is not divisible by 100, it is a leap year. If the year is not divisible by 4, it is not a leap year.
This is demonstrated by the following code snippet −
if (year % 4 == 0) {
   if (year % 100 == 0) {
      if (year % 400 == 0)
      cout << year << " is a leap year";
      else
      cout << year << " is not a leap year";
   } else
   cout << year << " is a leap year";
} else
cout << year << " is not a leap year";
How to save pyttsx3 results to MP3 or WAV file? - GeeksforGeeks

25 Feb, 2021
In this article, we will see how to generate and save pyttsx3 results as mp3 and wav file. Pyttsx3 is a python module that provides a Text to Speech API. We can use this API to convert the text into voice. 
To use pyttsx3 we have to install espeak and ffmpeg first.
sudo apt update
sudo apt install espeak
sudo apt install ffmpeg
Additionally, we need to install the latest version of pyttsx3
python3 -m pip install pyttsx3
We can confirm the installation by importing the module.
import pyttsx3
If the above statement runs without error, the environment setup is successful.
First, we have to initialize the pyttsx3 engine. The init() method does that for us.
Next, we need to create a string with the text we want to convert to audio.
The say() method takes the string as a parameter. It will set the string it has to speak.
Since the speech will take a while to play on the speaker of the machine, we need to wait for the process to complete. Hence, we need to call the runAndWait() method in order to let the interpreter stop the execution till then.
Below is the code for the above steps:
Python3
# Import the required moduleimport pyttsx3  # Create a stringstring = "Lorem Ipsum is simply dummy text " \    + "of the prting and typesetting industry."  # Initialize the Pyttsx3 engineengine = pyttsx3.init()  # Command it to speak the given stringengine.say(string)  # Wait until above command is not finished.engine.runAndWait()
Output:
Note that we need to have ffmpeg in our system. So make sure that the environment setup was done correctly.
Pyttsx3 comes with a save_to_file() method which takes the text to speak and the file path as an argument.
This method saves the given file in the path. However, this module is in development state, so in some operating systems, the volume and rate options may not work properly.
We have to keep the library updated to its latest version. Install the module using:
sudo apt install git
python3 -m pip install git+https://github.com/nateshmbhat/pyttsx3
This will directly install the latest version available.
Below is the code to do the same:
Python3
# Import the required moduleimport pyttsx3  # Create a stringstring = "Lorem Ipsum is simply dummy text " \    + "of the prting and typesetting industry."  # Initialize the Pyttsx3 engineengine = pyttsx3.init()  # We can use file extension as mp3 and wav, both will workengine.save_to_file(string, 'speech.mp3')  # Wait until above command is not finished.engine.runAndWait()
Output:
Picked
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Pandas dataframe.groupby()
Defaultdict in Python
Python | Get unique values from a list
Python Classes and Objects
Python | os.path.join() method
Create a directory in Python
Why MySQL NOT NULL shouldn’t be added to primary key field?

You do not need to add NOT NULL to primary key field because it gets NOT NULL automatically. Primary key is combination of both NOT NULL and Unique Key.
Here is the demo of primary key field. Let us first create a table. The query to create a table is as follows:
mysql> create table NotNullAddDemo
   -> (
   -> Id int AUTO_INCREMENT,
   -> PRIMARY KEY(Id)
   -> );
Query OK, 0 rows affected (0.81 sec)
In the above table, you do not need to add NOT NULL to primary key field because MySQL internally converts it into NOT NULL. To check if it is correct or not, use the following syntax.
DESC yourTableName;
Let us now check the above syntax to get the table description:
mysql> desc NotNullAddDemo;
The following is the output:
+-------+---------+------+-----+---------+----------------+
| Field | Type    | Null | Key | Default | Extra          |
+-------+---------+------+-----+---------+----------------+
| Id    | int(11) | NO   | PRI | NULL    | auto_increment |
+-------+---------+------+-----+---------+----------------+
1 row in set (0.07 sec)
Look at the column Null, there is a value NO that means there is no NULL value.
To check for NOT NULL, let us insert some NULL records in the table. This will allow NULL value but every time it counts the value from 1. The query to insert records in the table.
mysql> insert into NotNullAddDemo values(NULL);
Query OK, 1 row affected (0.12 sec)
mysql> insert into NotNullAddDemo values(NULL);
Query OK, 1 row affected (0.45 sec)
After inserting two NULL values for primary key, if you try to insert value 1, then an error will generate. This is because MySQL counts first NULL value as 1 and second NULL value as 2 and so on.
The error is as follows if you will now try to insert 1:
mysql> insert into NotNullAddDemo values(1);
ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'
If you insert value 3 then it will accept:
mysql> insert into NotNullAddDemo values(3);
Query OK, 1 row affected (0.21 sec)
mysql> insert into NotNullAddDemo values(NULL);
Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement. The query is as follows:
mysql> select *from NotNullAddDemo;
The following is the output:
+----+
| Id |
+----+
|  1 |
|  2 |
|  3 |
|  4 |
+----+
4 rows in set (0.00 sec)
SOAP - Examples

In the example below, a GetQuotation request is sent to a SOAP Server over HTTP. The request has a QuotationName parameter, and a Quotation will be returned in the response.
The namespace for the function is defined in http://www.xyz.org/quotation address.
Here is the SOAP request −
POST /Quotation HTTP/1.0
Host: www.xyz.org
Content-Type: text/xml; charset = utf-8
Content-Length: nnn

<?xml version = "1.0"?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope"
   SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">

   <SOAP-ENV:Body xmlns:m = "http://www.xyz.org/quotations">
      <m:GetQuotation>
         <m:QuotationsName>MiscroSoft</m:QuotationsName>
      </m:GetQuotation>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
A corresponding SOAP response looks like −
HTTP/1.0 200 OK
Content-Type: text/xml; charset = utf-8
Content-Length: nnn

<?xml version = "1.0"?>
<SOAP-ENV:Envelope
   xmlns:SOAP-ENV = "http://www.w3.org/2001/12/soap-envelope"
   SOAP-ENV:encodingStyle = "http://www.w3.org/2001/12/soap-encoding">

   <SOAP-ENV:Body xmlns:m = "http://www.xyz.org/quotation">
      <m:GetQuotationResponse>
         <m:Quotation>Here is the quotation</m:Quotation>
      </m:GetQuotationResponse>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

    8 Lectures 
     4 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
MongoDB query to set user defined variable into query?

For user-defined variables, use var keyword in MongoDB. Let us create a collection with documents −
> db.demo327.insertOne({"FirstName":"Chris","LastName":"Brown"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e516952f8647eb59e562076")
}
> db.demo327.insertOne({"FirstName":"David","LastName":"Miller"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e51695af8647eb59e562077")
}
> db.demo327.insertOne({"FirstName":"John","LastName":"Doe"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e516962f8647eb59e562078")
}
> db.demo327.insertOne({"FirstName":"John","LastName":"Smith"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e516968f8647eb59e562079")
}
Display all documents from a collection with the help of find() method −
> db.demo327.find();
This will produce the following output −
{ "_id" : ObjectId("5e516952f8647eb59e562076"), "FirstName" : "Chris", "LastName" : "Brown" }
{ "_id" : ObjectId("5e51695af8647eb59e562077"), "FirstName" : "David", "LastName" : "Miller" }
{ "_id" : ObjectId("5e516962f8647eb59e562078"), "FirstName" : "John", "LastName" : "Doe" }
{ "_id" : ObjectId("5e516968f8647eb59e562079"), "FirstName" : "John", "LastName" : "Smith" }
Following is how to set a user-defined variable into the query −
> var name="John";
> db.demo327.find({"FirstName":name});
This will produce the following output −
{ "_id" : ObjectId("5e516962f8647eb59e562078"), "FirstName" : "John", "LastName" : "Doe" }
{ "_id" : ObjectId("5e516968f8647eb59e562079"), "FirstName" : "John", "LastName" : "Smith" }
C# Trim() Method

The Trim() method in C# is used to return a new string in which all leading and trailing occurrences of a set of specified characters from the current string are removed.
public string Trim ();
public string Trim (params char[] trimChars);
Above, the trimChars parameter is an array of Unicode characters to remove, or null.
 Live Demo
using System;
using System.Globalization;
public class Demo {
   public static void Main(String[] args) {
      string str1 = " JackSparrow!";
      string str2 = " @#$PQRSTUV!";
      Console.WriteLine("String1 = "+str1);
      Console.WriteLine("String1 (after trim) = "+str1.Trim());
      Console.WriteLine("String1 ToUpper = "+str1.ToUpper(new CultureInfo("en-US", false)));
      Console.WriteLine("String1 Substring from index4 = " + str1.Substring(2, 2));
      Console.WriteLine("\n\nString2 = "+str2);
      Console.WriteLine("String2 ToUpper = "+str2.ToUpper(new CultureInfo("en-US", false)));
      Console.WriteLine("String2 Substring from index2 = " + str2.Substring(0, 5));
   }
}
String1 =         JackSparrow!
String1 (after trim) = JackSparrow!
String1 ToUpper =         JACKSPARROW!
String1 Substring from index4 =  

String2 =     @#$PQRSTUV!
String2 ToUpper =     @#$PQRSTUV!
String2 Substring from index2 =     @
 Live Demo
using System;
public class Demo {
   public static void Main(String[] args) {
      string str = "JackSparrow!";
      char[] arr = { 'J', 'a'};
      Console.WriteLine("String = "+str);
      Console.WriteLine("String (after trim) = " + str.Trim(arr));
   }
}
String = JackSparrow!
String (after trim) = ckSparrow!
Annotate Multiple Lines of Text to ggplot2 Plot in R - GeeksforGeeks

17 Jun, 2021
In this article, we will see how to annotate Multiple Lines of text to ggplot2 Plot in R programming language. 
Let us first create a regular plot so that the difference is apparent,
Example:
R
# Load Packagelibrary("ggplot2")  # Create a DataFrame DF <- data.frame(X = runif(100, min=0, max=100),                                         Y = runif(100, min=0, max=100))  # Create a ScatterPlot using ggplot2.ggplot(DF,aes(X, Y))+  geom_point(size = 5, fill = "green", color = "black", shape = 21)
Output:
ScatterPlot using ggplot2
Now to annotate multiple lines to the plot annotate() function is used along the regular plot. This function is passed the required value and attributes. The approach is similar to adding a single line to the plot, only difference being each new line should be created by using “\n” within the text that is to be passed to the the plot.
Syntax : annotate(geom, x, y, label)
Parameters :
geom : We assign geom that we want to add to the plot as a first parameter which will written in “” . geom can be anything like rect, segment, pointrange etc. here we will use text as a geom as we want to add text. all other arguments will be depends on geom that we select. So here all other parameters that we will use are only works for Annotating text to plot.
x : Represents the Co-ordinates of X Axis.
y : Represents the Co-ordinates of Y Axis.
label : Text that we want to annotate on plot.
Above threes parameters (i.e x, y and label) are necessary for annotating text but here we will also use two parameters size and color which are used to represent size and color of text respectively and they are not necessary to use.
Return : Geoms on plot.
Example:
R
# Load ggplot2 Packagelibrary("ggplot2")  # Create a DataFrame for PlottingDF <- data.frame(X = runif(100, min=0, max=100),                                         Y = runif(100, min=0, max=100))  # ScatterPlot with Multiple Lines Text on it.ggplot(DF,aes(X, Y))+  geom_point(size = 5, fill = "green", color = "black", shape = 21)+  annotate("text", x = 50, y = 10, label = "Geeks For Geeks\n(R Tutorial)",            size = 10, color = "dark green")
Output:
ScatterPlot with Annotating Multiple Lines on Plot
Picked
R-ggplot
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
Replace Specific Characters in String in R
How to filter R dataframe by multiple conditions?
R - if statement
How to import an Excel File into R ?
How to change the order of bars in bar chart in R ?
Count distinct in Pandas aggregation - GeeksforGeeks

03 Mar, 2021
In this article, let’s see how we can count distinct in pandas aggregation. So to count the distinct in pandas aggregation we are going to use groupby() and add() method.  
groupby(): This method is used to split the data into groups based on some criteria. Pandas objects can be split on any of their axes. We can create a grouping of categories and apply a function to the categories. The abstract definition of grouping is to provide a mapping of labels to group names
agg(): This method is used to pass a function or list of functions to be applied on a series or even each element of series separately. In the case of a list of functions, multiple results are returned by agg() method.
Below are some examples which depict how to count distinct in Pandas aggregation:
Example 1:
Python
# import moduleimport pandas as pdimport numpy as np  # create Data framedf = pd.DataFrame({'Video_Upload_Date': ['2020-01-17',                                         '2020-01-17',                                         '2020-01-19',                                         '2020-01-19',                                         '2020-01-19'],                   'Viewer_Id': ['031', '031', '032',                                 '032', '032'],                   'Watch_Time': [34, 43, 43, 41, 40]})  # print original Dataframeprint(df)  # let's Count distinct in Pandas aggregationdf = df.groupby("Video_Upload_Date").agg(    {"Watch_Time": np.sum, "Viewer_Id": pd.Series.nunique})  # print final outputprint(df)
Output:
Example 2:
Python
# import moduleimport pandas as pdimport numpy as np  # create Data framedf = pd.DataFrame({'Order Date': ['2021-02-22',                                  '2021-02-22',                                  '2021-02-22',                                  '2021-02-24',                                  '2021-02-24'],                   'Product Id': ['021', '021',                                  '022', '022', '022'],                   'Order Quantity': [23, 22, 22,                                      45, 10]})  # print original Dataframeprint(df)  # let's Count distinct in Pandas aggregationdf = df.groupby("Order Date").agg({"Order Quantity": np.sum,                                   "Product Id": pd.Series.nunique})  # print final outputprint(df)
Output:
Picked
Python pandas-groupby
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?
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()
Go Keywords - GeeksforGeeks

03 Feb, 2020
Keywords or Reserved words are the words in a language that are used for some internal process or represent some predefined actions. These words are therefore not allowed to use as an identifier. Doing this will result in a compile-time error.
Example:
// Go program to illustrate the// use of keywordspackage mainimport "fmt"  // Here, package, import, func,// var are keywordsfunc main() {  // Here, a is a valid identifiervar a = "GeeksforGeeks"   fmt.Println(a)  // Here, the default is an// illegal identifier and// compiler will throw an error// var default = "GFG"}
Output:
GeeksforGeeks
There are total 25 keywords present in the Go language as follows:
Example:
// Go program to illustrate // the use of keywords  // Here package keyword is used to // include main package in the programpackage main  // import keyword is used to // import "fmt" in your packageimport "fmt"  // func is used to// create functionfunc main() {      // Here, var keyword is used     // to create variables    // Pname, Lname, and Cname     // are the valid identifiers    var Pname = "GeeksforGeeks"     var Lname = "Go Language"     var Cname = "Keywords"          fmt.Printf("Portal name: %s", Pname)    fmt.Printf("\nLanguage name: %s", Lname)    fmt.Printf("\nChapter name: %s", Cname)  }
Output:
Portal name: GeeksforGeeks
Language name: Go Language
Chapter name: Keywords

Go-Basics
Go-Keywords
Golang
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to concatenate two strings in Golang
6 Best Books to Learn Go Programming Language
time.Sleep() Function in Golang With Examples
strings.Contains Function in Golang with Examples
Time Formatting in Golang
strings.Replace() Function in Golang With Examples
fmt.Sprintf() Function in Golang With Examples
Golang Maps
Different Ways to Find the Type of Variable in Golang
Inheritance in GoLang
Check if a point is inside, outside or on the ellipse in C++

Suppose, one ellipse is given (the center coordinate (h, k) and semi-major axis a, and semi-minor axis b), another point is also given. We have to find whether the point is inside the ellipse or not. To solve it, we have to solve the following equation for the given point (x, y).
(x−h)2a2+(y−k)2b2≤1
If the result is less than one, then the point is inside the ellipse, otherwise not.
 Live Demo
#include <iostream>
#include <cmath>
using namespace std;
bool isInsideEllipse(int h, int k, int x, int y, int a, int b) {
   int res = (pow((x - h), 2) / pow(a, 2)) + (pow((y - k), 2) / pow(b, 2));
   return res;
}
int main() {
   int x = 2, y = 1, h = 0, k = 0, a = 4, b = 5;
   if(isInsideEllipse(h, k, x, y, a, b) > 1){
      cout <<"Outside Ellipse";
   }
   else if(isInsideEllipse(h, k, x, y, a, b) == 1){
      cout <<"On the Ellipse";
   } else{
      cout <<"Inside Ellipse";
   }
}
Inside Ellipse
How to Convert CSV to Excel in Node.js ? - GeeksforGeeks

30 Jun, 2021
NodeJS has become one of the famous backend frameworks for development. So in this article, we’ll see one of its use to convert CSV into Excel
We will use CSVtoExcel npm package to do the conversion of files. It provides convertCsvToXlsx function to implement the conversion.
convertCsvToXlsx(source, destination);
Steps to Implement:
Import path and csv-to-xlsx module.
Specify the source and destination directory and the file name with path module function.
Use try catch block for error detection.
Call the convert function to convert csv to excel function.
Check the destination directory, you’ll see excel file.
Modules Required:
path: This module is used to join the path.
csv-to-xlsx: This module provides functionality to convert csv to excel file.
 
Creating Nodejs Application And Installing Module:
Step 1: Run NPM init in cli and Enter the basic informationnpm init
Step 1: Run NPM init in cli and Enter the basic information
npm init
Step 2:Now, create app.js or index.js or anything in which we’ll implement our functiontouch app.js
Step 2:Now, create app.js or index.js or anything in which we’ll implement our function
touch app.js
Step 3: After creating the Nodejs application, Install the required modules using the following command:npm i path @aternur/csv-to-xlsx
Step 3: After creating the Nodejs application, Install the required modules using the following command:
npm i path @aternur/csv-to-xlsx
Project Structure: It will look like the following.
Report.csv File
Code:
Javascript
// Importing modulesconst path = require('path');const convertCsvToXlsx = require('@aternus/csv-to-xlsx');  // Specifying source directory + file namelet source = path.join(__dirname, 'report.csv');  // Specifying destination directory + file namelet destination = path.join(__dirname, 'converted_report.xlsx');  // try-catch block for handling exceptionstry {      // Functions to convert csv to excel    convertCsvToXlsx(source, destination);} catch (e) {      // Handling error    console.error(e.toString());}
Output:
Excel File:
NodeJS-Questions
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Express.js express.Router() Function
JWT Authentication with Node.js
Express.js req.params Property
Mongoose Populate() Method
Difference between npm i and npm ci in Node.js
Roadmap to Become a Web Developer in 2022
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Convert a string to an integer in JavaScript
C++ | Operator Overloading | Question 3 - GeeksforGeeks

28 Jun, 2021
Which of the following operators are overloaded by default by the compiler in every user defined classes even if user has not written?
1) Comparison Operator ( == )
2) Assignment Operator ( = ) 
(A) Both 1 and 2(B) Only 1(C) Only 2(D) None of the twoAnswer: (C)Explanation: Assign operator is by default available in all user defined classes even if user has not implemented. The default assignement does shallow copy.
But comparison operator “==” is not overloaded.
#include<iostream>
using namespace std;

class Complex {
private:
    int real, imag;
public:
    Complex(int r = 0, int i =0)  {real = r;   imag = i;}
};

int main()
{
    Complex c1(10, 5), c2(2, 4);

    // For example, below code works fine
    c1 = c2;

    // But this code throws compiler error
    if (c1 == c2)
       cout << "Same";

    return 0;
}
Quiz of this Question
C++-Operator Overloading
Operator Overloading
C Language
C++ Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
rand() and srand() in C/C++
Left Shift and Right Shift Operators in C/C++
fork() in C
Command line arguments in C/C++
Function Pointer in C
C++ | Exception Handling | Question 3
C++ | Inheritance | Question 7
C++ | new and delete | Question 4
C++ | Inheritance | Question 1
C++ | Inheritance | Question 11
W3.CSS - Buttons

W3.CSS has a very beautiful and responsive CSS for customizing the look of a button. The following CSS are used −
w3-btn
Represents a standard button. Can be used to style a link as button as well.
w3-btn-floating
Represents a floating button being circular in design.
w3-btn-floating-large
Represents a large floating button.
<html>
   <head>
      <title>The W3.CSS Forms</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://www.w3schools.com/lib/w3.css">
   </head>
   
   <body class = "w3-container">
      <h2>Standard Buttons</h2>
      <button class = "w3-btn">Click Me</button>
      <button class = "w3-btn w3-teal">Click Me</button>
      <button class = "w3-btn w3-disabled">I am disabled</button>
      
      <h2>Links as Buttons</h2>
      <a class = "w3-btn">Link</a>
      <a class = "w3-btn w3-teal">Link</a>
      <a class = "w3-btn w3-disabled">Disabled Link</a>
      
      <h2>Floating Buttons</h2>
      <a class = "w3-btn-floating">+</a>
      <a class = "w3-btn-floating w3-teal">+</a>
      <a class = "w3-btn-floating w3-disabled">+</a>
      
      <h2>Large Floating Buttons</h2>
      <a class = "w3-btn-floating-large">+</a>
      <a class = "w3-btn-floating-large w3-teal">+</a>
      <a class = "w3-btn-floating-large w3-disabled">+</a>
   </body>
</html>
Verify the result.
 Print
 Add Notes
 Bookmark this page
Are array members deeply copied in C++?

In case of C/C++, we can be able to assign a struct (or class in C++ only) variable to another variable of same type. At the time when we assign a struct variable to another, all members of the variable are copied to the other struct variable. In this case the question is arisen what happens when the structure consists of an array?
Now, we have to discuss about arrays. Main point to note is that the array members is not copied as shallow copy; compiler automatically accomplishes Deep Copy in case of array members. In the below program, struct test consists of array member str1[]. When we are able to assign st1 to st2, st2 has a new copy of the array. So st2 is not modified or changed when we modify or change str[] of st1.
 Live Demo
# include <iostream>
# include <string.h>
using namespace std;
struct test{
   char str1[20];
};
int main(){
   struct test st1, st2;
   strcpy(st1.str1, "Tutorial Point");
   st2 = st1;
   st1.str1[0] = 'X';
   st1.str1[1] = 'Y';
   /* Because copy was Deep, both arrays are different */
   cout<< "st1's str = " << st1.str1 << endl;
   cout<< "st2's str = " << st2.str1 << endl;
   return 0;
}
st1's str = XYtorial Point
st2's str = Tutorial Point
Therefore, in case of C++ classes, we don’t require to write our own copy constructor and assignment operator for array members because the default behavior is Deep copy for arrays.
How to remove a function from an object in JavaScript?

JSON.stringify() method not only stringifies an object but also removes any function present in an object. Lets' discuss it in detail.
In the following example, the property 'designation' is a function so when we tried to stringify the object, the function was removed and other properties were displayed as shown in the output.
Live Demo
<html>
<body>
   <p id="stringify"></p>
   <script>
      var person = { name: "Rahim", designation: function () {return developer;},
      city: "Hyderabad" };
      var myJSON = JSON.stringify(person);
      document.getElementById("stringify").innerHTML = myJSON;
   </script>
</body>
</html>
{"name":"Rahim","city":"Hyderabad"}
In the following example, the property 'name' is acting as a function so when we stringify the object using JSON.stringify(), the function was removed and other properties were displayed as shown in the output.
Live Demo
<html>
<body>
   <p id="stringify"></p>
   <script>
      var person = { name: function () {return Ram + Rahim;},
      designation:"Developer" , city: "Hyderabad" };
      var myJSON = JSON.stringify(person);
      document.getElementById("stringify").innerHTML = myJSON;
   </script>
</body>
</html>
{"designation":"Developer","city":"Hyderabad"}
How can we set PRIMARY KEY on multiple columns of an existing MySQL table?

We can set PRIMARY KEY constraint on multiple columns of an existing table by using ADD keyword along with ALTER TABLE statement.
Suppose we have a table ‘Room_allotment’ as follows −
mysql> Create table Room_allotment(Id Int, Name Varchar(20), RoomNo Int);
Query OK, 0 rows affected (0.20 sec)

mysql> Describe Room_allotment;
+--------+-------------+------+-----+---------+-------+
| Field  | Type        | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| Id     | int(11)     | YES  |     | NULL    |       |
| Name   | varchar(20) | YES  |     | NULL    |       |
| RoomNo | int(11)     | YES  |     | NULL    |       |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.11 sec)
Now we can add composite PRIMARY KEY on multiple columns, ‘id’ and ‘Name’, with the following query
mysql> Alter Table Room_allotment ADD PRIMARY KEY(Id, Name);
Query OK, 0 rows affected (0.29 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> Describe Room_allotment;
+--------+-------------+------+-----+---------+-------+
| Field  | Type        | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| Id     | int(11)     | NO   | PRI | 0       |       |
| Name   | varchar(20) | NO   | PRI |         |       |
| RoomNo | int(11)     | YES  |     | NULL    |       |
+--------+-------------+------+-----+---------+-------+
3 rows in set (0.12 sec)
It can be observed from the above result set that PRIMARY KEY has been added on multiple columns.
Joining Excel Data from Multiple files using Python Pandas

17 Aug, 2020
Let us see how to join the data of two excel files and save the merged  data as a new Excel file.
We have 2 files, registration details.xlsx and exam results.xlsx.
registration details.xlsx
We are having 7 columns in this file with 14 unique students details. Column names are as follows :
Admission Date
Name of Student
Gender
DOB
Student email Id
Enquiry No.
Registration No.
exam results.xlsx
We are having 7 columns in this file with 32 unique students’ details. Column names are as follows :
Registration No.
Name
No.of questions attempted
Correct
Incorrect
Marks Obtained
Percentage
You can download these files from these links : registration details.xlsx and exam results.xlsx.
Now, let’s see the common columns between these two files :
So the common column between the excel files is REGISTRATION NO. So we need to merge these two files in such a way that the new excel file will only hold the required columns i.e. :
Algorithm :
Import the Pandas module.Read both the files using the read_excel() function.Combine them using the merge() function.Use the to_excel() function, to create the resultant file.
Import the Pandas module.
Read both the files using the read_excel() function.
Combine them using the merge() function.
Use the to_excel() function, to create the resultant file.
# importing the moduleimport pandas  # reading the filesf1 = pandas.read_excel("registration details.xlsx")f2 = pandas.read_excel("exam results.xlsx")  # merging the filesf3 = f1[["REGISTRATION NO",          "STUDENT EMAIL ID "]].merge(f2[["REGISTRATION NO",                                          "Name", "Marks Obtained",                                          "Percentage"]],                                      on = "REGISTRATION NO",                                      how = "left")  # creating a new filef3.to_excel("Results.xlsx", index = False)
Output :
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Iterate over a list in Python
Python Classes and Objects
Convert integer to string in Python
PostgreSQL - LIMIT Clause

The PostgreSQL LIMIT clause is used to  limit the data amount returned by the SELECT statement.
The basic syntax of SELECT statement with LIMIT clause is as follows −
SELECT column1, column2, columnN
FROM table_name
LIMIT [no of rows]

The following is the syntax of LIMIT clause when it is used along with OFFSET clause −
SELECT column1, column2, columnN
FROM table_name
LIMIT [no of rows] OFFSET [row num]

LIMIT and OFFSET allow you to retrieve just a portion of the rows that are generated by the rest of the query.
Consider the table COMPANY having records as follows −
# select * from COMPANY;
 id | name  | age | address   | salary
----+-------+-----+-----------+--------
  1 | Paul  |  32 | California|  20000
  2 | Allen |  25 | Texas     |  15000
  3 | Teddy |  23 | Norway    |  20000
  4 | Mark  |  25 | Rich-Mond |  65000
  5 | David |  27 | Texas     |  85000
  6 | Kim   |  22 | South-Hall|  45000
  7 | James |  24 | Houston   |  10000
(7 rows)
The following is an example, which limits the row in the table according to the number of rows you want to fetch from table −
testdb=# SELECT * FROM COMPANY LIMIT 4;
This would produce the following result −
 id | name  | age | address     | salary
----+-------+-----+-------------+--------
  1 | Paul  |  32 | California  |  20000
  2 | Allen |  25 | Texas       |  15000
  3 | Teddy |  23 | Norway      |  20000
  4 | Mark  |  25 | Rich-Mond   |  65000
(4 rows)

However, in certain situation, you may need to pick up a set of records from a particular offset. Here is an example, which picks up three records starting from the third position −
testdb=# SELECT * FROM COMPANY LIMIT 3 OFFSET 2;
This would produce the following result −
 id | name  | age | address   | salary
----+-------+-----+-----------+--------
  3 | Teddy |  23 | Norway    |  20000
  4 | Mark  |  25 | Rich-Mond |  65000
  5 | David |  27 | Texas     |  85000
MySQL query to find a match and fetch records

To find a match from records, use MySQL IN(). Let us first create a table −
mysql> create table DemoTable
(
   Id int,
   FirstName varchar(20),
   Gender ENUM('Male','Female')
);
Query OK, 0 rows affected (1.73 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(1,'Chris','Male');
Query OK, 1 row affected (0.47 sec)
mysql> insert into DemoTable values(10,'Emma','Female');
Query OK, 1 row affected (1.88 sec)
mysql> insert into DemoTable values(9,'Emma','Male');
Query OK, 1 row affected (0.70 sec)
mysql> insert into DemoTable values(11,'Isabella','Female');
Query OK, 1 row affected (0.46 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------+-----------+--------+
| Id   | FirstName | Gender |
+------+-----------+--------+
|    1 | Chris     | Male   |
|   10 | Emma      | Female |
|    9 | Emma      | Male   |
|   11 | Isabella  | Female |
+------+-----------+--------+
4 rows in set (0.00 sec)
Following is the query to find match and fetch records with Id 1 and 11 −
mysql> select *from DemoTable where Id IN(1,11);
This will produce the following output −
+------+-----------+--------+
| Id   | FirstName | Gender |
+------+-----------+--------+
|    1 | Chris     | Male   |
|   11 | Isabella  | Female |
+------+-----------+--------+
2 rows in set (0.00 sec)
How to scroll the Page up or down in Selenium WebDriver using java?

We can scroll the page up or down in Selenium webdriver using Java. This is achieved with the help of the Actions class. First of all, we have to create an object of this Actions class and then apply the sendKeys method to it.
Now, to scroll down a page, we have to pass the parameter Keys.PAGE_DOWN to this method. To again scroll up a page, we have to pass the parameter Keys.PAGE_UP to the sendKeys method. Finally, we have to use the build and perform methods to perform this action.
Syntax −
Actions a = new Actions(driver);
//scroll down a page
a.sendKeys(Keys.PAGE_DOWN).build().perform();
//scroll up a page
a.sendKeys(Keys.PAGE_UP).build().perform();
Code Implementation
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Keys;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
public class ScrollUpDownActions{
   public static void main(String[] args) {
      System.setProperty("webdriver.gecko.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\geckodriver.exe");
      WebDriver driver = new FirefoxDriver();

      //implicit wait
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

      //URL launch
      driver.get("https://www.tutorialspoint.com/index.htm");

      // object of Actions class to scroll up and down
      Actions at = new Actions(driver);
      at.sendKeys(Keys.PAGE_DOWN).build().perform();

      //identify element on scroll down
      WebElement l = driver.findElement(By.linkText("Latest Courses"));
      String strn = l.getText();
      System.out.println("Text obtained by scrolling down is :"+strn);
      at.sendKeys(Keys.PAGE_UP).build().perform();

      //identify element on scroll up
      WebElement m = driver.findElement(By.tagName("h4"));
      String s = m.getText();
      System.out.println("Text obtained by scrolling up is :"+s);
      driver.quit();
   }
}
Checking list of all available schema in SAP HANA

This can be checked using below SQL query and it will display all the available schema in HANA system.
select distinct BASE_SCHEMA_NAME from "SYS"."OBJECT_DEPENDENCIES"