code-rag-bench/online-tutorials huggingface dataset:
Python Pandas – Plotting the Autocorrelation Plot

14 Jan, 2022
Pandas can be used to plot the Autocorrelation Plot on a graph. Plotting the Autocorrelation Plot on a graph can be done using the autocorrelation_plot() method of the plotting module. This function generates the Autocorrelation plot for time series.
Autocorrelation plots are a commonly used tool for checking randomness in a data set. This randomness is ascertained by computing autocorrelation for data values at varying time lags. It shows the properties of a type of data known as a time series. These plots are available in most general-purpose statistical software programs. It can be plotted using the pandas.plotting.autocorrelation_plot().
Syntax: pandas.plotting.autocorrelation_plot(series, ax=None, **kwargs)
Parameters:
series: This parameter is the Time series to be used to plot.
ax: This parameter is a matplotlib axes object. Its default value is None.
Returns: This function returns an object of class matplotlip.axis.Axes
Example 1:
Python3
# importing various packageimport pandas as pdimport numpy as npimport matplotlib.pyplot as plt # making Time seriesspacing = np.linspace(-5 * np.pi, 5 * np.pi, num=100)s = pd.Series(0.7 * np.random.rand(100) + 0.3 * np.sin(spacing)) # Creating Autocorrelation plotx = pd.plotting.autocorrelation_plot(s) # plotting the Curvex.plot() # Displayplt.show()
Output:
Example 2:
Python3
# importing various packageimport pandas as pdimport numpy as npimport matplotlib.pyplot as plt # making Time seriesdata = np.array([12.0, 24.0, 7., 20.0,                 7.0, 22.0, 18.0,22.0,                 6.0, 7.0, 20.0, 13.0,                 8.0, 5.0, 8]) # Creating Autocorrelation plotx = pd.plotting.autocorrelation_plot(data) # plotting the Curvex.plot() # Displayplt.show()
Output:
adnanirshad158
Python pandas-plotting
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
D3.js stack() method

09 Sep, 2020
The d3.stack() method constructs a new stack generator with the default settings. This stack generator can be further used to create stacks.
Syntax:
d3.stack()
Parameters: This method takes no parameters.
Return Value: This method returns a new stack generator with the default settings.
Example:
<!DOCTYPE html><html><head>    <meta charset="utf-8">      <script src=        "https://d3js.org/d3.v5.min.js">    </script></head>  <body>    <h1 style="text-align: center; color: green;">        GeeksforGeeks    </h1>      <center>        <canvas id="gfg" width="200" height="200">        </canvas>    </center>      <script>        var data = [              {a: 3840, b: 1920, c: 960, d: 400},              {a: 1600, b: 1440, c: 960, d: 400},              {a:  640, b:  960, c: 640, d: 400},              {a:  320, b:  480, c: 640, d: 400}            ];          var stackGen = d3.stack()            .keys(["a", "b", "c", "d"])            .order(d3.stackOrderNone)            .offset(d3.stackOffsetNone);          var stack = stackGen(data);                  for(var i=0;i<4;i++){            console.log(stack[i]);        }              </script></body>  </html>
Output:
D3.js
HTML
JavaScript
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Design a Tribute Page using HTML & CSS
Build a Survey Form using HTML and CSS
Design a web page using HTML and CSS
Angular File Upload
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
How to append HTML code to a div using JavaScript ?
Difference Between PUT and PATCH Request
C++ Program for Program to find largest element in an array

03 Jun, 2022
Given an array arr of size N, the task is to find the largest element in the given array. 
Example: 
Input: arr[] = {10, 20, 4}Output: 20
Input : arr[] = {20, 10, 20, 4, 100}Output : 100
Approach 1 – Linear Traversal: One of the most simplest and basic approach to solve this problem is to simply traverse the whole list and find the maximum among them. 
Follow the steps below to implement this idea:
Create a local variable max to store the maximum among the list
Initialize max with the first element initially, to start the comparison.
Then traverse the given array from second element till end, and for each element:Compare the current element with maxIf the current element is greater than max, then replace the value of max with the current element.
Compare the current element with max
If the current element is greater than max, then replace the value of max with the current element.
At the end, return and print the value of the largest element of array stored in max.
Below is the implementation of the above approach: 
CPP
// C++ program to find maximum// in arr[] of size n #include <bits/stdc++.h>using namespace std;  int largest(int arr[], int n){    int i;          // Initialize maximum element    int max = arr[0];      // Traverse array elements     // from second and compare    // every element with current max     for (i = 1; i < n; i++)        if (arr[i] > max)            max = arr[i];      return max;}  // Driver Codeint main(){    int arr[] = {10, 324, 45, 90, 9808};    int n = sizeof(arr) / sizeof(arr[0]);    cout << "Largest in given array is " <<              largest(arr, n);    return 0;}  // This Code is contributed by Shivi_Aggarwal
Largest in given array is 9808
Time complexity: O(N), to traverse the Array completely.Auxiliary Space: O(1), as only an extra variable is created, which will take O(1) space.
Approach 2: Using Library Function: Most of the languages have a relevant max() type in-built function to find the maximum element, such as  std::max_element in C++. We can use this function to directly find the maximum element.  
Below is the implementation of the above approach: 
C++
// C++ program to find maximum // in arr[] of size n #include <bits/stdc++.h>using namespace std;  // Returns maximum in arr[] // of size nint largest(int arr[], int n){    return *max_element(arr, arr+n);}  // Driver codeint main(){    int arr[] = {10, 324, 45, 90, 9808};    int n = sizeof(arr)/sizeof(arr[0]);    cout << largest(arr, n);    return 0;}
9808
Time complexity: O(N), since the in-built max_element() function takes O(N) time.Auxiliary Space: O(1), as only an extra variable is created, which will take O(1) space.
Please refer complete article on Program to find largest element in an array for more details!
tamanna17122007
Order-Statistics
Arrays
C++
C++ Programs
Matrix
School Programming
Searching
Arrays
Searching
Matrix
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ISRO | ISRO CS 2015 | Question 14

03 Apr, 2018
A hash table with ten buckets with one slot per bucket is shown in the following figure. The symbols S1 to S7 initially entered using a hashing function with linear probing.The maximum number of comparisons needed in searching an item that is not present is
(A) 4(B) 5(C) 6(D) 3Answer: (B)Explanation:
We have to consider different cases to find the maximum number
 of comparisons needed in searching an item that is not present.
If searching starts at 0 index : 3 comparisons will be made at
 index 0, index 1 and finally at index 2 and terminate searching 
when index 2 found empty.
Similarly after checking on different indexes, the maximum number
of comparisons will be required if searching starts from index 8,
as in this case, total 5 comparisons will be made at index 8, 9, 0, 1 and 2.
So, correct option is (B).
Quiz of this Question
ISRO
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ISRO | ISRO CS 2011 | Question 56
ISRO | ISRO CS 2013 | Question 21
ISRO | ISRO CS 2018 | Question 44
ISRO | ISRO CS 2018 | Question 74
ISRO | ISRO CS 2011 | Question 70
ISRO | ISRO CS 2008 | Question 1
ISRO | ISRO CS 2007 | Question 16
ISRO | ISRO CS 2014 | Question 64
ISRO | ISRO CS 2007 | Question 12
ISRO | ISRO CS 2009 | Question 30
Python | page_source method in Selenium

06 Mar, 2020
page_source method is used retrieve the page source of the webpage the user is currently accessing. The main use of this method to find something in the page source like finding any data or keyword.
Page source : The source code/page source is the programming behind any webpage.
Syntax :
driver.page_source

Argument :
It takes no argument.
Return value :It return the page source in string format.
# importing webdriver from seleniumfrom selenium import webdriver  # Here Chrome will be useddriver = webdriver.Chrome()  # URL of the website url = "https://www.geeksforgeeks.org/"  # Opening the URLdriver.get(url)  # Getting current URL source codeget_source = driver.page_source  # Printing the URLprint(get_source)
Output : This code will print the source code of the “https://www.geeksforgeeks.org/”.
Code 2. When no web page is opened.
# importing webdriver from seleniumfrom selenium import webdriver  # Here Chrome  will be useddriver = webdriver.Chrome()  # Getting current URL source codeget_source = driver.page_source  # Printing the URLprint(get_source)
Output :
Python-selenium
Python
Web Technologies
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()
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 highest salary in MySQL?

For this, you can use MAX(). The syntax is as follows −
select MAX(yourColumnName) AS anyAliasName from yourTableName;
Let us create a table −
mysql> create table demo44
−> (
−> employee_id int not null auto_increment primary key,
−> employee_name varchar(20),
−> employee_salary int
−> )
−> ;
Query OK, 0 rows affected (1.27 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo44(employee_name,employee_salary) values('John',3000);
Query OK, 1 row affected (0.13 sec)

mysql> insert into demo44(employee_name,employee_salary) values('David',4500);
Query OK, 1 row affected (0.12 sec)

mysql> insert into demo44(employee_name,employee_salary) values('Bob',3500);
Query OK, 1 row affected (0.12 sec)

mysql> insert into demo44(employee_name,employee_salary) values('Carol',5500);
Query OK, 1 row affected (0.15 sec)

mysql> insert into demo44(employee_name,employee_salary) values('Mike',4900);
Query OK, 1 row affected (0.13 sec)
Display records from the table using select statement −
mysql> select *from demo44;
This will produce the following output −
+-------------+---------------+-----------------+
| employee_id | employee_name | employee_salary |
+-------------+---------------+-----------------+
| 1           | John          | 3000            |
| 2           | David         | 4500            |
| 3           | Bob           | 3500            |
| 4           | Carol         | 5500            |
| 5           | Mike          | 4900            |
+-------------+---------------+-----------------+
5 rows in set (0.00 sec)
Following is the query to select highest salary −
mysql> select MAX(employee_salary) AS Highest_Salary from demo44;
This will produce the following output −
+----------------+
| Highest_Salary |
+----------------+
|           5500 |
+----------------+
1 row in set (0.00 sec)
Python | Pandas Series.mad() to calculate Mean Absolute Deviation of a Series

30 Sep, 2019
Pandas provide a method to make Calculation of MAD (Mean Absolute Deviation) very easy. MAD is defined as average distance between each value and mean.
The formula used to calculate MAD is:
Syntax: Series.mad(axis=None, skipna=None, level=None)
Parameters:axis: 0 or ‘index’ for row wise operation and 1 or ‘columns’ for column wise operation.skipna: Includes NaN values too if False, Result will also be NaN even if a single Null value is included.level: Defines level name or number in case of multilevel series.
Return Type: Float value
Example #1:In this example, a Series is created from a Python List using Pandas .Series() method. The .mad() method is called on series with all default parameters.
# importing pandas module import pandas as pd     # importing numpy module import numpy as np     # creating listlist =[5, 12, 1, 0, 4, 22, 15, 3, 9]  # creating seriesseries = pd.Series(list)  # calling .mad() methodresult = series.mad()  # displayresult
Output:
5.876543209876543
Explanation:
Calculating Mean of series mean = (5+12+1+0+4+22+15+3+9) / 9 = 7.8888
MAD = | (5-7.88)+(12-7.88)+(1-7.88)+(0-7.88)+(4-7.88)+(22-7.88)+(15-7.88)+(3-7.88)+(9-7.88)) | / 9.00
MAD = (2.88 + 4.12 + 6.88 + 7.88 + 3.88 + 14.12 + 7.12 + 4.88 + 1.12) / 9.00
MAD = 5.8755 (More accurately = 5.876543209876543)
Akanksha_Rai
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.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Convert integer to string in Python
How to draw an ellipse using CSS ?

31 May, 2021
In this article, we will learn how to create an ellipse using CSS. To create an ellipse first we will create a simple rectangle of our desired height and width.
Approach To create Rectangle: In order to create an ellipse of our desired size, we will create a div in HTML and will give it a class named as an ellipse. Now we will set the height and width of the div, it will look like a rectangle. We can set the background color as per our choice.
Below is the implementation to create the rectangle.
HTML
<!DOCTYPE html><html>    <head>    <!-- Adding CSS to the div -->    <style>          /* Setting Height and Width of Rectangle */        .ellipse{            height: 100px;            width: 150px;            background-color: green;        }    </style></head>  <body>      <!-- Create a div -->    <div class="ellipse"></div></body>  </html>
Output:
Rectangle
Approach to Create Ellipse from Rectangle: Now to convert this rectangle into an ellipse, we will set the border-radius refers to a very high value (50% to 100%). It refers to the curvature at the corners of the ​shape. The height of the rectangle will be the minor axis of the ellipse and the width will be the major axis.
HTML
<!DOCTYPE html><html>    <head>      <!-- Adding CSS to the div -->    <style>          /* Setting Height and Width of Rectangle */        .ellipse{            height: 100px;            width: 150px;            background-color: green;              /* Setting Border Radius */            border-radius: 50%;        }    </style></head>  <body>      <!-- Create a div -->    <div class="ellipse"></div></body>  </html>
Output:
Ellipse
CSS-Properties
CSS-Questions
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a Tribute Page using HTML & CSS
How to set space between the flexbox ?
Build a Survey Form using HTML and CSS
Design a web page using HTML and CSS
Form validation using jQuery
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
How to create a table with date column?

To create a table with only date column, you can use DATE type. Let us first create a table −
mysql> create table DemoTable
   (
   StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   StudentName varchar(20),
   StudentAdmissionDate DATE
   );
Query OK, 0 rows affected (0.47 sec)
Insert records in the table using insert command −
mysql> insert into DemoTable(StudentName,StudentAdmissionDate) values('Chris',now());
Query OK, 1 row affected, 1 warning (0.12 sec)
mysql> insert into DemoTable(StudentName,StudentAdmissionDate) values('Robert',curdate());
Query OK, 1 row affected (0.20 sec)
mysql> insert into DemoTable(StudentName,StudentAdmissionDate) values('David','2019-05-21');
Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable;
This will produce the following output −
+-----------+-------------+----------------------+
| StudentId | StudentName | StudentAdmissionDate |
+-----------+-------------+----------------------+
| 1         | Chris       | 2019-04-27           |
| 2         | Robert      | 2019-04-27           |
| 3         | David       | 2019-05-21           |
+-----------+-------------+----------------------+
3 rows in set (0.00 sec)
Node Jimp | Color mix - GeeksforGeeks

23 Apr, 2019
IntroductionThe mix modifier is an inbuilt color modifier in Nodejs | Jimp which mixes colors by their RGB component values and amount is opacity of overlaying color.Syntax:
image.color([
  { apply: 'mix', params: [color : value] }
]);

Parameter:
color – This parameter stores the color to apply.
value – This parameter stores the amount of mix of color to apply.
Input Images:
Example 1:
// npm install --save jimp// import jimp library to the environmentvar Jimp = require('jimp');  // User-Defined Function to read the imagesasync function main() {  const image = await Jimp.read('https://media.geeksforgeeks.org/wp-content/uploads/20190328185307/gfg28.png');// color function having hue modifier  image.color([{apply:'mix', params: ['blue', 60]}])  .write('mix1.png');}   main();  console.log("Image Processing Completed");
Output:Example 2: cb (optional parameters)
// npm install --save jimp// import jimp library to the environmentvar Jimp = require('jimp');  // User-Defined Function to read the imagesasync function main() {  const image = await Jimp.read('https://media.geeksforgeeks.org/wp-content/uploads/20190328185333/gfg111.png');// color function having hue modifier  image.color([{apply:'mix', params: ['green', 50]}], function(err){    if (err) throw err;  })  .write('mix2.png');}  main();  console.log("Image Processing Completed");
Output:Reference: https://www.npmjs.com/package/jimp
Image-Processing
Node-Jimp
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between promise and async await in Node.js
How to use an ES6 import in Node.js?
Mongoose | findByIdAndUpdate() Function
Express.js res.render() Function
Express.js res.redirect() Function
Remove elements from a JavaScript Array
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?
Difference between var, let and const keywords in JavaScript
GATE | GATE-CS-2017 (Set 2) | Question 61 - GeeksforGeeks

09 Sep, 2021
Consider the following database table named top_scorer.
Consider the following SQL query:
SELECT ta.player FROM top_scorer AS ta
WHERE ta.goals > ALL ( SELECT tb.goals
		       FROM top_scorer AS tb
		       WHERE tb.country = 'Spain' )
      AND ta.goals > ANY (SELECT tc.goals
	       	        FROM top_scorer AS tc
		        WHERE tc.country = 'Germany')

The number of tuples returned by the above SQL query is ____.
Note: This questions appeared as Numerical Answer Type.(A) 6(B) 7(C) 8(D) 9Answer: (B)Explanation:  
The query says we need to
Condition 1: Select players which have goals greater than ALL players of Spain – This condition will always be true as ALL (empty) always returns TRUE.ANDCondition 2: Any  player of Germany having 10 goals, so all the rows which are greater than 10 Goals will be returned.
Condition 1: Select players which have goals greater than ALL players of Spain – This condition will always be true as ALL (empty) always returns TRUE.ANDCondition 2: Any  player of Germany having 10 goals, so all the rows which are greater than 10 Goals will be returned.
Condition 1: Select players which have goals greater than ALL players of Spain – This condition will always be true as ALL (empty) always returns TRUE.ANDCondition 2: Any  player of Germany having 10 goals, so all the rows which are greater than 10 Goals will be returned.
Condition 1: Select players which have goals greater than ALL players of Spain – This condition will always be true as ALL (empty) always returns TRUE.AND
Condition 2: Any  player of Germany having 10 goals, so all the rows which are greater than 10 Goals will be returned.
Looking at the table, first 7 rows satisfy both the conditions.
Therefore, option B is true.Quiz of this Question
sagartomar9927
GATE-CS-2017 (Set 2)
GATE-GATE-CS-2017 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE MOCK 2017 | Question 24
GATE | GATE-CS-2006 | Question 47
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
Python Tweepy – Getting the language of a tweet - GeeksforGeeks

21 Jun, 2020
In this article we will see how we can fetch the language of a tweet/status. The lang attribute of the Status object indicates the language of the status. The language is indicated in the language code example, English is en, Hindi is hi.
In order to get the language of the status, we have to do the following :
Identify the status ID of the status from the GUI.Get the Status object of the status using the get_status() method with the status ID.From this object, fetch the lang attribute present in it.
Identify the status ID of the status from the GUI.
Get the Status object of the status using the get_status() method with the status ID.
From this object, fetch the lang attribute present in it.
Example 1 : Consider the following status :
We will use the status ID to fetch the status. The status ID of the above mentioned status is 1272771459249844224.
# import the moduleimport tweepy  # assign the values accordinglyconsumer_key = ""consumer_secret = ""access_token = ""access_token_secret = ""  # authorization of consumer key and consumer secretauth = tweepy.OAuthHandler(consumer_key, consumer_secret)  # set access to user's access key and access secret auth.set_access_token(access_token, access_token_secret)  # calling the api api = tweepy.API(auth)  # the ID of the statusid = 1272771459249844224  # fetching the statusstatus = api.get_status(id)  # fetching the lang attributelang = status.lang   print("The language of the status is : " + lang)
Output :
The language of the status is : en

Example 2 : Consider the following status :
We will use the status ID to fetch the status. The status ID of the above mentioned status is 1273220141417816064.
# the ID of the statusid = 1273220141417816064  # fetching the statusstatus = api.get_status(id)  # fetching the lang attributelang = status.lang   print("The language of the status is : " + lang)
Output :
The language of the status is : hi

Python-Tweepy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
DecimalFormat applyPattern() method in Java - GeeksforGeeks

01 Apr, 2019
The applyPattern() Method of DecimalFormat class in Java is used to apply a given string pattern to this Decimal format. This pattern can be set by the user.
Syntax:
public void applyPattern(String pattern)

Parameters: The method takes one parameter pattern of String type and refers to the pattern which will be used to format the DecimalPattern.
Return Value: The method returns void type.
Below programs illustrate the working of applyPattern() Method:
Program 1:
// Java program to illustrate the// applyPattern method  import java.text.DecimalFormat;  public class Main {    public static void main(String[] args)    {          DecimalFormat deciFormat = new DecimalFormat();          deciFormat.applyPattern("##, ##");        System.out.println(deciFormat.format(-123456789.54321));    }}
-1, 23, 45, 67, 90

Program 2:
// Java program to illustrate the// applyPattern method  import java.text.DecimalFormat;  public class Main {    public static void main(String[] args)    {          DecimalFormat deciFormat = new DecimalFormat();          deciFormat.applyPattern("#, #00.0#");        System.out.println(deciFormat.format(-123456789.54321));    }}
-123, 456, 789.54

Reference: https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html#https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html#applyPattern(java.lang.String)(java.lang.String)
Java-DecimalFormat
Java-Functions
Java-text package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Generics in Java
Different ways of Reading a text file in Java
Internal Working of HashMap in Java
Introduction to Java
Comparator Interface in Java with Examples
Strings in Java
Python | math.sin() function - GeeksforGeeks

20 Mar, 2019
In Python, math module contains a number of mathematical operations, which can be performed with ease using the module. math.sin() function returns the sine of value passed as argument. The value passed in this function should be in radians.
Syntax: math.sin(x)
Parameter:x : value to be passed to sin()
Returns: Returns the sine of value passed as argument
Code #1:
# Python code to demonstrate the working of sin()     # importing "math" for mathematical operations import math     a = math.pi / 6     # returning the value of sine of pi / 6 print ("The value of sine of pi / 6 is : ", end ="") print (math.sin(a)) 
The value of sine of pi/6 is : 0.49999999999999994

 Code #2:
# Python program showing # Graphical representation of # sin() function import mathimport matplotlib.pyplot as plt   in_array = [-3.14159265, -2.57039399, -0.28559933,            0.28559933, 2.57039399,  3.14159265]  out_array = []  for i in range(len(in_array)):    out_array.append(math.sin(in_array[i]))    i += 1     print("in_array : ", in_array) print("\nout_array : ", out_array)   # red for numpy.sin() plt.plot(in_array, out_array, color = 'red', marker = "o") plt.title("math.sin()") plt.xlabel("X") plt.ylabel("Y") plt.show() 
in_array : [-3.14159265, -2.57039399, -0.28559933, 0.28559933, 2.57039399, 3.14159265]
out_array : [-3.5897930298416118e-09, -0.5406408168673427, -0.2817325547837714, 0.2817325547837714, 0.5406408168673427, 3.5897930298416118e-09]
Python math-library-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Explain naming conventions for packages in java? 

While choosing a package name you need to keep the following points in mind.
The name of the package should be in small letters.
It is suggested to start the name of the package with the top level domain level followed by sub domains, ex: com.example.tutorialspoint.
You can declare a package as −
package com.mypackage.tutorialspoint;
Public class Sample{
   Public static void main(String args[]){
      System.out.println("Welcome to Tutorialspoint");
   }
}
You need to compile the file with packages using –d option as −
C:\Sample>javac -d . PackageExample.java
After compiling, you can see the class files of the class created in the location com/mypackage/tutorialspoint.
Day of the Week in C++

Suppose we have a date (day, month and year). From this date, we have to find the day of the week of that given date. To solve this we will use Zeller’s Algorithm. The formula to find weekday using Zeller’s Algorithm is here
w=⟮d+⌊13(m+1)5⌋+y+⌊y4⌋+⌊c4⌋+5c⟯mod7
The formula is containing some variables; They are −
d − The day of the date.
m − It is the month code. For March to December, it is 3 to 12, for January it is 13, and for February it is 14. When we consider January or February, then the given year will be decreased by 1.
y − Last two digits of the year
c − first two digits of the year
w − The weekday. When it is 0, it is Saturday, when it is 6, it means Friday
So for example, if we want to get the weekday of 4th January 1997, then the output will be “Saturday”
The algorithm is as follows −
zellersAlgorithm(day, month, year)
Input − The date of the day.
Output − Which day it was, (Sunday to Saturday).
Begin
   if month > 2, then
      mon := month
   else
      mon := 12 + month
      decrease year by 1
   y := last two digit of the year
   c := first two digit of the year
   w := day + floor((13*(mon+1))/5) + y + floor(y/4) + floor(c/4) + 5*c
   w := w mod 7
   return weekday[w] //weekday will hold days from Saturday to Friday
End
 Live Demo
#include
#include
using namespace std;
string weekday[7] = {"Saturday","Sunday","Monday","Tuesday", "Wednesday","Thursday","Friday"};
string zellersAlgorithm(int day, int month, int year){
   int mon;
   if(month > 2)
      mon = month; //for march to december month code is same as month
   else{
      mon = (12+month); //for Jan and Feb, month code will be 13 and 14
      year--; //decrease year for month Jan and Feb
   }
   int y = year % 100; //last two digit
   int c = year / 100; //first two digit
   int w = (day + floor((13*(mon+1))/5) + y + floor(y/4) + floor(c/4) + (5*c));
   w = w % 7;
   return weekday[w];
}
int main(){
   int day, month, year;
   cout << "Enter Day: "; cin >>day;
   cout << "Enter Month: "; cin >>month;
   cout << "Enter Year: "; cin >>year;
   cout << "It was: " <<zellersAlgorithm(day, month, year);
}
(4, 1, 1997)
Enter Day: 4
Enter Month: 1
Enter Year: 1997
It was: Saturday
Tryit Editor v3.7

Tryit: HTML internal CSS
Variadic Functions in Go

07 Jul, 2021
The function that called with the varying number of arguments is known as variadic function. Or in other words, a user is allowed to pass zero or more arguments in the variadic function. fmt.Printf is the example of the variadic function, it required one fixed argument at the starting after that it can accept any number of arguments. Important Points: 
In the declaration of the variadic function, the type of the last parameter is preceded by an ellipsis, i.e, (...). It indicates that the function can be called at any number of parameters of this type. Syntax:  
function function_name(para1, para2...type)type{
// code...
}
Inside the function ...type behaves like a slice. For example, suppose we have a function signature, i.e, add( b...int)int, now the a parameter of type[]int.
You can also pass an existing slice in a variadic function. To do this, we pass a slice of the complete array to the function as shown in Example 2 below.
When you do not pass any argument in the variadic function, then the slice inside the function is nil.
The variadic functions are generally used for string formatting.
You can also pass multiple slice in the variadic function.
You can not use variadic parameter as a return value, but you can return it as a slice.
Example 1: 
C
// Go program to illustrate the// concept of variadic functionpackage main import(    "fmt"    "strings") // Variadic function to join stringsfunc joinstr(element...string)string{    return strings.Join(element, "-")} func main() {     // zero argument   fmt.Println(joinstr())       // multiple arguments   fmt.Println(joinstr("GEEK", "GFG"))   fmt.Println(joinstr("Geeks", "for", "Geeks"))   fmt.Println(joinstr("G", "E", "E", "k", "S"))    }
Output:  
GEEK-GFG
Geeks-for-Geeks
G-E-E-k-S
Example 2: 
C
// Go program to illustrate the// concept of variadic functionpackage main import(    "fmt"    "strings") // Variadic function to join stringsfunc joinstr(element...string)string{    return strings.Join(element, "-")} func main() {       // pass a slice in variadic function   element:= []string{"geeks", "FOR", "geeks"}   fmt.Println(joinstr(element...))}
Output:  
geeks-FOR-geeks
When we use a Variadic function: 
Variadic function is used when you want to pass a slice in a function.
Variadic function is used when we don’t know the quantity of parameters.
When you use variadic function in your program, it increase the readability of your program.
 
saurabh1990aror
Go-Functions
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
time.Sleep() Function in Golang With Examples
strings.Contains Function in Golang with Examples
strings.Replace() Function in Golang With Examples
fmt.Sprintf() Function in Golang With Examples
Golang Maps
Time Formatting in Golang
Interfaces in Golang
Different Ways to Find the Type of Variable in Golang
How to Parse JSON in Golang?
rename - Unix, Linux Command

For example, given the files
foo1, ..., foo9, foo10, ..., foo278, the commands



rename foo foo0 foo?
rename foo foo0 foo??


will turn them into
foo001, ..., foo009, foo010, ..., foo278. 

And

rename .htm .html *.htm


will fix the extension of your html files.
Rexx - drop

This function is used to un assign a variable.
drop variable_name 

variable_name − The variable which needs to be dropped.
variable_name − The variable which needs to be dropped.
None
/* Main program */ 
options arexx_bifs 
a = 5 
say a 
drop a 
say a 
When we run the above program we will get the following result.
5 
A 

From the output you can see that since the variable a is dropped, it does not have a value assigned to it.
Insertion Sort in C#

Insertion Sort is a sorting algorithm that takes an element at a time and inserts it in its correct position in the array. This process is continued until the array is sorted.
A program that demonstrates insertion sort in C# is given as follows.
 Live Demo
using System;
namespace InsertionSortDemo {
   class Example {
      static void Main(string[] args) {
         int[] arr = new int[10] { 23, 9, 85, 12, 99, 34, 60, 15, 100, 1 };
         int n = 10, i, j, val, flag;
         Console.WriteLine("Insertion Sort");
         Console.Write("Initial array is: ");
         for (i = 0; i < n; i++) {
            Console.Write(arr[i] + " ");
         }
         for (i = 1; i < n; i++) {
            val = arr[i];
            flag = 0;
            for (j = i - 1; j >= 0 && flag != 1; ) {
               if (val < arr[j]) {
                  arr[j + 1] = arr[j];
                  j--;
                  arr[j + 1] = val;
               }
               else flag = 1;
            }
         }
         Console.Write("\nSorted Array is: ");
         for (i = 0; i < n; i++) {
            Console.Write(arr[i] + " ");
         }
      }
   }
}
The output of the above program is as follows.
Insertion Sort
Initial array is: 23 9 85 12 99 34 60 15 100 1
Sorted Array is: 1 9 12 15 23 34 60 85 99 100
Now, let us understand the above program.
First the array is initialized and its value is printed using a for loop. This can be seen in the following code snippet −
int[] arr = new int[10] { 23, 9, 85, 12, 99, 34, 60, 15, 100, 1 };
int n = 10, i, j, val, flag;
Console.WriteLine("Insertion Sort");
Console.Write("Initial array is: ");
for (i = 0; i < n; i++) {
   Console.Write(arr[i] + " ");
}
A nested for loop is used for the actual sorting process. In each pass of the outer for loop, the current element is inserted into its correct position in the array. This process continues until the array is sorted. This can be seen in the following code snippet.
for (i = 1; i < n; i++) {
   val = arr[i];
   flag = 0;
   for (j = i - 1; j >= 0 && flag != 1; ) {
      if (val < arr[j]) {
         arr[j + 1] = arr[j];
         j--;
         arr[j + 1] = val;
      } else flag = 1;
   }
}
Finally, the sorted array is displayed. This can be seen in the following code snippet.
Console.Write("\nSorted Array is: ");
for (i = 0; i < n; i++) {
   Console.Write(arr[i] + " ");
}
GATE | GATE CS 2019 | Question 21

20 Sep, 2021
Which one of the following is NOT a valid identity?
(A) (x ⊕ y) ⊕ z = x ⊕ (y ⊕ z)(B) (x + y) ⊕ z = x ⊕ (y + z)(C) x ⊕ y = x + y, if xy = 0(D) x ⊕ y = (xy + x′y′)′Answer: (B)Explanation: According to Exor (⊕) operation,
Therefore, option (D),
x⊕y 
= (x'y + xy′)
= (x'+y').(x+y)
= (x⊙y)'
= (xy + x′y′)′ 
It also clearly shows that, if atleast one of x and y is 0, then it works as (x+y).
x⊕y = x + y,  if xy = 0
You can notice that it works as (x+y) except last row in given Truth table, because only last row does not satisfy (x.y)=0. So, option (C) is also correct.
Exor (⊕) operation also satisfies associative law, i.e.,
(x ⊕ y) ⊕ z = x ⊕ (y ⊕ z)
So, option (A) is also correct.
But, option (B) is not correct because,
(x+y)⊕z 
= (x+y)'.z + (x+y).z'
= (x'y').z + xz' + yz'

And,
x⊕(y+z)
= x'.(y+z) + x.(y+z)'
= x'y + x'z + x.y'z'

Therefore,
(x+y)⊕z ≠ x⊕(y+z)
YouTube<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=wdK9OisYuEE" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2015 (Set 2) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 20
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2003 | Question 20
GATE | Gate IT 2005 | Question 52
GATE | GATE CS 2011 | Question 49
GATE | GATE-CS-2016 (Set 1) | Question 45
GATE | GATE CS 2011 | Question 4
GATE | GATE-CS-2004 | Question 52
GATE | GATE CS Mock 2018 | Set 2 | Question 30
Zombie and Orphan Processes in C

29 May, 2017
Prerequisite: fork() in C
In the following code, the child finishes its execution using exit() system call while the parent sleeps for 50 seconds, hence doesn’t call wait() and the child process’s entry still exists in the process table.
// A C program to demonstrate Zombie Process. // Child becomes Zombie as parent is sleeping// when child process exits.#include <stdlib.h>#include <sys/types.h>#include <unistd.h>int main(){    // Fork returns process id    // in parent process    pid_t child_pid = fork();      // Parent process     if (child_pid > 0)        sleep(50);      // Child process    else                exit(0);      return 0;}
Note that the above code may not work with online compiler as fork() is disabled.
 
In the following code, parent finishes execution and exits while the child process is still executing and is called an orphan process now.
However, the orphan process is soon adopted by init process, once its parent process dies.
// A C program to demonstrate Orphan Process. // Parent process finishes execution while the// child process is running. The child process// becomes orphan.#include<stdio.h>#include <sys/types.h>#include <unistd.h>  int main(){    // Create a child process          int pid = fork();      if (pid > 0)        printf("in parent process");      // Note that pid is 0 in child process    // and negative if fork() fails    else if (pid == 0)    {        sleep(30);        printf("in child process");    }      return 0;}
Note that the above code may not work with online compilers as fork() is disabled.
Related :Any idea What are Zombies in Operating System?Zombie Processes and their Prevention
This article is contributed by Pranjal Mathur.If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
CPP-Library
system-programming
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Calculate Median in MySQL

14 Jul, 2020
Median :In statistics and probability theory, Median is a value separating the higher half from the lower half of a data sample, a population, or a probability distribution. In lay-man language, Median is the middle value of a sorted listed of values.
Calculate Median value in MySQL –Consider a table demo where Name is the student name and Distance is the total distance (in km) from their home to college.
We calculate the median of the Distance from the demo table.Query –
SET @rowindex := -1;
 
SELECT
   AVG(d.distance) as Median 
FROM
   (SELECT @rowindex:=@rowindex + 1 AS rowindex,
           demo.distance AS distance
    FROM demo
    ORDER BY demo.distance) AS d
WHERE
d.rowindex IN (FLOOR(@rowindex / 2), CEIL(@rowindex / 2));

Explanation :
Beginning with the internal subquery – the select assigns @rowindex as an incremental index for each distance that is selected and sorts the distance.Once we have the sorted list of distances, the outer query will fetch the middle items in the array. If the array contains an odd number of items, both values will be the single middle value.Then, the SELECT clause of the outer query returns the average of those two values as the median value.
Beginning with the internal subquery – the select assigns @rowindex as an incremental index for each distance that is selected and sorts the distance.
Once we have the sorted list of distances, the outer query will fetch the middle items in the array. If the array contains an odd number of items, both values will be the single middle value.
Then, the SELECT clause of the outer query returns the average of those two values as the median value.
Output –
25.0000
mysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to sort a Numpy Array | Python

11 May, 2020
In this article, we will learn how to sort a Numpy array. There are multiple ways in Numpy to sort an array, based on the requirement. Let’s try to understand them with the help of examples.
Example #1: Simply sort the given array based on axis using sort() method.
# importing librariesimport numpy as np   # sort along the first axisa = np.array([[12, 15], [10, 1]])arr1 = np.sort(a, axis = 0)        print ("Along first axis : \n", arr1)              # sort along the last axisa = np.array([[10, 15], [12, 1]])arr2 = np.sort(a, axis = -1)        print ("\nAlong first axis : \n", arr2)      a = np.array([[12, 15], [10, 1]])arr1 = np.sort(a, axis = None)        print ("\nAlong none axis : \n", arr1)
Output:
Along first axis : 
 [[10  1]
 [12 15]]

Along first axis : 
 [[10 15]
 [ 1 12]]

Along none axis : 
 [ 1 10 12 15]


Example #2: Get the indices which can return sorted array using argsort() method
# Python code to demonstrate # working of  numpy.argsortimport numpy as np   # Numpy array createda = np.array([9, 3, 1, 7, 4, 3, 6])   # unsorted array printprint('Original array:\n', a)   # Sort array indicesb = np.argsort(a)print('Sorted indices of original array->', b)   # To get sorted array using sorted indices# c is temp array created of same len as of bc = np.zeros(len(b), dtype = int)for i in range(0, len(b)):    c[i]= a[b[i]]print('Sorted array->', c)
Output:
Original array:
 [9 3 1 7 4 3 6]
Sorted indices of original array-> [2 1 5 4 6 3 0]
Sorted array-> [1 3 3 4 6 7 9]

Example #3: Get stable sort using a sequence of keys.
import numpy as np   # Numpy array created# First columna = np.array([9, 3, 1, 3, 4, 3, 6])   # Second column b = np.array([4, 6, 9, 2, 1, 8, 7]) print('column a, column b')for (i, j) in zip(a, b):    print(i, ' ', j)   # Sort by a then by bind = np.lexsort((b, a)) print('Sorted indices->', ind)
Output:
column a, column b
9   4
3   6
1   9
3   2
4   1
3   8
6   7
Sorted indices-> [2 3 1 5 4 6 0]


Python numpy-program
Python-numpy
Python-sort
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Bypass Anti-virus using Veil Framework

This article is intended to demonstrate, how to bypass the anti-virus detection using the Veil framework, as it is a collection of tools designed for use during penetration testing. It currently consists of the following modules −
Veil-Evasion − a tool to generate antivirus-evading payloads using a variety of techniques and languages
Veil-Catapult − a psexec-style payload delivery system that integrates Veil-Evasion
Veil-PowerView − a powershell tool to gain network situational awareness on Windows domains
Veil-Pillage − a modular post-exploitation framework that integrates Veil-Evasion
To install the Veil- Framework, you are supposed to configure the latest Python packages into your machine.
The important point to remember is that the installation must be done with superuser privileges. If you are not using the root account (as default with Kali Linux), prepend commands with sudo or change to the root user before beginning. The Veil-Framework is a fantastic tool for avoiding payload detection by the anti-virus software. To install it, you first need to download it from Github and perform the following commands.
git clone https://github.com/Veil-Framework/Veil.git cd Veil/
./config/setup.sh --force --silent
Now, select the operation Evasion from the list as following to generate the payload;
To list all the available payloads, select the list option as usual which will display all the available payloads as following −
Now, select your payload using the use command as following; −
Finally, after selecting the payload, select the py2exe option and hit the generate command to generate the desired FUD payload as following;
Here, in the aforesaid image, you can easily see that the runme.bat fully undetectable virus (payload) is generated and stored in the /usr/share.veil-output/source directory.