code-rag-bench/online-tutorials huggingface dataset:
sympy.integrals.transforms.laplace_transform() in python

28 Jun, 2021
With the help of laplace_transform() method, we can compute the laplace transformation F(s) of f(t). 
 
Syntax : laplace_transform(f, t, s) Return : Return the laplace transformation and convergence condition.  
Example #1 : In this example, we can see that by using laplace_transform() method, we are able to compute the laplace transformation and return the transformation and convergence condition. 
Python3
# import laplace_transformfrom sympy.integrals import laplace_transformfrom sympy.abc import t, s, a # Using laplace_transform() methodgfg = laplace_transform(t**a, t, s) print(gfg)
Output : 
(s**(-a)*gamma(a + 1)/s, 0, a > -1)  
Example #2 : 
Python3
# import laplace_transformfrom sympy.integrals import laplace_transformfrom sympy.abc import t, s, a # Using laplace_transform() methodgfg = laplace_transform(t**a, t, 5) print(gfg)
Output : 
(5**(-a)*gamma(a + 1)/5, 0, a > -1)  
 
ruhelaa48
Python SymPy-Stats
SymPy
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Rotate axis tick labels in Seaborn and Matplotlib
Deque in Python
Stack in Python
Python Dictionary
sum() function in Python
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Iterate over characters of a string in Python
Python | Convert set into a list
How to Hide IP and MAC Address using Anonym8 in Kali Linux ?

17 Jun, 2021
Anonym8 is a free and open-source tool for becoming anonymous on the Internet while testing the security of a web browser. Anonym8 uses IP-tables to create a Transparent Proxy through the Tor Network. Anonym8 can move the network of your Kali Linux operating system through the Tor Network. When you run the tool, it starts as a transparent proxy. After initiating Anonym8, you can do all your security testing on the website and become anonymous. This tool can be challenging for people if they want to trace your IP address. This tool uses the techniques of Transparent Proxy through TOR and I2P to change Mac addresses. The user interface is very similar to Metasploitable 1 and Metasploitable 2, which makes it easy to use.
Anonym8 uses IP-tables
Anonym8 uses  tor proxy
Anonym8 uses tor tunnel
through Anonym8 network can redirected through IP tables.
Anonym8 is easy to use.
Anonym8 can change your system’s mac address.
Step 1: Open your Kali Linux. Move to your terminal and install the tool using the following command.
git clone https://github.com/HiroshiManRise/anonym8.git 
cd anonym8
Step 2: Now you have to give permission to the tool using the following command.
chmod +x INSTALL.sh
Step 3: To install the tool use the following command.
INSTALL.sh
Example 1:
 Now to see the status and to change the IP address use the following command.
anonym8 status_ip
Before that, first check the original IP address
after running the command
after running the tool.
You can see that IP address has been changed. Similarly, you can change your IP address while testing any site.
Example 2:
Now to spoof the mac address, use the following command.
anonym8 start_mac
You can see that eth is changed and the flags values are different from each other.
This is how you can perform these experiments on your system. You can also spoof your mac address. The MAC address is the same as the Ethernet address on the Ethernet LAN. In telecommunication protocols, the media access control, which is the sublayer of the data-link layer, uses the MAC address.
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Docker - COPY Instruction
scp command in Linux with Examples
chown command in Linux with Examples
SED command in Linux | Set 2
mv command in Linux with examples
nohup Command in Linux with Examples
chmod command in Linux with examples
Introduction to Linux Operating System
Array Basics in Shell Scripting | Set 1
Basic Operators in Shell Scripting
Addition of Lines to a Plot in R Programming – lines() Function

09 Dec, 2021
lines() function in R Programming Language is used to add lines of different types, colors and width to an existing plot.
Syntax: lines(x, y, col, lwd, lty)
Parameters: 
x, y: Vector of coordinates
col: Color of line
lwd: Width of line
lty: Type of line
Here we are going to create a scatter plot using the dataset.
R
# R program to create a scatter plot # Creating coordinate vectorsx <- c(1.3, 3.5, 1.4, -3.1, 5.7, 2.4,       3.3, 2.5, 2.3, 1.9, 1.8, 2.3)y <- c(2.5, 5.8, 2.1, -3, 12, 5, 6.2,       4.8, 4.2, 3.5, 3.7, 5.2) # Plotting the graphplot(x, y, cex = 1, pch = 3,     xlab ="x", ylab ="y",     col ="black")
Output:
R
# R program to add lines into plots # Creating coordinate vectorsx <- c(1.3, 3.5, 1.4, -3.1, 5.7,       2.4, 3.3, 2.5, 2.3, 1.9, 1.8, 2.3)y <- c(2.5, 5.8, 2.1, -3, 12, 5,       6.2, 4.8, 4.2, 3.5, 3.7, 5.2) # Plotting the graphplot(x, y, cex = 1, pch = 3, xlab ="x",     ylab ="y", col ="black") # Creating coordinate vectorsx2 <- c(4.3, 1.2, -2.5, -0.4)y2 <- c(3.5, 4.6, 2.5, 3.2) # Plotting a linelines(x2, y2, col = "red",      lwd = 2, lty = 1)
Output:
Here we are going to create a scatter plot and then we will connect lines with lines() function.
R
# R program to add lines into plots # Creating coordinate vectorsx <- c(1.3, 3.5, 1.4, -3.1, 5.7, 2.4,       3.3, 2.5, 2.3, 1.9, 1.8, 2.3)y <- c(2.5, 5.8, 2.1, -3, 12, 5, 6.2,       4.8, 4.2, 3.5, 3.7, 5.2) # Plotting the graphplot(x, y, cex = 1, pch = 3,     xlab ="x", ylab ="y",     col ="black") lines(x, y, col = "red")
Output: 
kumar_satyam
R-plots
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Pandas Timestamp.round

14 Jan, 2019
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas Timestamp.round() function is used to round the given Timestamp to the specified resolution.
Syntax :Timestamp.round()
Parameters :freq : a freq string indicating the rounding resolution
Return : a new Timestamp rounded to the given resolution of freq
Example #1: Use Timestamp.round() function to round the given Timestamp to Daily time series frequency.
# importing pandas as pdimport pandas as pd  # Create the Timestamp objectts = pd.Timestamp(year = 2011,  month = 11, day = 21,                  hour = 10, second = 49, tz = 'US/Central')  # Print the Timestamp objectprint(ts)
Output :
Now we will use the Timestamp.round() function to round the given Timestamp object to Daily frequency.
# round to daily frequencyts.round(freq = 'D')
Output :
As we can see in the output, the Timestamp.round() function has returned a Timestamp object having the time series frequency rounded to the desired resolution.
Example #2: Use Timestamp.round() function to round the given Timestamp to minutely time series frequency.
# importing pandas as pdimport pandas as pd  # Create the Timestamp objectts = pd.Timestamp(year = 2009, month = 5, day = 31,       hour = 4, second = 49, tz = 'Europe/Berlin')  # Print the Timestamp objectprint(ts)
Output :
Now we will use the Timestamp.round() function to round the given Timestamp object to minutely frequency.
# round to minutely frequencyts.round(freq = 'T')
Output :
As we can see in the output, the Timestamp.round() function has returned a Timestamp object having the time series frequency rounded to the desired resolution.
Python Pandas-Timestamp
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Scanner hasNextLine() method in Java with Examples

16 Oct, 2018
The hasNextLine() method of java.util.Scanner class returns true if there is another line in the input of this scanner. This method may block while waiting for input. The scanner does not advance past any input.
Syntax:
public boolean hasNextLine()
Parameters: The function does not accepts any parameter.
Return Value: This function returns true if and only if this scanner has another line of input
Exceptions: The function throws IllegalStateException if this scanner is closed.
Below programs illustrate the above function:
Program 1:
// Java program to illustrate the// hasNextLine() method of Scanner class in Java// without parameter  import java.util.*;  public class GFG1 {    public static void main(String[] argv)        throws Exception    {          String s = "gfg 2 geeks!";          // new scanner with the        // specified String Object        Scanner scanner = new Scanner(s);          // use US locale to interpret Lines in a string        scanner.useLocale(Locale.US);          // iterate till end        while (scanner.hasNextLine()) {              // print what is scanned            System.out.println(scanner.nextLine());        }          // close the scanner        scanner.close();    }}
gfg 2 geeks!

Program 2: Program to demonstrate exception
// Java program to illustrate the// hasNextLine() method of Scanner class in Java// without parameter  import java.util.*;  public class GFG1 {    public static void main(String[] argv)        throws Exception    {        try {              String s = "gfg 2 geeks!";              // new scanner with the            // specified String Object            Scanner scanner = new Scanner(s);              // use US locale to interpret Lines in a string            scanner.useLocale(Locale.US);              scanner.close();              // iterate till end            while (scanner.hasNextLine()) {                  // print what is scanned                System.out.println(scanner.nextLine());            }              // close the scanner            scanner.close();        }        catch (IllegalStateException e) {            System.out.println("Exception is: " + e);        }    }}
Exception is: java.lang.IllegalStateException: Scanner closed

Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html#hasNextLine()
Java - util package
Java-Functions
Java-Scanner
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to select specified node within Xpath node sets by index with Selenium?

We can select specific nodes within xpath node sets by index with Selenium webdriver. We can mention a specific node with the help of its index number enclosed in [].
Let us have a look at the below html code for an element having children. The element with tagname ul has multiple child elements with tagname li. If we want to identify the second child of the parent having text as Software Quality management the xpath expression with node index shall be //ul[@class='list']li[2].
The xpath expression to identify the second child of the parent element ul can also be created with the help of position() function in xpath. To pinpoint the second element we have to append position()=2 to the xpath. So the complete xpath expression shall be //ul/[@class='list']/li[position()=2].
Code Implementation with xpath having index
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class ElementIndex{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      driver.get("https://www.tutorialspoint.com/about/tutorials_writing.htm");
      // identify element with xpath having index
      WebElement t = driver.findElement(By.xpath("//ul[@class='list']/li[2]"));
      //getText to get element text
      System.out.println("The element is: " + t.getText());
      driver.close();
   }
}
Code Implementation with xpath having position().
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class ElementPosition{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      driver.get("https://www.tutorialspoint.com/about/tutorials_writing.htm");
      // identify element with xpath having position()
      WebElement t = driver.findElement(By.xpath("//ul[@class='list']/li[position()=2]"));
      //getText to get element text
      System.out.println("The element is: " + t.getText());
      driver.close();
   }
}
Compound Literals in C - GeeksforGeeks

02 Jun, 2017
Consider below program in C.
// Please make sure that you compile this program// using a C compiler, not a C++ compiler (Save your// file .cpp). If using online compiler, select "C"#include <stdio.h>int main(){   // Compound literal (an array is created without   // any name and address of first element is assigned   // to p.  This is equivalent to:   // int arr[] = {2, 4, 6};   // int *p = arr;   int *p = (int []){2, 4, 6};     printf("%d %d %d", p[0], p[1], p[2]);     return 0;}
Output:
2 4 6
The above example is an example of compound literals. Compound literals were introduced in C99 standard of C. Compound literals feature allows us to create unnamed objects with given list of initialized values. In the above example, an array is created without any name. Address of first element of array is assigned to pointer p.
What is the use of it?Compound literals are mainly used with structures and are particularly useful when passing structures variables to functions. We can pass a structure object without defining itFor example, consider the below code.
// Please make sure that you compile this program// using a C compiler, not a C++ compiler (Save your// file .cpp). If using online compiler, select "C"#include <stdio.h>  // Structure to represent a 2D pointstruct Point{   int x, y;};  // Utility function to print pointvoid printPoint(struct Point p){   printf("%d, %d", p.x, p.y);}  int main(){   // Calling printPoint() without creating any temporary   // Point variable in main()   printPoint((struct Point){2, 3});     /*  Without compound literal, above statement would have       been written as       struct Point temp = {2, 3};       printPoint(temp);  */     return 0;}
Output:
2, 3
This article is contributed by Shivam Gupta. 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.
C-Data Types
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
rand() and srand() in C/C++
fork() in C
Command line arguments in C/C++
Function Pointer in C
Substring in C++
Different methods to reverse a string in C/C++
Structures in C
TCP Server-Client implementation in C
Enumeration (or enum) in C
std::string class in C++
Scope of Variables In Scala - GeeksforGeeks

17 Feb, 2019
Variable declaration specifies the name of the variable that would be stored in the memory and memory can be accessed further with this name of variable. There are three types of scope for Scala variable.
Fields.
Method Parameters.
Local Variables.
Let’s discuss each of them in detail.
We can access these kind of variables from every method in the object & from outside the object if we declared them with the right access modifiers.A field may be mutable or immutable, they can define them using ‘var’ or ‘val’.Example:
// Scala program of field // scope for Scala variable  // class created with field // variables x and y.class disp {    var x = 10.3f    var y = 7f    def windet()     {        println("Value of x : "+x)    }        println("Value of y : "+y);}  object Example {    // Main method    def main(args:Array[String])     {        val Example = new disp()        Example.windet()    }}
Output:
Value of y : 7.0
Value of x : 10.3
Above example shows disp class is created with field variables x and y. These variables can be accessed inside a method and invoked this from an object by creating reference.Hence below is the output obtained. 
We use these variables when we want to pass a value inside the method when we call it. They can be accessed inside the method and outside method if there is a reference to the object from outside the method. these variables are always mutable Using with ‘val’ keyword.
Example:
// Scala program of Method // scope for Scala variable  // class created with Method // variables s1 and s2.class rect {    def mult(s1: Int, s2: Int)    {        var result = s1 * s2       println("Area is: " + result);    }}  object Area {    // Main method    def main(args:Array[String])    {        val su = new rect()        su.mult(5, 10)    }}
Output:
Area is: 50
Above Example shows rect class is created with mult method accepting two method parameter variables s1 and s2. Area object is created and rect method is invoking by passing the values to variables s1 and s2.Hence below is the output obtained.
 
Example:
// Scala program of Method // scope for Scala variable  // class created with Local// variables s1 and s2.class Area {    def mult()     {        var(s1, s2) = (3, 80);        var s = s1 * s2;        println("Area is: " + s)    }}  object Test {    // Main method    def main(args:Array[String])     {        val ex = new Area()        ex.mult()    }}
Output:
Area is: 240
Above example shows class Area having local variables s1, s2 & s inside method mult.These variables are not accessible outside the method.Hence the output obtained is below.
Scala
Scala-Basics
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Hello World in Scala
Scala Map get() method with example
Scala ListBuffer
Scala List map() method with example
Scala List length() method with example
How to install Scala on Windows?
Scala | Traits
Scala | Case Class and Case Object
Inheritance in Scala
GATE | GATE-CS-2016 (Set 1) | Question 33 - GeeksforGeeks

28 Sep, 2017
A database of research articles in a journal uses the following schema.
(VOLUME, NUMBER, STARTPGE, ENDPAGE, TITLE, YEAR, PRICE) 
The primary key is (VOLUME, NUMBER, STARTPAGE, ENDPAGE) and the following functional dependencies exist in the schema.
(VOLUME, NUMBER, STARTPAGE, ENDPAGE) -> TITLE
(VOLUME, NUMBER)                     -> YEAR
(VOLUME, NUMBER, STARTPAGE, ENDPAGE) -> PRICE 
The database is redesigned to use the following schemas.
(VOLUME, NUMBER, STARTPAGE, ENDPAGE, TITLE, PRICE)
(VOLUME, NUMBER, YEAR) 
Which is the weakest normal form that the new database satisfies, but the old one does not?
(A) 1NF(B) 2NF(C) 3NF(D) BCNFAnswer: (B)Explanation: Old relation has functional dependency : Volume, Number -> Year as partial dependency. So it does not follow 2NF.But, there is no partial dependency in the New relation and so it satisfies 2NF as well as 3NF.
Therefore, 2NF is the weakest normal form that the new database satisfies, but the old one does not.Option (B) is true.Quiz of this Question
GATE-CS-2016 (Set 1)
GATE-GATE-CS-2016 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2014-(Set-1) | Question 30
GATE | GATE-CS-2001 | Question 23
GATE | GATE-CS-2015 (Set 1) | Question 65
GATE | GATE CS 2010 | Question 45
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2014-(Set-1) | Question 65
C++ Program to count Vowels in a string using Pointer
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2015 (Set 1) | Question 42
GATE | GATE-CS-2014-(Set-3) | Question 65
strcpy in C/C++ - GeeksforGeeks

22 Sep, 2021
strcpy() is a standard library function in C/C++ and is used to copy one string to another. In C it is present in string.h header file and in C++ it is present in cstring header file. 
Syntax: 
char* strcpy(char* dest, const char* src);
Parameters: This method accepts the following parameters:  
dest: Pointer to the destination array where the content is to be copied.
src: string which will be copied.
Return Value: After copying the source string to the destination string, the strcpy() function returns a pointer to the destination string.
Below program explains different usages of this library function:  
C++
C
// C++ program to illustrate// strcpy() function ic C/C++#include <iostream>using namespace std;#include<string.h> int main (){    char str1[]="Hello Geeks!";    char str2[] = "GeeksforGeeks";    char str3[40];    char str4[40];    char str5[] = "GfG";         strcpy(str2, str1);    strcpy(str3, "Copy successful");    strcpy(str4, str5);    cout << "str1: " << str1 << "\nstr2: " << str2 <<"\nstr3: "<< str3 << "\nstr4: "<< str4;    return 0;} // this code is contributed by shivanisinghss2110
// C program to illustrate// strcpy() function ic C/C++#include<stdio.h>#include<string.h> int main (){    char str1[]="Hello Geeks!";    char str2[] = "GeeksforGeeks";    char str3[40];    char str4[40];    char str5[] = "GfG";         strcpy(str2, str1);    strcpy(str3, "Copy successful");    strcpy(str4, str5);    printf ("str1: %s\nstr2: %s\nstr3: %s\nstr4:                  %s\n", str1, str2, str3, str4);    return 0;}
Output: 
str1: Hello Geeks!
str2: Hello Geeks!
str3: Copy successful
str4: GfG
Important Points 
This function copies the entire string to the destination string. It doesn’t append the source string to the destination string. In other words, we can say that it replaces the content of destination string by the content of source string.
It does not affect the source string. The source string remains same after copying.
This function only works with C style strings and not C++ style strings i.e. it only works with strings of type char str[]; and not string s1; which are created using standard string data type available in C++ and not C.
This article is contributed by Harsh Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
oliverelarsen
CoderSaty
shivanisinghss2110
C-String
cpp-string
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
rand() and srand() in C/C++
Left Shift and Right Shift Operators in C/C++
fork() in C
Core Dump (Segmentation fault) in C/C++
Command line arguments in C/C++
Vector in C++ STL
Initialize a vector in C++ (6 different ways)
Map in C++ Standard Template Library (STL)
Inheritance in C++
Constructors in C++
Python Pandas - Return the microseconds from Timedelta object

To return the microseconds from Timedelta object, use the timedelta.microseconds property. At first, import the required libraries −
import pandas as pd
TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s. Create a Timedelta object
timedelta = pd.Timedelta('7 days 20 min 15 s 35 ms')

Return the microseconds value
timedelta.microseconds
Following is the code
import pandas as pd

# TimeDeltas is Python’s standard datetime library uses a different representation timedelta’s
# create a Timedelta object
timedelta = pd.Timedelta('7 days 20 min 15 s 35 ms')

# display the Timedelta
print("Timedelta...\n", timedelta)

# return the microseconds value
res = timedelta.microseconds

# display the microseconds
print("\nTimedelta (microseconds value)...\n", res)
This will produce the following code
Timedelta...
 7 days 00:20:15.035000

Timedelta (microseconds value)...
 35000
How to get a variable name as a string in PHP?

To get a variable name as a string in PHP, the code is as follows−
 Live Demo
<?php
   $a = "This is it!";
   $$a = "Demo string!";
   print($a);
?>
This will produce the following output−
This is it!
Let us now see another example −
 Live Demo
<?php
   $val = "This is it!";
   function display($var) {
      foreach($GLOBALS as $demo => $value) {
         if ($value === $var) {
            return $demo;
         }
      }
      return false;
   }
   print display($val);
?>
This will produce the following output−
Val
Tk - Canvas Text Widget

Canvas text widget is used to draw text in canvas. The syntax for canvas text widget is shown below −
canvasName create text x y options

x and y are used to determine the position of text −
The options available for the canvas text widget are listed below in the following table −
-anchor position
The text will be positioned relative to the x and y locations. Center is default and other options are n, s, e, w, ne, se, sw, and nw.
-justify style
Determines the multiline, should be right justified, left justified, or center justified. The default is left.
-fill color
The fill color fills the oval with the color.
-text text
The text for text widget.
-font fontStyle
The font to use for this text.
A simple example for canvas text widget is shown below −
#!/usr/bin/wish

canvas .myCanvas -background red -width 200 -height 200 
pack .myCanvas
.myCanvas create text 100 100 -fill yellow -justify center -text "Hello World.\n
   How are you?" -font {Helvetica -18 bold}
When we run the above program, we will get the following output −
 Print
 Add Notes
 Bookmark this page
3D Scatter Plotting in Python using Matplotlib - GeeksforGeeks

28 Sep, 2020
A 3D Scatter Plot is a mathematical diagram, the most basic version of three-dimensional plotting used to display the properties of data as three variables of a dataset using the cartesian coordinates.To create a 3D Scatter plot, Matplotlib’s mplot3d toolkit is used to enable three dimensional plotting.Generally 3D scatter plot is created by using ax.scatter3D() the function of the matplotlib library which accepts a data sets of X, Y and Z to create the plot while the rest of the attributes of the function are the same as that of two dimensional scatter plot.Example 1: Let’s create a basic 3D scatter plot using the ax.scatter3D() function. 
Python3
# Import librariesfrom mpl_toolkits import mplot3dimport numpy as npimport matplotlib.pyplot as plt  # Creating datasetz = np.random.randint(100, size =(50))x = np.random.randint(80, size =(50))y = np.random.randint(60, size =(50)) # Creating figurefig = plt.figure(figsize = (10, 7))ax = plt.axes(projection ="3d") # Creating plotax.scatter3D(x, y, z, color = "green")plt.title("simple 3D scatter plot") # show plotplt.show()
Output :  
Example 2 : For better understanding Let’s take another example. 
Python3
# Import librariesfrom mpl_toolkits import mplot3dimport numpy as npimport matplotlib.pyplot as plt  # Creating datasetz = 4 * np.tan(np.random.randint(10, size =(500))) + np.random.randint(100, size =(500))x = 4 * np.cos(z) + np.random.normal(size = 500)y = 4 * np.sin(z) + 4 * np.random.normal(size = 500) # Creating figurefig = plt.figure(figsize = (16, 9))ax = plt.axes(projection ="3d")   # Add x, y gridlinesax.grid(b = True, color ='grey',        linestyle ='-.', linewidth = 0.3,        alpha = 0.2)  # Creating color mapmy_cmap = plt.get_cmap('hsv') # Creating plotsctt = ax.scatter3D(x, y, z,                    alpha = 0.8,                    c = (x + y + z),                    cmap = my_cmap,                    marker ='^') plt.title("simple 3D scatter plot")ax.set_xlabel('X-axis', fontweight ='bold')ax.set_ylabel('Y-axis', fontweight ='bold')ax.set_zlabel('Z-axis', fontweight ='bold')fig.colorbar(sctt, ax = ax, shrink = 0.5, aspect = 5) # show plotplt.show()
Output :
 
Krishna_Yadav
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Python Dictionary
Taking input in Python
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Concatenation of Elements without Separator in R Programming - paste0() Function - GeeksforGeeks

01 Jun, 2020
paste0() function in R Language is used to concatenate all elements without separator.
Syntax: paste0(..., collapse = NULL)
Parameters:...: one or more R objects, to be converted to character vectors.collapse: an optional character string to separate the results.
Example 1:
# R program to illustrate# paste0 function  # Calling paste0() functionpaste0("GFG", "gfg")paste0("GFG", " gfg")paste0(letters[1:4])
Output :
[1] "GFGgfg"
[1] "GFG gfg"
[1] "a" "b" "c" "d"

Example 2:
# R program to illustrate# paste0 function  # Calling paste0() functionpaste0(letters[1:6], collapse ="-")paste0("G", 1:5)
Output:
[1] "a-b-c-d-e-f"
[1] "G1" "G2" "G3" "G4" "G5"

R String-Functions
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to import an Excel File into R ?
How to filter R dataframe by multiple conditions?
Replace Specific Characters in String in R
Time Series Analysis in R
R - if statement
D3.js time.tickFormat() Function - GeeksforGeeks

23 Aug, 2020
The time.tickFormat() function in D3.js is used to return a time format function suitable for displaying tick values. It returns the default time format when the specifier is not specified.
Syntax:
time.tickFormat( count, specifier )
Parameters: This function accepts two parameters as given above and described below:
count: It specifies the number of tick values.
specifier: It is the string that will be used as the specifier. It is of the format type “s”.
Return Values: This function does not return anything.
Below programs illustrate the time.tickFormat() function in D3.js:
Example 1:
HTML
<!DOCTYPE html><html>  <head>    <script src="https://d3js.org/d3.v4.min.js">    </script>    <script src="https://d3js.org/d3-color.v1.min.js">    </script>    <script src=    "https://d3js.org/d3-interpolate.v1.min.js">    </script>    <script src=    "https://d3js.org/d3-scale-chromatic.v1.min.js">    </script></head>  <body>    <h1 style="color: green">GeeksforGeeks</h1>      <p>time.tickFormat() Function </p>      <script>        var time = d3.scaleTime()              // Specify the domain and range            .domain([2001 - 01 - 01, 2005 - 01 - 02])            .range([1, 100]);          var ticks = time.ticks(1);          // Specify the format of the ticks        var tickFormat = time.tickFormat(1, "%Y-%m-%d ");          document.write("<h3>" +            ticks.map(tickFormat) + "</h3>");    </script></body>  </html>
Output:
Example 2:
HTML
<!DOCTYPE html><html>  <head>    <script src="https://d3js.org/d3.v4.min.js">    </script>    <script src="https://d3js.org/d3-color.v1.min.js">    </script>    <script src=    "https://d3js.org/d3-interpolate.v1.min.js">    </script>    <script src=    "https://d3js.org/d3-scale-chromatic.v1.min.js">    </script></head>  <body>    <h1 style="color: green">GeeksforGeeks</h1>      <p>time.tickFormat() Function </p>      <script>        var time = d3.scaleTime()              // Specify the domain and range            .domain([2001 - 01 - 01, 2005 - 01 - 02])            .range([1, 100]);          var ticks = time.ticks(1);          // Specify the format of the ticks        var tickFormat = time.tickFormat(0, "%I %p");          document.write("<h3>" +            ticks.map(tickFormat) + "</h3>");    </script></body>  </html>
Output:
D3.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
Remove elements from a JavaScript Array
How to get character array from string in JavaScript?
How to get selected value in dropdown list using JavaScript ?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Convert long primitive to Long object in Java

To convert long primitive to Long object, follow the below steps.
Let’s say the following is our long primitive.
// primitive
long val = 45;
System.out.println("long primitive: "+val);
Now, to convert it to Long object is not a tiresome task. Include the same long value while creating a new Long object −
// object
Long myObj = new Long(val);
System.out.println("Long object: "+myObj);
The following is the complete example −
 Live Demo
public class Demo {
   public static void main(String[] args) {
      // primitive
      long val = 45;
      System.out.println("long primitive: "+val);
      // object
      Long myObj = new Long(val);
      System.out.println("Long object: "+myObj);
   }
}
long primitive: 45
Long object: 45
Python 3 - String zfill() Method

The zfill() method pads string on the left with zeros to fill width.
Following is the syntax for zfill() method −
str.zfill(width)

width − This is final width of the string. This is the width which we would get after filling zeros.
This method returns padded string.
The following example shows the usage of zfill() method.
#!/usr/bin/python3

str = "this is string example....wow!!!"
print ("str.zfill : ",str.zfill(40))
print ("str.zfill : ",str.zfill(50))
When we run above program, it produces the following result −
str.zfill :  00000000this is string example....wow!!!
str.zfill :  000000000000000000this is string example....wow!!!


    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
Lodash | _.xor() Method

08 May, 2020
The _.xor() method returns an array of the symmetric difference of given arrays i.e. it will create an array that contains an element that doesn’t exist in any other array.
Syntax:
_.xor( arrays )
Parameters: This function accepts one or more parameters as mentioned above and described below:
arrays: This parameter holds one or more arrays that need to inspect.
Return Value: It returns an array of symmetric difference of given arrays.
Example 1:
const _ = require('lodash');  let x = [3, 10, 100];  let y = [100, 10, 2];  let symmetricDifference = _.xor(x, y);  console.log(symmetricDifference);
Here, const _ = require('lodash') is used to import the lodash library into the file.
Output:
[ 3, 2 ]

Example 2:
const _ = require('lodash');  let x = [3, 10, 100];  let y = [100, 10, 2];  let z = [10, 500, 3];  let symmetricDifference = _.xor(x, y, z);  console.log(symmetricDifference);
Output:
[ 2, 500 ]

Example 3:
const _ = require('lodash');  let js = ['web', 'mobile-app'];  let python = ['machine-learning', 'web'];  let c = ['basic-programming', 'system-app'];  let java = ['mobile-app', 'web', 'basic-programming'];  let symmetricDifference = _.xor(js, python, c, java);  console.log(symmetricDifference);
Output:
[ 'machine-learning', 'system-app' ]

Note: This will not work in normal JavaScript because it requires the library lodash to be installed.
Reference: https://lodash.com/docs/4.17.15#xor
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Pattern flags() method in Java with examples

The pattern class of java.regex package is a compiled representation of a regular expression.
The compile() method of this class accepts a string value representing a regular expression and returns a Pattern object, the following is the signature of this method.
static Pattern compile(String regex)
Another variant of this method accepts an integer value representing flags, following is the signature of the compile method with two parameters.
static Pattern compile(String regex, int flags)
The Pattern class provides various fields each representing a flag
The flags() method of this class returns the flag used in the current pattern.
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class COMMENTES_Example {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter your name: ");
      String name = sc.nextLine();
      System.out.println("Enter your Date of birth: ");
      String dob = sc.nextLine();
      //Regular expression to accept date in MM-DD-YYY format
      String regex = "^(1[0-2]|0[1-9])/ # For Month\n" + "(3[01]|[12][0-9]|0[1-9])/ # For Date\n"
+ "[0-9]{4}$ # For Year";
      //Creating a Pattern object
      Pattern pattern = Pattern.compile(regex, Pattern.COMMENTS);
      //Creating a Matcher object
      Matcher matcher = pattern.matcher(dob);
      boolean result = matcher.matches();
      if(result) {
         System.out.println("Given date of birth is valid");
      } else {
         System.out.println("Given date of birth is not valid");
      }
      System.out.println("Flag used: "+ pattern.flags());
   }
}
Enter your name:
Krishna
Enter your Date of birth:
09/26/1989
Given date of birth is valid
Flag used: 4
Find uncommon characters of the two strings in C++ Program

In this tutorial, we are going to learn how to find distinct characters from the given two strings. Let's see an example.
Input 
string_one = "tutorialspoint"
string_two = "tutorialsworld"
Output
d n p w
We are going to use hashing to solve the problem. It's more efficient than writing two nested loop
Let's see the steps to solve the program.
Initialize the two strings with some random values.
Initialize the two strings with some random values.
Initialize a map as map<char, int> chars.
Initialize a map as map<char, int> chars.
Iterate over the first string and insert each character into map with value 1.
Iterate over the first string and insert each character into map with value 1.
Now, iterate over the second string.Check whether the character is already present or not.If present, assign 0 to it.If not present insert the character with value 1.
Now, iterate over the second string.
Check whether the character is already present or not.
Check whether the character is already present or not.
If present, assign 0 to it.
If present, assign 0 to it.
If not present insert the character with value 1.
If not present insert the character with value 1.
Iterate over the map and print characters with value 1.
Iterate over the map and print characters with value 1.
See the code below.
 Live Demo
#include <bits/stdc++.h>
#include <map>
using namespace std;
void findDistinctCharacters(string one, string two){
   // initializing char presence in string
   map<char, int> chars;
   // iterating over the first string
   for (int i = 0; i < one.size(); ++i){
      // inserting every character into map
      chars.insert({one[i], 1});
   }
   // iterating over the second string
   for (int i = 0; i < two.size(); ++i){
      // checking whether the current char in string or not
      if (chars.count(two[i])) {
         // assigning 0 for common chars
         chars.find(two[i])->second = 0;
      }
      else {
         // insering new chars
         chars.insert({two[i], 1});
      }
   }
   // printing the distinct characters
   for (auto item: chars){
      // checking the presence
      if (item.second == 1) {
         // printing the distinct char
         cout << item.first << " ";
      }
   }
}
int main(){
   string one = "tutorialspoint";
   string two = "tutorialsworld";
   findDistinctCharacters(one, two);
   return 0;
}
If you run the above code, you will get the following result.
d n p w
If you have any queries in the tutorial, mention them in the comment section.
Pattern asPredicate() Method in Java with Examples - GeeksforGeeks

06 Mar, 2019
asPredicate() method of a Pattern class used to creates a predicate object which can be used to match a string.Predicate is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Syntax:
public Predicate asPredicate()

Parameters: This method accepts nothing as parameter.
Return value: This method returns a predicate which can be used for matching on a string.
Below programs illustrate the toString() method:
Program 1:
// Java program to demonstrate// Pattern.splitAsStream(CharSequence input) method  import java.util.regex.*;import java.util.function.*;  public class GFG {    public static void main(String[] args)    {        // create a REGEX String        String REGEX = "ee";          // create the string        // in which you want to search        String actualString            = "aaeebbeecceeddee";          // create a Pattern using REGEX        Pattern pattern            = Pattern.compile(REGEX);          // get Predicate Object        Predicate<String> predicate            = pattern.asPredicate();          // check whether predicate match        // with actualString        boolean value = predicate                            .test(actualString);          // print result        System.out.println("value matched: "                           + value);    }}
value matched: true

Program 2:
// Java program to demonstrate// Pattern.splitAsStream(CharSequence input) method  import java.util.regex.*;import java.util.function.*;public class GFG {    public static void main(String[] args)    {        // create a REGEX String        String REGEX = "org";          // create the string        // in which you want to search        String actualString            = "welcome geeks";          // create a Pattern using REGEX        Pattern pattern            = Pattern.compile(REGEX);          // get Predicate Object        Predicate<String> predicate            = pattern.asPredicate();          // check whether predicate match        // with actualString        boolean value            = predicate.test(actualString);          // print result        System.out.println("value matched: "                           + value);    }}
value matched: false

Reference: https://docs.oracle.com/javase/10/docs/api/java/util/regex/Pattern.html#asPredicate()
Java - util package
Java-Functions
Java-Pattern
java-regular-expression
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
Interfaces in Java
How to iterate any Map in Java
ArrayList in Java
Initialize an ArrayList in Java
Stack Class in Java
Multidimensional Arrays in Java
Singleton Class in Java
Set in Java
How to Find Recently Modified Files in Linux? - GeeksforGeeks

20 Apr, 2021
Here we are going to see how to find recent or today’s modified files in Linux. Locating files with a particular name is one of the problems Linux user’s faces, it would be easier when you actually know the filename.
let’s assume that you have created a file in your home folder and you have forgotten the name of the file which also contains some more files and now you want to use it then below are the ways of listing all files that you created or modified today.
Method 1: Using stat command.
Stat command can be used to display timestamps of a file.
Syntax :
stat [File_Name]
Example 2: Using the ls command.
By using this command you can list only today’s files in your home folder.
Syntax :
# ls  -al --time-style=+%D | grep 'date +%D'
Where:
-a – lists all files(including hidden files)
-l – enables listing format
–time-style=FORMAT – shows time in the specified FORMAT
+%D – show/use date in %m/%d/%y format
If you want to list the files which are sorted alphabetically.
Syntax :
# ls -alX --time-style=+%D | grep 'date +%D'
If you want to list the files based on size.
Syntax :
# ls -alS --time-style=+%D | grep 'date +%D'
Example 3: Using the find command
Syntax :
# find . -maxdepth 1 -newermt "date"
Date format yyyy-dd-mm.
-maxdepth level is used to specify the level
-newerPQ, if timestamp P of the file is newer than timestamp Q of the file reference. P and Q may represent any of the letters below
a – access time of the file reference
B – birth time of the file reference
c – inode status change time of reference
m – modification time of the file reference
t – reference is interpreted directly as a time
Picked
How To
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install FFmpeg on Windows?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Set Git Username and Password in GitBash?
How to create a nested RecyclerView in Android
How to Install Jupyter Notebook on MacOS?
Sed Command in Linux/Unix with examples
AWK command in Unix/Linux with examples
grep command in Unix/Linux
cut command in Linux with examples
cp command in Linux with examples
Lex Program For checking a valid URL - GeeksforGeeks

02 May, 2019
Problem: Write a Lex program for checking a valid URL.
Explanation:Lex is a computer utility that generates some lexical analyzers. Lex reads a stream of characters as input specifying the lexical analyzer and give source code as the output implementing the lexer in the C programming language.
Prerequisite: Flex (Fast Lexical Analyzer Generator)
Examples:
Input: geeksforgeeks 
Output: INVALID URL

Input: https://www.geeksforgeeks.org
Output: VALID URL 
Implementation:
%%((http)|(ftp))s?:\/\/[a-zA-Z0-9]{2, }(\.[a-z]{2, })       +(\/[a-zA-Z0-9+=?]*)* {printf("\nURL Valid\n");}  .+ {printf("\nURL Invalid\n");}  %%     // driver programvoid main()  {    printf("\nEnter URL : ");    yylex();    printf("\n"); }
Output:
Lex program
Compiler Design
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Symbol Table in Compiler
Code Optimization in Compiler Design
Directed Acyclic graph in Compiler Design (with examples)
Intermediate Code Generation in Compiler Design
Syntax Directed Translation in Compiler Design
Introduction of Compiler Design
Types of Parsers in Compiler Design
Ambiguous Grammar
Difference between Compiler and Interpreter
Shift Reduce Parser in Compiler