code-rag-bench/online-tutorials huggingface dataset:
SQL Tryit Editor v1.6

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

To increase the width of axes (both X-axis and Y-axis at the same time) using ggplot2 in
R, we can use theme function with axis.line argument where we can set element_line
argument to a larger value.
Check out the Example given below to understand how it can be done.
Following snippet creates a sample data frame −
x<-sample(0:9,20,replace=TRUE)
y<-sample(0:9,20,replace=TRUE)
df<-data.frame(x,y)
df
The following dataframe is created
   x y
 1 6 9
 2 7 8
 3 1 3
 4 2 4
 5 1 2
 6 2 5
 7 2 4
 8 1 6
 9 4 1
10 7 6
11 0 8
12 9 0
13 9 4
14 1 8
15 6 5
16 7 7
17 0 0
18 6 7
19 1 6
20 6 8
To load ggplot2 package and create scatterplot between x and y on the above created
data frame, add the following code to the above snippet −
x<-sample(0:9,20,replace=TRUE)
y<-sample(0:9,20,replace=TRUE)
df<-data.frame(x,y)
library(ggplot2)
ggplot(df,aes(x,y))+geom_point()
If you execute all the above given snippets as a single program, it generates the following Output −
To create scatterplot between x and y with increased width of both the axes on the
above created data frame, add the following code to the above snippet −
x<-sample(0:9,20,replace=TRUE)
y<-sample(0:9,20,replace=TRUE)
df<-data.frame(x,y)
library(ggplot2)
ggplot(df,aes(x,y))+geom_point()+theme(axis.line=element_line(size=2))
If you execute all the above given snippets as a single program, it generates the following Output −
Lodash - parseInt method

_.parseInt(string, [radix=10])

Converts string to an integer of the specified radix. If radix is undefined or 0, a radix of 10 is used unless value is a hexadecimal, in which case a radix of 16 is used.
[string=''] (string) − The string to convert.
[string=''] (string) − The string to convert.
[radix=10] (number) − The radix to interpret value by.
[radix=10] (number) − The radix to interpret value by.
(number) − Returns the converted integer.
(number) − Returns the converted integer.
var _ = require('lodash');
var result = _.parseInt('010');

console.log(result);

result = _.map(['6', '08', '10'], _.parseInt);
console.log(result);
Save the above program in tester.js. Run the following command to execute this program.
\>node tester.js

10
[ 6, 8, 10 ]

 Print
 Add Notes
 Bookmark this page
C# | Check whether a Hashtable contains a specific key or not - GeeksforGeeks

01 Feb, 2019
Hashtable.Contains(Object) Method is used to check whether the Hashtable contains a specific key or not.
Syntax:
public virtual bool Contains (object key);
Here, key is the Key of Object type which is to be located in the Hashtable.
Return Value: This method returns true if the Hashtable contains an element with the specified key otherwise returns false.
Exception: This method will give ArgumentNullException if the key is null.
Note:
Hashtable.ContainsKey(Object) Method is also used to check whether the Hashtable contains a specific key or not. This method behaves same as Contains() method.
Contains method implements IDictionary.Contains. It behaves exactly as ContainsKey and this method is an O(1) operation.
Below programs illustrate the use of above-discussed method:
Example 1:
// C# code to check whether the Hashtable// contains a specific key or notusing System;using System.Collections;  class GFG {      // Driver code    public static void Main()    {          // Creating a Hashtable        Hashtable myTable = new Hashtable();          // Adding elements in Hashtable        myTable.Add("g", "geeks");        myTable.Add("c", "c++");        myTable.Add("d", "data structures");        myTable.Add("q", "quiz");          // Checking if Hashtable contains        // the key "Brazil"        Console.WriteLine(myTable.Contains("d"));    }}
Output:
True

Example 2:
// C# code to check whether the Hashtable// contains a specific key or notusing System;using System.Collections;  class GFG {      // Driver code    public static void Main()    {          // Creating a Hashtable        Hashtable myTable = new Hashtable();          // Adding elements in Hashtable        myTable.Add("1", "C");        myTable.Add("2", "C++");        myTable.Add("3", "Java");        myTable.Add("4", "Python");          // Checking if Hashtable contains        // the key null. It will give exception        // ArgumentNullException        Console.WriteLine(myTable.Contains(null));    }}
Runtime Error:
Unhandled Exception:System.ArgumentNullException: Key cannot be null.Parameter name: key
Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.collections.hashtable.contains?view=netframework-4.7.2
CSharp-Collections-Hashtable
CSharp-Collections-Namespace
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Destructors in C#
Extension Method in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
Partial Classes in C#
C# | Inheritance
C# | List Class
Difference between Hashtable and Dictionary in C#
C# | Generics - Introduction
How to save a matrix as CSV file using R?

To save a matrix as CSV file using R, we can use write.matrix function of MASS package.
For Example, if we have a matrix called M and we want to save it as CSV file then we can
use the below mentioned command −
write.matrix(M,file="Mat.csv")
Following snippet creates a sample matrix −
M<-matrix(rpois(80,10),ncol=4)
M
The following matrix is created −
   [,1] [,2] [,3] [,4]
 [1,] 10 10   13   4
 [2,] 13  9    6   9
 [3,] 16  9   13  10
 [4,] 12 11   11  13
 [5,] 8   7    8   6
 [6,] 7   6    5  11
 [7,] 9  10    6  12
 [8,] 8   9   10  12
 [9,] 10  6   12   6
[10,] 8   6    8   8
[11,] 5  11   14   9
[12,] 12  7    8  11
[13,] 18  9    9  10
[14,] 7   5    8   7
[15,] 10 12    8  12
[16,] 8   7    8  15
[17,] 9  13   12  11
[18,] 7   9   10   8
[19,] 9   8   10   6
[20,] 12  7   10  10
To load MASS package and save matrix M as CSV file on the above created matrix, add
the following code to the above snippet −
M<-matrix(rpois(80,10),ncol=4)
library(MASS)
write.matrix(M,file="Mat.csv")

If you execute all the above given snippets as a single program, it generates the following Output −
dnssec-keygen command in Linux with Examples - GeeksforGeeks

01 Sep, 2020
dnssec-keygen command is used to generate keys for DNSSEC (DNS Security Extensions). DNSSEC is an extension to the regular DNS (Domain Name System) technology but with added authentication for the DNS data. This authentication is carried out using public key cryptography technique and the above mentioned command produces the public/private key pair.
Syntax:
dnssec-keygen [options] name

Example:
dnssec-keygen gfg.org

In the above example, keys are generated for gfg.org. Since no options are provided, the default algorithm (RSASHA1) is used for generation and the keys are of the default size (1024 bits).
This option specifies the number of bits the key should contain. The size of the key depends upon the algorithm used.
RSA Algorithm: 512-4096 bits
DH Algorithm: 128-4096 bits
DSA Algorithm: 512-1024 bits (multiples of 64)
HMAC Algorithm: 1-512 bits
Example:
dnssec-keygen -b 1024 gfg.org

This option is used to select the crypt algorithm for the key generation. If an algorithm is specified like this, use of the -b to set key size is mandatory. The available algorithms are:
RSAMD5
RSASHA1 (default algorithm)
RSASHA256
RSASHA512
DH
DSA
HMAC-MD5
HMAC-SHA1
HMAC-SHA224
HMAC-SHA256
HMAC-SHA384
HMAC-SHA512
Example:
dnssec-keygen -a RSASHA1 -b 1024 gfg.org
This option is used to specify the owner type of the key. The accepted values are:
ZONE
HOST/ENTITY
USER
Example:
dnssec-keygen -n ZONE gfg.org

This option mandates the creation of the keys using a NSEC3-capable algorithm. NSEC3RSASHA1 will be used by default if no algorithm is mentioned explicitly.
Example:
dnssec-keygen -a RSASHA256 -b 1024 -3 gfg.org

This is used to specify a flag for the generated key. The recognized flags are:
KSK (Key Signing Key)
REVOKE
Example :
dnssec-keygen -a RSASHA256 -b 1024 -f KSK gfg.org

DNS could be partitioned according to the class. This option is used to specify the class that the DNS record should have. If you do not specify anything using this option, IN is used by default. The following are a list of DNS classes:
IN (Internet) – Default Class
CH (CHAOS)
HS (Hesiod)
Example:
dnssec-keygen -c CH gfg.org

This option is used to specify the type of the key. AUTHCONF is used by default if not specified explicitly. The possible types are: 
AUTHCONF
NOAUTHCONF
NOAUTH
NOCONF
Example:
dnssec-keygen -a RSASHA256 -b 1024 -t NOAUTH gfg.org

Linux-networking-commands
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
nohup Command in Linux with Examples
scp command in Linux with Examples
Thread functions in C/C++
mv command in Linux with examples
chown command in Linux with Examples
SED command in Linux | Set 2
Docker - COPY Instruction
Array Basics in Shell Scripting | Set 1
Basic Operators in Shell Scripting
nslookup command in Linux with Examples
Seaborn - Pair Grid

PairGrid allows us to draw a grid of subplots using the same plot type to visualize data.
Unlike FacetGrid, it uses different pair of variable for each subplot. It forms a matrix of sub-plots. It is also sometimes called as “scatterplot matrix”.
The usage of pairgrid is similar to facetgrid. First initialise the grid and then pass the plotting function.
import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
df = sb.load_dataset('iris')
g = sb.PairGrid(df)
g.map(plt.scatter);
plt.show()

It is also possible to plot a different function on the diagonal to show the univariate distribution of the variable in each column.
import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
df = sb.load_dataset('iris')
g = sb.PairGrid(df)
g.map_diag(plt.hist)
g.map_offdiag(plt.scatter);
plt.show()

We can customize the color of these plots using another categorical variable. For example, the iris dataset has four measurements for each of three different species of iris flowers so you can see how they differ.
import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
df = sb.load_dataset('iris')
g = sb.PairGrid(df)
g.map_diag(plt.hist)
g.map_offdiag(plt.scatter);
plt.show()

We can use a different function in the upper and lower triangles to see different aspects of the relationship.
import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
df = sb.load_dataset('iris')
g = sb.PairGrid(df)
g.map_upper(plt.scatter)
g.map_lower(sb.kdeplot, cmap = "Blues_d")
g.map_diag(sb.kdeplot, lw = 3, legend = False);
plt.show()


    11 Lectures 
     4 hours 

 DATAhill Solutions Srinivas Reddy

    11 Lectures 
     2.5 hours 

 DATAhill Solutions Srinivas Reddy
 Print
 Add Notes
 Bookmark this page
Interactive Pivot Tables in Jupyter Notebook | by Satyam Kumar | Towards Data Science

Python has achieved popularity in a short span of time, still, it falls short to interact with data in some cases, that is where excel takes a lead. For the development of a model, the initial steps are data understanding and Exploratory data analysis (EDA).
For EDA you need the ability of flexibility to play around with data. Python falls short in terms of interacting with the data in the case of creating pivot tables. For creating pivot tables, Excel takes a lead, as it comes up with interactive and dynamic development of tables.
Creating a pivot table in pandas is a bit combustion process. The structure of the pivot table needs to be decided in advance and accordingly, the script needs to be developed. To make some manipulation in the pivot table requires changing the code again and run the script. This is a combustion process to generate insights as to proceed with model building.
pd.pivot_table(df,                values='Survived',               index=['Pclass'],               columns=['Sex'],               aggfunc='sum'              )
pd.pivot_table(df,                values='Survived',               index=['Pclass','Embarked'],               columns=['Sex'],               aggfunc='sum'              )
Pivot tables are used to get insights about the data during EDA, to generate pivot tables in pandas, code needs to be manipulated for each table, which makes it a bit of combustion.
Here, PivotTable.js comes into the picture, and it helps to create interactive pivot tables.
PivotTable.js is an open-source Javascript Pivot Table (aka Pivot Grid, Pivot Chart, Cross-Tab) implementation with drag’n’ drop functionality.
pip install pivottablejs
Now trying to generate the same pivot tables as developed using pandas earlier in this article.
PivotTable.js provides the privilege of choosing the aggregate functions from the drop-down list.
Different representations of pivot tables, and heatmaps.
Several types of plots including bar plot, stacked bar plot, line chart, area chart, scatter chart, treemap, etc.
Including PivotTable.js in the workflow enables us to generate insights about the data easily. This library comes up with features to generate several plots from the pivot table in real-time, which enables us to speed up the work during data wrangling.
You can find the GitHub repository for PivotTable.js here.
[1] PivotTable.js Examples:https://pivottable.js.org/examples/
Thank You for Reading
degrees() and radians() in Python - GeeksforGeeks

09 Apr, 2018
degress() and radians() are methods specified in math module in Python 3 and Python 2.
Often one is in need to handle mathematical computation of conversion of radians to degrees and vice-versa, especially in the field of geometry. Python offers inbuilt methods to handle this functionality. Both the functions are discussed in this article.
This function accepts the “degrees” as input and converts it into its radians equivalent.
Syntax : radians(deg)
Parameters :deg : The degrees value that one needs to convert into radians
Returns : This function returns the floating point radians equivalent of argument.Computational Equivalent : 1 Radians = 180/pi Degrees.
 Code #1 : Demonstrating radians()
# Python code to demonstrate# working of radians()  # for radiansimport math  # Printing radians equivalents.print("180 / pi Degrees is equal to Radians : ", end ="")print (math.radians(180 / math.pi))  print("180 Degrees is equal to Radians : ", end ="")print (math.radians(180))  print("1 Degrees is equal to Radians : ", end ="")print (math.radians(1))
Output:
180/pi Degrees is equal to Radians : 1.0
180 Degrees is equal to Radians : 3.141592653589793
1 Degrees is equal to Radians : 0.017453292519943295

This function accepts the “radians” as input and converts it into its degrees equivalent.
Syntax : degrees(rad)
Parameters :rad : The radians value that one needs to convert into degrees.
Returns : This function returns the floating point degrees equivalent of argument.Computational Equivalent : 1 Degrees = pi/180 Radians.
 Code #2 : Demonstrating degrees()
# Python code to demonstrate# working of degrees()  # for degrees()import math  # Printing degrees equivalents.print("pi / 180 Radians is equal to Degrees : ", end ="")print (math.degrees(math.pi / 180))  print("180 Radians is equal to Degrees : ", end ="")print (math.degrees(180))  print("1 Radians is equal to Degrees : ", end ="")print (math.degrees(1))
Output:
pi/180 Radians is equal to Degrees : 1.0
180 Radians is equal to Degrees : 10313.240312354817
1 Radians is equal to Degrees : 57.29577951308232

Application :There are many possible applications of these functions in mathematical computations related to geometry and has a certain applications in astronomical computations as well.
Python-Built-in-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python String | replace()
Python program to convert a list to string
Reading and Writing to text files in Python
sum() function in Python
Move all zeros to start and ones to end in an Array of random integers in C++

In this tutorial, we are going to write a program that moves all zeroes to front and ones to end of the array.
Given an array with zeroes and ones along with random integers. We have to move all the zeroes to start and ones to the end of the array. Let's see an example.
Input
arr = [4, 5, 1, 1, 0, 0, 2, 0, 3, 1, 0, 1]
Output
0 0 0 0 4 5 2 3 1 1 1 1
Initialise the array.
Initialise the array.
Initialise an index to 1.
Initialise an index to 1.
Iterate over the given array.If the current element is not zero, then update the value at the index with the current element.Increment the index.
Iterate over the given array.
If the current element is not zero, then update the value at the index with the current element.
If the current element is not zero, then update the value at the index with the current element.
Increment the index.
Increment the index.
Write a loop that iterates from the above index to nUpdate all the elements to 1.
Write a loop that iterates from the above index to n
Update all the elements to 1.
Update all the elements to 1.
Similarly, do for 0. Instead of increasing the index, decrease it to move all zeroes to front of the array.
Similarly, do for 0. Instead of increasing the index, decrease it to move all zeroes to front of the array.
Following is the implementation of the above algorithm in C++
#include <bits/stdc++.h>
using namespace std;
void update1And0Positions(int arr[], int n) {
   int index = 0;
   for (int i = 0; i < n; i++) {
      if (arr[i] != 1) {
         arr[index++] = arr[i];
      }
   }
   while (index < n) {
      arr[index++] = 1;
   }
   index = 0;
   for (int i = n - 1; i >= 0; i--) {
      if (arr[i] == 1) {
         continue;
      }
      if (!index) {
         index = i;
      }
      if (arr[i] != 0) {
         arr[index--] = arr[i];
      }
   }
   while (index >= 0) {
      arr[index--] = 0;
   }
}
int main() {
   int arr[] = { 4, 5, 1, 1, 0, 0, 2, 0, 3, 1, 0, 1 };
   int n = 12;
   update1And0Positions(arr, n);
   for (int i = 0; i < n; i++) {
      cout << arr[i] << " ";
   }
   cout << endl;
   return 0;
}
If you run the above code, then you will get the following result.
0 0 0 0 4 5 2 3 1 1 1 1
How to use window.location to redirect to a different URL?

You might have encountered a situation where you clicked a URL to reach a page X but internally you were directed to another page Y. It happens due to page redirection.
It is quite simple to do a page redirect using JavaScript on the client side. To redirect your site visitors to a new page, you just need to add a line in your head section as follows.
You can try to run the following code to learn how to use window.location to redirect an HTML page. Here, we will redirect to the home page
Live Demo
<html>
   <head>
      <script>
         <!--
            function Redirect() {
               window.location.assign("https://www.tutorialspoint.com");
            }
         //-->
      </script>
   </head>
   <body>
      <p>Click the following button, you will be redirected to home page.</p>
      <input type="button" value="Redirect Me" onclick="Redirect();" />
   </body>
</html>
What are the differences and similarities between tuples and lists in Python?

Both List and Tuple are called as sequence data types of Python. Objects of both types are comma separated collection of items not necessarily of same type.
Concatenation, repetition, indexing and slicing can be done on objects of both types
>>> #list operations
>>> L1=[1,2,3]
>>> L2=[4,5,6]
>>> #concatenation
>>> L3=L1+L2
>>> L3
[1, 2, 3, 4, 5, 6]
>>> #repetition
>>> L1*3
[1, 2, 3, 1, 2, 3, 1, 2, 3]
>>> #indexing
>>> L3[4]
5
>>> #slicing
>>> L3[2:4]
[3, 4]
>>> #tuple operations
>>> T1=(1,2,3)
>>> T2=(4,5,6)
>>> #concatenation
>>> T3=T1+T2
>>> T3
(1, 2, 3, 4, 5, 6)
>>> #repetition
>>> T1*3
(1, 2, 3, 1, 2, 3, 1, 2, 3)
>>> #indexing
>>> T3[4]
5
>>> #slicing
>>> T3[2:4]
(3, 4)
Following built-in functions are common to both types
len() − return number of elements in sequence
>>> L1=[45,32,16,72,24]
>>> len(L1)
5
>>> T1=(45,32,16,72,24)
>>> len(T3)
max() − returns element with largest value.
>>> max(L1)
72
>>> max(T1)
72
min() − returns element with smallest value.
>>> max(T1)
72
>>> min(L1)
16
>>> min(T1)
16
List object is mutable. Hence, it is possible to append, update or delete an item from list.
>>> L1=[45,32,16,72,24]
>>> L1.append(56)
>>> L1
[45, 32, 16, 72, 24, 56]
>>> L1.insert(4,10) #insert 10 at 4th index
>>> L1
[45, 32, 16, 72, 10, 24, 56]
>>> L1.remove(16)
>>> L1
[45, 32, 72, 10, 24, 56]
>>> L1[2]=100 #update
>>> L1
[45, 32, 100, 10, 24, 56]
Tuple is immutable object. Any operation that try to modify it , results in AttributeError
T1.append(56)
AttributeError: 'tuple' object has no attribute 'append'
>>> T1.remove(16)
AttributeError: 'tuple' object has no attribute 'remove'
>>> T1[2]=100
TypeError: 'tuple' object does not support item assignment
Python - Synonyms and Antonyms

Synonyms and Antonyms are available as part of the wordnet which a lexical database for the English language. It is available as part of nltk corpora access. In wordnet Synonyms are the words that denote the same concept and are interchangeable in many contexts so that they are grouped into unordered sets (synsets). We use these synsets to derive the synonyms and antonyms as shown in the below programs.
from nltk.corpus import wordnet

synonyms = []

for syn in wordnet.synsets("Soil"):
    for lm in syn.lemmas():
             synonyms.append(lm.name())
print (set(synonyms))
When we run the above program we get the following output −
set([grease', filth', dirt', begrime', soil', 
grime', land', bemire', dirty', grunge', 
stain', territory', colly', ground'])

To get the antonyms we simply uses the antonym function.
from nltk.corpus import wordnet
antonyms = []

for syn in wordnet.synsets("ahead"):
    for lm in syn.lemmas():
        if lm.antonyms():
            antonyms.append(lm.antonyms()[0].name())

print(set(antonyms))
When we run the above program, we get the following output −
set([backward', back'])


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Python Grayscaling of Images using OpenCV

In this tutorial, we are going to learn how to change the grayscaling of an image using Grayscaling is the process of changing the images from different colour spaces like RGB,CMYK, etc.., to shades of gray. Install the OpenCV module if you didn't install it before.
pip install opencv-python
After installing the OpenCV module. Follow the below steps to write the code.
Import the cv2 module.
Read the image with cv2.imread(image_path) and store it in a variable.
Convert the image colour scale using cv2.cvtColor(image, cv2.COLOR_BGR1GRAY) and store it in a variable.
Show the image using cv2.imshow(image).
Wait until any key press to exit using the cv2.waitKey().
Destroy all the opened windows using cv2.destroyAllWindows() method.
# importing the opencv(cv2) module
import cv2
# reading the image
image = cv2.imread('lion.png')
# changing the color space
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# showing the resultant image
cv2.imshow('Grayscale Lion', gray_image)
# waiting until key press
cv2.waitKey()
# destroy all the windows
cv2.destroyAllWindows()
If you run the above code, then you will see the image in grayscale as shown below.
If you have any doubts in the tutorial, mention them in the comment section.
C library function - exp()

The C library function double exp(double x) returns the value of e raised to the xth power.
Following is the declaration for exp() function.
double exp(double x)
x − This is the floating point value.
x − This is the floating point value.
This function returns the exponential value of x.
The following example shows the usage of exp() function.
#include <stdio.h>
#include <math.h>

int main () {
   double x = 0;
  
   printf("The exponential value of %lf is %lf\n", x, exp(x));
   printf("The exponential value of %lf is %lf\n", x+1, exp(x+1));
   printf("The exponential value of %lf is %lf\n", x+2, exp(x+2));
   
   return(0);
}
Let us compile and run the above program that will produce the following result −
The exponential value of 0.000000 is 1.000000
The exponential value of 1.000000 is 2.718282
The exponential value of 2.000000 is 7.389056


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
3D Maths - DirectX Math

The initialization process of Direct3D requires some specific Direct3D types and basic graphics concepts. This chapter addresses these requirements.
Direct3D includes a design of low-level graphics API (Application Programming Interface) that enables us to render 3D worlds using 3D hardware acceleration. The most important thing is that Direct3D provides the software interfaces through which a user can use the graphics hardware. The best illustration is to instruct the graphics hardware to clear the render target.
Now, let us focus on DirectXMath which is the primary focus of this chapter. DirectXMath is written with the help of standard Intel-style intrinsics, which is usually portable to all compilers. The ARM code paths use ARM-style intrinsics which is considered to be portable.
The DirectXMath library makes use of two commonly implemented extensions to Standard C++ which are mentioned below −
Anonymous structs, which are widely supported and are part of the C11 standard.
Anonymous structs, which are widely supported and are part of the C11 standard.
Anonymous unions, but these are part of the C++ and C99 standard.
Anonymous unions, but these are part of the C++ and C99 standard.
DirectXMath is an inline SIMD which includes all the linear algebra library features for use in games and graphics apps.
The DirectXMath library includes inline features and uses only the concerned Visual C++ intrinsics. Hence, it is considered to be more compatible with all versions of Windows supported by Visual C++. There's no standard configuration which will put DirectXMath in the include path but a user can add it manually or make use of the NuGet package which is designed for that unique purpose. Keep in mind there are many differences which are completed with DirectX development for Windows XP support.
The details on moving from XNAMath to DirectXMath are covered in Code Migration from the XNA Math Library.
Make sure as a user you read all the details on the calling convention types which are designed to deal with the various architectures and vector calling conventions.
If a user is writing client code that is intended to build with both DirectXMath 3.06+ (Windows 8.1 SDK / VS 2013) and DirectXMath 3.03 (Windows 8 XDK / VS 2012), the following adapter code can be used −
#include <DirectXMath.h>
namespace DirectX {
   #if (DIRECTX_MATH_VERSION < 305) && !defined(XM_CALLCONV)
   #define XM_CALLCONV __fastcall
   typedef const XMVECTOR& HXMVECTOR;
   typedef const XMMATRIX& FXMMATRIX;
   #endif
}

DirectXMath includes all the written intrinsic standards, which should be portable to other compilers. The ARM codepaths also include ARM-style intrinsics which should be considered portable.
 Print
 Add Notes
 Bookmark this page
How to add “graphics.h” C/C++ library to gcc compiler in Linux

In this tutorial, we will be discussing a program to understand how to add “graphics.h” C/C++ library to gcc compiler in Linux.
To do this we are required to compile and install the libgraph package.
This includes install build-essential and some external packages
>>sudo apt-get install build-essential

>>sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-2.0 guile-2.0-dev
libsdl1.2debian libart-2.0-dev libaudiofile-dev libesd0-dev
libdirectfb-dev libdirectfb-extra libfreetype6-dev
libxext-dev x11proto-xext-dev libfreetype6 libaa1
libaa1-dev libslang2-dev libasound2 libasound2-dev
Then setting the path in the extracted files
>>sudo make install
>>sudo cp /usr/local/lib/libgraph.* /usr/lib
#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>
int main(){
   int gd = DETECT, gm;
   initgraph(&gd, &gm, NULL);
   circle(40, 40, 30);
   delay(40000);
   closegraph();
   return 0;
}
Python 3 - os.readlink() Method

The method readlink() returns a string representing the path to which the symbolic link points. It may return an absolute or relative pathname.
Following is the syntax for readlink() method −
os.readlink(path)
path − This is the path or symblic link for which we are going to find source of the link.
This method return a string representing the path to which the symbolic link points.
The following example shows the usage of readlink() method.
# !/usr/bin/python3
import os

src = 'd://tmp//python3'
dst = 'd://tmp//python2'

# This creates a symbolic link on python in tmp directory
os.symlink(src, dst)

# Now let us use readlink to display the source of the link.
path = os.readlink( dst )
print (path)
Let us compile and run the above program, this will create a symblic link to d:\tmp\python3 and later it will read the source of the symbolic link using readlink() call. This is an example on Windows platform and needs administrator privilege to run. Before running this program make sure you do not have d:\tmp\python2 already available.
d:\tmp\python2


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
How to decrement a value in MySQL keeping it above zero?

You can decrement value in MySQL with update command. With this, you can also restrict the value to not reach below 0.
The syntax is as follows −
update yourTableName set yourColumnName = yourColumnName - 1 where yourColumnName > 0;
To avoid the value to go below zero, you can use yourColumnName > 0.
To understand the above syntax, let us create a table. The query to create a table.
mysql> create table DecrementDemo
   −> (
   −> DecrementValue int
   −> );
Query OK, 0 rows affected (0.62 sec)
Insert some records in the table with insert statement. The query is as follows −
mysql> insert into DecrementDemo values(15),(14),(13),(12),(11),(10);
Query OK, 6 rows affected (0.18 sec)
Records: 6 Duplicates: 0 Warnings: 0
Now you can display all records from table with the help of select statement. The query is as follows −
mysql> select *from DecrementDemo;
The following is the output −
+----------------+
| DecrementValue |
+----------------+
|             15 |
|             14 |
|             13 |
|             12 |
|             11 |
|             10 |
+----------------+
6 rows in set (0.00 sec)
Here is the query to decrement value from a table −
mysql> update DecrementDemo
   −> set DecrementValue = DecrementValue - 1 where DecrementValue > 0;
Query OK, 6 rows affected (0.16 sec)
Rows matched: 6 Changed: 6 Warnings: 0
Check whether the value decremented or not using the following query −
mysql> select *from DecrementDemo;
The following is the output −
+----------------+
| DecrementValue |
+----------------+
|             14 |
|             13 |
|             12 |
|             11 |
|             10 |
|              9 |
+----------------+
6 rows in set (0.00 sec)
How to get specific nodes in xml file in Python?

Using the xml library you can get any node you want from the xml file. But for extracting a given node, you'd need to know how to use xpath to get it. You can learn more about XPath here:https://www.w3schools.com/xml/xml_xpath.asp. 
For example, assume you have a xml file with following structure,
<bookstore>
    <book category="cooking">
    <title lang="en">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
    </book>
    <book category="children">
    <title lang="en">Harry Potter</title>
    <author>J K. Rowling</author>
    <year>2005</year>
    <price>29.99</price>
    </book>
</bookstore>
And you want to extract all title nodes with lang attribute en, then you'd have the code −
from xml.etree.ElementTree import ElementTree
tree = ElementTree()
root = tree.parse("my_file.xml")
for node in root.findall("//title[@lang='en']"):
    for type in node.getchildren():
        print(type.text)
Python | Split given dictionary in half

26 Jul, 2019
While working with dictionaries, sometimes we might have a problem in which we need to reduce the space taken by single container and wish to divide the dictionary into 2 halves. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using items() + len() + list slicingThe combination of above functions can easily perform this particular task in which slicing into half is done by list slicing and items of dictionary are extracted by items()
# Python3 code to demonstrate working of# Split dictionary by half# Using items() + len() + list slicing  # Initialize dictionarytest_dict = {'gfg' : 6, 'is' : 4, 'for' : 2, 'CS' : 10}  # printing original dictionaryprint("The original dictionary : " +  str(test_dict))  # Using items() + len() + list slicing# Split dictionary by halfres1 = dict(list(test_dict.items())[len(test_dict)//2:])res2 = dict(list(test_dict.items())[:len(test_dict)//2])  # printing result print("The first half of dictionary : " + str(res1))print("The second half of dictionary : " + str(res2))
The original dictionary : {‘CS’: 10, ‘for’: 2, ‘is’: 4, ‘gfg’: 6}The first half of dictionary : {‘is’: 4, ‘gfg’: 6}The second half of dictionary : {‘for’: 2, ‘CS’: 10}
 
Method #2 : Using slice() + len() + items()The combination of above functions can be used to perform this particular task. In this, we perform task similar to above method, just the difference is the slice operation is performed by slice() instead of list slicing.
# Python3 code to demonstrate working of# Split dictionary by half# Using items() + len() + slice()from itertools import islice  # Initialize dictionarytest_dict = {'gfg' : 6, 'is' : 4, 'for' : 2, 'CS' : 10}  # printing original dictionaryprint("The original dictionary : " +  str(test_dict))  # Using items() + len() + slice()# Split dictionary by halfinc = iter(test_dict.items())res1 = dict(islice(inc, len(test_dict) // 2)) res2 = dict(inc)  # printing result print("The first half of dictionary : " + str(res1))print("The second half of dictionary : " + str(res2))
The original dictionary : {‘CS’: 10, ‘for’: 2, ‘is’: 4, ‘gfg’: 6}The first half of dictionary : {‘is’: 4, ‘gfg’: 6}The second half of dictionary : {‘for’: 2, ‘CS’: 10}
Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Query to find the Nth Largest Value in a Column using Limit and Offset - GeeksforGeeks

30 Jun, 2021
Prerequisite – How to find Nth highest salary from a table Problem Statement : Write an SQL query to find the nth largest value from the column using LIMIT and OFFSET. 
Example-1 : 
Table – BILLS 
 
The above table has the electricity bills of all the flats in an apartment. You have to find the nth largest electricity bill in the table. 
 
SELECT DISTINCT ElectricityBill AS NthHighestElectricityBill
FROM Bills
ORDER BY ElectricityBill DESC
LIMIT 1 
OFFSET n-1;
Here n should be an integer whose value must be greater than zero. 
Explaination : In the above query, we are sorting the values of ElectricityBill column in descending order using Order By clause and by selecting only distinct values. After sorting it in descending order we have to find the Nth value from the top, so we use OFFSET n-1 which eliminates the top n-1 values from the list, now from the remaining list we have to select only its top element, to do that we use LIMIT 1. 
If we want to find the 3rd highest electricity bill the query will be – 
 
SELECT DISTINCT ElectricityBill AS 3rdHighestElectricityBill
FROM Bills
ORDER BY ElectricityBill DESC
LIMIT 1
OFFSET 2;
The result of the above query will be – 
 
Example-2 : 
Table – EmployeeSalary 
 
The above table has the salaries of employees working in a small company. Find the employee id who is earning the 4th highest salary. 
 
SELECT EmployeeID AS 4thHighestEarningEmployee 
FROM EmployeeSalary
ORDER BY SalaryInThousands DESC
LIMIT 1 
OFFSET 3;
Explaination : Here distinct is not used because we need employee whose earnings stand at 4th place among all the employee’s (i.e 316k not 259k). 
The result of the above query will be – 
 
 
as5853535
DBMS-SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
CTE in SQL
SQL | Views
Difference between DELETE, DROP and TRUNCATE
How to Update Multiple Columns in Single Update Statement in SQL?
Difference between SQL and NoSQL
Difference between DDL and DML in DBMS
SQL Interview Questions
What is Temporary Table in SQL?
MySQL | Group_CONCAT() Function
SQL - ORDER BY
Union of two Objects in R Programming - union() Function - GeeksforGeeks

19 May, 2020
union() function in R Language is used to combine the data of two objects. This function takes two objects like Vectors, dataframes, etc. as arguments and results in a third object with the combination of the data of both the objects.
Syntax: union(x, y)
Parameters:x and y: Objects with sequence of items
Example 1: Union of two Vectors
# R program to illustrate# union of two vectors  # Vector 1x1 <- c(1, 2, 3, 4, 5, 6, 5, 5)     # Vector 2 x2 <- c(8, 9)      # Union of two vectors  x3 <- union(x1, x2)        print(x3)                                      
Output:
[1] 1 2 3 4 5 6 8 9
Here in the above code, the vector x1 contains values from 1-6, and x2 has two values. Now the union of these two vector x1 and x2 will combine each of the values present in them just once.
Note: Union of two vectors removes the duplicate elements in the final vector.
Example 2: Union of two dataframes
# R program to illustrate # the union of two data frames  # Data frame 1data_x <- data.frame(x1 = c(5, 6, 7),                         x2 = c(1, 1, 1))  # Data frame 2data_y <- data.frame(y1 = c(2, 3, 4),                            y2 = c(2, 2, 2))  # R union two data framesdata_z <- union(data_x, data_y)    print(data_z)               
Output:
[[1]]
[1] 5 6 7

[[2]]
[1] 1 1 1

[[3]]
[1] 2 3 4

[[4]]
[1] 2 2 2

Here in the above code, we have created two data frames first with x1, x2 and second have y1, y2. Union of these two data frames creates a third data frame with combined values.
R-dataStructures
R-Functions
Programming Language
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Decorators with parameters in Python
Top 10 Programming Languages to Learn in 2022
Shallow Copy and Deep Copy in C++
C# | Data Types
Difference between Shallow and Deep copy of a class
Change column name of a given DataFrame in R
How to Replace specific values in column in R DataFrame ?
Filter data by multiple conditions in R using Dplyr
Adding elements in a vector in R programming - append() method
Loops in R (for, while, repeat)
What is the difference between int and Int32 in C#?

Int32 is a type provided by .NET framework whereas int is an alias for Int32 in C# language.
Int32 x = 5;
Int32 x = 5;
int x = 5;
int x = 5;
So, in use both the above statements will hold a 32bit integer. They compile to the same code, so at execution time there is no difference whatsoever.
The only minor difference is Int32 can be only used with System namespace. While validating the type of a value like mentioned above we can use Int32 or int.
typeof(int) == typeof(Int32) == typeof(System.Int32)
The below example shows how an integer is declared using System.Int32.
 Live Demo
using System;
namespace DemoApplication{
   class Program{
      static void Main(string[] args){
         Int32 x = 5;
         Console.WriteLine(x); //Output: 5
      }
   }
}
5
The below example shows how an integer is declared using int keyword.
 Live Demo
using System;
namespace DemoApplication{
   class Program{
      static void Main(string[] args){
         int x = 5;
         Console.WriteLine(x); //Output: 5
      }
   }
}
5
Data Structures | Tree Traversals | Question 11 - GeeksforGeeks

28 Jun, 2021
Let LASTPOST, LASTIN and LASTPRE denote the last vertex visited in a postorder, inorder and preorder traversal. Respectively, of a complete binary tree. Which of the following is always true? (GATE CS 2000)(A) LASTIN = LASTPOST(B) LASTIN = LASTPRE(C) LASTPRE = LASTPOST(D) None of the aboveAnswer: (D)Explanation: It is given that the given tree is complete binary tree. For a complete binary tree, the last visited node will always be same for inorder and preorder traversal. None of the above is true even for a complete binary tree.
The option (a) is incorrect because the last node visited in Inorder traversal is right child and last node visited in Postorder traversal is root.
The option (c) is incorrect because the last node visited in Preorder traversal is right child and last node visited in Postorder traversal is root.
For option (b), see the following counter example. Thanks to Hunaif Muhammed for providing the correct explanation.
     1
   /    \
  2      3
 / \    /
4   5  6  

Inorder traversal is 4 2 5 1 6 3
Preorder traversal is 1 2 4 5 3 6 

Quiz of this Question
Data Structures
Data Structures-Tree Traversals
Tree Traversals
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Data Structures | Linked List | Question 5
Data Structures | Linked List | Question 6
Difference between Singly linked list and Doubly linked list
Advantages and Disadvantages of Linked List
Data Structures | Graph | Question 9
FIFO vs LIFO approach in Programming
C program to implement Adjacency Matrix of a given Graph
Data Structures | Stack | Question 1
Introduction to Data Structures
Binary Search Tree | Set 3 (Iterative Delete)
Python Regex to extract maximum numeric value from a string - GeeksforGeeks

29 Dec, 2020
Given an alphanumeric string, extract maximum numeric value from that string. Alphabets will only be in lower case.
Examples:
Input : 100klh564abc365bg
Output : 564
Maximum numeric value among 100, 564 
and 365 is 564.

Input : abchsd0sdhs
Output : 0

This problem has existing solution please refer Extract maximum numeric value from a given string | Set 1 (General approach) link. We will solve this problem quickly in python using Regex. Approach is very simple,
Find list of all integer numbers in string separated by lower case characters using re.findall(expression,string) method.Convert each number in form of string into decimal number and then find max of it.
Find list of all integer numbers in string separated by lower case characters using re.findall(expression,string) method.
Convert each number in form of string into decimal number and then find max of it.
# Function to extract maximum numeric value from # a given stringimport re  def extractMax(input):       # get a list of all numbers separated by      # lower case characters      # \d+ is a regular expression which means     # one or more digit     # output will be like ['100','564','365']     numbers = re.findall('\d+',input)       # now we need to convert each number into integer     # int(string) converts string into integer     # we will map int() function onto all elements      # of numbers list     numbers = map(int,numbers)       print max(numbers)  # Driver programif __name__ == "__main__":    input = '100klh564abc365bg'    extractMax(input)
Output:
564

Python Regex-programs
python-regex
python-string
Python
Strings
Strings
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
Write a program to reverse an array or string
Reverse a string in Java
Write a program to print all permutations of a given string
C++ Data Types
Longest Common Subsequence | DP-4
Grouping Rows in pandas - GeeksforGeeks

14 Jan, 2019
Pandas is the most popular Python library that is used for data analysis. It provides highly optimized performance with back-end source code is purely written in C or Python.
Let’s see how to group rows in Pandas Dataframe with help of multiple examples.
Example 1:
For grouping rows in Pandas, we will start with creating a pandas dataframe first.
# importing Pandasimport pandas as pd  # example dataframeexample = {'Team':['Arsenal', 'Manchester United', 'Arsenal',                   'Arsenal', 'Chelsea', 'Manchester United',                   'Manchester United', 'Chelsea', 'Chelsea', 'Chelsea'],                                'Player':['Ozil', 'Pogba', 'Lucas', 'Aubameyang',                       'Hazard', 'Mata', 'Lukaku', 'Morata',                                          'Giroud', 'Kante'],                                                      'Goals':[5, 3, 6, 4, 9, 2, 0, 5, 2, 3] }  df = pd.DataFrame(example)  print(df)
Now, create a grouping object, means an object that represents that particular grouping.
total_goals = df['Goals'].groupby(df['Team'])  # printing the means valueprint(total_goals.mean())    
Output:
 Example 2:
import pandas as pd  # example dataframeexample = {'Team':['Australia', 'England', 'South Africa',                   'Australia', 'England', 'India', 'India',                        'South Africa', 'England', 'India'],                                     'Player':['Ricky Ponting', 'Joe Root', 'Hashim Amla',                     'David Warner', 'Jos Buttler', 'Virat Kohli',                     'Rohit Sharma', 'David Miller', 'Eoin Morgan',                                                 'Dinesh Karthik'],                                                             'Runs':[345, 336, 689, 490, 989, 672, 560, 455, 342, 376],                      'Salary':[34500, 33600, 68900, 49000, 98899,                    67562, 56760, 45675, 34542, 31176] }  df = pd.DataFrame(example)  total_salary = df['Salary'].groupby(df['Team'])  # printing the means valueprint(total_salary.mean())     
Output:
pandas-dataframe-program
Picked
Python pandas-dataFrame
Python-pandas
Technical Scripter 2018
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()