code-rag-bench/online-tutorials huggingface dataset:
Seaborn - Statistical Estimation

In most of the situations, we deal with estimations of the whole distribution of the data. But when it comes to central tendency estimation, we need a specific way to summarize the distribution. Mean and median are the very often used techniques to estimate the central tendency of the distribution.
In all the plots that we learnt in the above section, we made the visualization of the whole distribution. Now, let us discuss regarding the plots with which we can estimate the central tendency of the distribution.
The barplot() shows the relation between a categorical variable and a continuous variable. The data is represented in rectangular bars where the length the bar represents the proportion of the data in that category.
Bar plot represents the estimate of central tendency. Let us use the ‘titanic’ dataset to learn bar plots.
import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
df = sb.load_dataset('titanic')
sb.barplot(x = "sex", y = "survived", hue = "class", data = df)
plt.show()

In the above example, we can see that the average number of survivals of male and female in each class. From the plot we can understand that more number of females survived than males. In both males and females more number of survivals are from first class.
A special case in barplot is to show the no of observations in each category rather than computing a statistic for a second variable. For this, we use countplot().
import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
df = sb.load_dataset('titanic')
sb.countplot(x = " class ", data = df, palette = "Blues");
plt.show()

Plot says that, the number of passengers in the third class are higher than first and second class.
Point plots serve same as bar plots but in a different style. Rather than the full bar, the value of the estimate is represented by the point at a certain height on the other axis.
import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
df = sb.load_dataset('titanic')
sb.pointplot(x = "sex", y = "survived", hue = "class", data = df)
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
DateTime.FromFileTime() Method in C#

The DateTime.FromFileTime() method in C# is used to convert the specified Windows file time to an equivalent local time.
Following is the syntax −
public static DateTime FromFileTime (long fileTime);
Above, the parameter lifetime is a Windows file time expressed in ticks.
Let us now see an example to implement the DateTime.FromFileTime() method −
using System;
public class Demo {
   public static void Main() {
      DateTime d1 = DateTime.FromFileTime(100000000000);
      System.Console.WriteLine("DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",d1);
   }
}
This will produce the following output −
DateTime = 01 January 1601, 02:46:40
Let us now see another example to implement the DateTime.FromFileTime() method −
using System;
public class Demo {
   public static void Main() {
      DateTime d1 = DateTime.FromFileTime(0);
      System.Console.WriteLine("DateTime = {0:dd} {0:y}, {0:hh}:{0:mm}:{0:ss} ",d1);
   }
}
This will produce the following output −
DateTime = 01 January 1601, 12:00:00
Standard Error in Excel - GeeksforGeeks

16 Aug, 2021
The standard error tells that how accurate the mean of any given sample from that population is likely to be compared to the true population mean. 
Formula:
Standard Error=Standard Deviation/sqrt(n)
Where
n= No. of samples.
Let’s follow the below steps and take a look at an example:
Step 1:  The dataset is given as follow:
Step 2:  Now for calculating the standard error we have to find the mean, standard deviation.
Step 3: Here we are calculating the standard deviation. And we have selected the rows whose standard deviation we have to calculate.
Step 4:  Now for calculating the standard error we have divided the standard deviation with the square root of no. of samples. The no. of samples here are 12.
This is the way by which we have calculated the standard error. In this mean was optional.
Excel-Charts
Picked
Excel
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Use Solver in Excel?
How to Find the Last Used Row and Column in Excel VBA?
How to Show Percentages in Stacked Column Chart in Excel?
Introduction to Excel Spreadsheet
Macros in Excel
How to Get Length of Array in Excel VBA?
How to Sum Values Based on Criteria in Another Column in Excel?
Excel Dynamic Chart Linked with a Drop-down List
How to Read Data From Text File in Excel VBA?
Using CHOOSE Function along with VLOOKUP in Excel
How to write plot description outside plot in facetted plot using ggplot2 in R?

To write plot description outside plot using ggplot2, we can use annotate function and coord_cartesian function. The annotate function will define the plot description and the coord_cartesian function will define the position of the text outside the plot area.
Check out the below given example to understand how it works.
Following snippet creates a sample data frame −
x<-rnorm(20)
y<-rnorm(20)
grp<-sample(LETTERS[1:4],20,replace=TRUE)
df<-data.frame(x,y,grp)
df
The following dataframe is created −
      x            y         grp
1   0.78077456  -1.46198018  D
2  -0.49452689   1.72471204  D
3  -1.39619653  -0.64859852  C
4  -0.73260404   0.79430612  A
5   0.83483420  -0.12772415  D
6  -1.42229860  -0.09636467  C
7   0.02591011   2.35094791  C
8   0.02007910  -0.64553958  D
9   0.78893141   0.89014539  B
10  0.28600357  -0.37031710  C
11 -1.69337019  -0.31425710  D
12  2.08396139  -1.14526981  D
13  0.74312431  -0.68121481  C
14  1.33009148   0.61906318  B
15  0.75865211   0.10783624  C
16 -0.82221628  -0.32764999  B
17 -0.28765766  -2.32935412  D
18 -1.30783428   0.48349510  B
19  2.32201111  -0.25456548  D
20 -1.50377138  -1.37306174  D
To load ggplot2 package and create facetted scatterplot between x and y with plot description outside the plot area, add the following code to the above snippet −
library(ggplot2) ggplot(df,aes(x,y))+geom_point()+facet_grid(.~grp)+labs(tag="Groupwise Scatterplot")+coord_cartesian(xlim=c(-3,3),ylim=c(-3,3),clip = "off")
If you execute all the above given snippets as a single program, it generates the following output −
Selenium versus BeautifulSoup for Web Scraping.

We can perform web scraping with Selenium webdriver and BeautifulSoup. Web Scraping is used to extract content from a page. In Python, it is achieved with the BeautifulSoup package.
Let us scrap and get the below links on a page −
Let us also see the html structure of the above links −
Let us see how to do web scraping with BeautifulSoup
To install the required package for Beautifulsoup, we should run the below commands −
pip install bs4
pip install requests
from bs4 import BeautifulSoup
import requests
#get all response
d=requests.get("https://www.tutorialspoint.com/about/about_careers.htm")
#response content whole page in html format
s = BeautifulSoup(d.content, 'html.parser')
#access to specific ul element with BeautifulSoup methods
l = s.find('ul', {'class':'toc reading'})
#access all children of ul
rs = l.findAll('li')
   for r in rs:
      #get text of li elements
         print(r.text)
Now, let us see how to do web scraping with Selenium along with BeautifulSoup.
To have BeautifulSoup along with Selenium, we should run the command −
pip install bs4 selenium
from selenium import webdriver
from bs4 import BeautifulSoup
#path of chromedriver.exe
driver = webdriver.Chrome (executable_path="C:\\chromedriver.exe")
#launch browser
driver.get ("https://www.tutorialspoint.com/about/about_careers.htm")
#content whole page in html format
s = BeautifulSoup(driver.page_source, 'html.parser')
#access to specific ul element with BeautifulSoup methods
l = s.find('ul', {'class':'toc reading'})
#get all li elements under ul
rs = l.findAll('li')
for r in rs:
   #get text of li elements
      print(r.text)
Puppeteer - Element Handling

We can handle elements on page with Puppeteer. Once we navigate to a webpage, we have to interact with the webelements available on the page like clicking a link/button, entering text within an edit box, and so on to complete our automation test case.
For this, our first job is to identify the element. To get the property of an element uniquely we need to inspect it (right-click on the element then select the option Inspect). The ElementHandle objects are created by the methods - page.$, page.$$ and page.$x. These objects refer to an element or tag in a page.
These methods are listed below −
page.$(locator value)
This method yields a Promise with the ElementHandle. The ElementHandle is an object of the identified element. If there are multiple elements having the same locator value, then only the first matching element from the top left corner of the page shall be returned.
page.$$(locator value)
This method yields a Promise with an array of ElementHandle. If there are multiple elements having the same locator value, then all matching elements shall be returned in the form of an array.
page.$x(xpath value)
This method yields a Promise with an array of ElementHandle. If there are multiple elements having the same xpath value, then all matching elements shall be returned in the form of an array. In case, there is one matching element, then the array returned shall have a single element.
The ElementHandle methods like elementHandle.$, elementHandle.$$ and elementHandle.$x can be applied to an element. In that case, an element shall be searched within the DOM of the present ElementHandle and not in the entire DOM.
In the below image, let us take the example of an element having the li tag (having a parent element ul) and class attribute value as heading. To identify it using the ElementHandle method on the page, the expression should be as follows −
const n = await page.$(".heading")

To identify it using the ElementHandle method on an element, the expression should be as follows −
const m = await page.$("ul") 
const p = await m.$(".heading")

Now, refer the image given below of an element having the li tag
The types of locators in Puppeteer are listed below −
ID
ID
Class
Class
Type
Type
Xpath
Xpath
Attribute
Attribute
Type
Type
To work with the above locators we should have the basic understanding of HTML code. Let us take an example of an edit box having the below mentioned properties −
Here, input is the tagname. A tag in HTML may or may not have attributes. The type, class, name, id and so on are the attributes of the element.
For example, in the expression class = "gsc-input", text to the left of = is the attribute name (class) and to the right of = is the attribute value (gsc-input).
An attribute may or may not have a value assigned. Also, if a value is assigned, then it should be enclosed in double or single quotes. The value of an attribute is set by a developer as per his choice.
 Print
 Add Notes
 Bookmark this page
How to filter rows in Pandas by regex?

A regular expression (regex) is a sequence of characters that define a search pattern. To filter rows in Pandas by regex, we can use the str.match() method.
Create a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.
Print the input DataFrame, df.
Initialize a variable regex for the expression. Supply a string value as regex, for example, the string 'J.*' will filter all the entries that start with the letter 'J'.
Use df.column_name.str.match(regex) to filter all the entries in the given column name by the supplied regex.
import pandas as pd

df = pd.DataFrame(
   dict(
      name=['John', 'Jacob', 'Tom', 'Tim', 'Ally'],
      marks=[89, 23, 100, 56, 90],
      subjects=["Math", "Physics", "Chemistry", "Biology", "English"]
   )
)

print "Input DataFrame is:\n", df

regex = 'J.*'
print "After applying ", regex, " DataFrame is:\n", df[df.name.str.match(regex)]

regex = 'A.*'
print "After applying ", regex, " DataFrame is:\n", df[df.name.str.match(regex)]
Input DataFrame is:

     name    marks   subjects
0    John     89        Math
1   Jacob     23     Physics
2     Tom    100   Chemistry
3     Tim     56     Biology
4    Ally     90     English

After applying J.* DataFrame is:

    name   marks   subjects
0   John     89        Math
1  Jacob     23     Physics

After applying A.* DataFrame is:

    name   marks   subjects
4   Ally     90     English
Java Program to convert Character Array to IntStream - GeeksforGeeks

11 Dec, 2018
Given a Character Array, the task is to convert this array into an IntStream containing the ASCII values of the character elements.
Examples:
Input: char[] = { 'G', 'e', 'e', 'k', 's' }
Output: 71, 101, 101, 107, 115

Input: char[] = { 'G', 'e', 'e', 'k', 's', 'F', 'o', 'r', 'G', 'e', 'e', 'k', 's' }
Output: 71, 101, 101, 107, 115, 70, 111, 114, 71, 101, 101, 107, 115

Algorithm:
Get the Character Array to be converted.Convert it into Stream using Stream.of() method.Convert the formed Stream into IntStream using flatMapToInt() method.Print the formed IntStream.
Get the Character Array to be converted.
Convert it into Stream using Stream.of() method.
Convert the formed Stream into IntStream using flatMapToInt() method.
Print the formed IntStream.
Below is the implementation of the above approach:
// Java program to convert// Character Array to IntStream  import java.util.stream.*;  class GFG {    public static void main(String[] args)    {          // Get the Character Array to be converted        Character charArray[] = { 'G', 'e', 'e', 'k', 's' };          // Convert charArray to IntStream        IntStream            intStream            = Stream                    // Convert charArray into Stream of characters                  .of(charArray)                    // Convert the Stream of characters into IntStream                  .flatMapToInt(IntStream::of);          // Print the elements of the IntStream        System.out.println("IntStream:");        intStream.forEach(System.out::println);    }}
Output:
IntStream:
71
101
101
107
115

Java - util package
Java-Array-Programs
Java-Arrays
java-intstream
Java-Stream-programs
Java
Java Programs
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Interfaces in Java
ArrayList in Java
Multidimensional Arrays in Java
Stack Class in Java
Set in Java
Initializing a List in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
How to Iterate HashMap in Java?
Amazon Interview Experience (Telephonic Interview) - GeeksforGeeks

15 Jul, 2019
Question1: Introduce yourselfQuestion2: Can you tell me about any scenario where you have taken an initiative in your previous jobs to do something/ solve something that was not strictly required of you.Question3: Coding on shared editor (no compilation of code required but no pseudocode)
There is a village with two kinds of people- villagers (represented by 0) and defenders (represented by 1). When enemy attacks the defenders stand in front as shown below:
110000
100000
111000
110000

The enemy will attack in that row which is most vulnerable (i.e. has the least number of defenders. Write a program to find the row where the enemy will attack.When I provided an O(mxn) solution I was asked to provide a better solution. And O(m+n) solution is possible.Practice hereQuestion4: Design a basic LRU cache using basic data structures.
Amazon
Experienced
Interview Experiences
Amazon
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Amazon Interview Experience for SDE1 (8 Months Experienced) 2022
Infosys Interview Experience for Java Backend Developer (3-5 Years Experienced)
Paypal Interview Experience for SSE
Amazon Interview Experience for System Development Engineer (Exp - 6 months)
Goldman Sachs Interview Experience for Java Developer (3+ Years Experienced)
Amazon Interview Questions
Microsoft Interview Experience for Internship (Via Engage)
Commonly Asked Java Programming Interview Questions | Set 2
Amazon Interview Experience for SDE-1 (On-Campus)
Infosys Interview Experience for DSE - System Engineer | On-Campus 2022
Converting two arrays into a JSON object in JavaScript

Suppose we have two arrays of literals like these −
const options = ['A', 'B', 'C', 'D'];
const values = [true, false, false, false];
We are required to write a JavaScript function that creates and returns a new Array of Objects
from these two arrays, like this −
const response = [
   {opt: 'A', val: true},
   {opt: 'B', val: false},
   {opt: 'C', val: false},
   {opt: 'D', val: false},
];
Therefore, let’s write the code for this function −
The code for this will be −
const options = ['A', 'B', 'C', 'D'];
const values = [true, false, false, false];
const mapArrays = (options, values) => {
   const res = [];
   for(let i = 0; i < options.length; i++){
      res.push({
         opt: options[i],
         val: values[i]
      });
   };
   return res;
};
console.log(mapArrays(options, values));
The output in the console will be −
[
   { opt: 'A', val: true },
   { opt: 'B', val: false },
   { opt: 'C', val: false },
   { opt: 'D', val: false }
]
Java Program to display the contents in JTextArea

The following is an example to display the contents of a text file in JTextArea −
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SwingDemo {
   private JFrame mainFrame;
   private JLabel statusLabel;
   private JPanel controlPanel;
   public SwingDemo() {
      prepareGUI();
   }
   public static void main(String[] args) {
      SwingDemo demo = new SwingDemo();
      demo.showTextAreaDemo();
   }
   private void prepareGUI() {
      mainFrame = new JFrame("Java Swing");
      mainFrame.setSize(400,400);
      mainFrame.setLayout(new GridLayout(3, 1));
      mainFrame.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent windowEvent) {
            System.exit(0);
         }
      });
      statusLabel = new JLabel("",JLabel.CENTER);
      statusLabel.setSize(350,100);
      controlPanel = new JPanel();
      controlPanel.setLayout(new FlowLayout());
      mainFrame.add(controlPanel);
      mainFrame.add(statusLabel);
      mainFrame.setVisible(true);
   }
   private void showTextAreaDemo() {
      JLabel commentlabel= new JLabel("Text = ", JLabel.RIGHT);
      final JTextArea commentTextArea =
      new JTextArea("This is demo text!",5,20);
      JScrollPane scrollPane = new JScrollPane(commentTextArea);
      JButton showButton = new JButton("Show");
      showButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            statusLabel.setText( commentTextArea.getText());
         }
      });
      controlPanel.add(commentlabel);
      controlPanel.add(scrollPane);
      controlPanel.add(showButton);
      mainFrame.setVisible(true);
   }
}
Click on the “Show” button above to display the text −
Prettify your Terminal Text With Termcolor and Pyfiglet | by Khuyen Tran | Towards Data Science

If you are working with Python, you probably print the output on the terminal either to debug or to be informed of the process. However, if the output is lengthy, it is difficult to keep track of the output.
Is there a way that you can make the important terminal output stand out more such as adding color, and enlarging the text like below?
Yes, you can do that with termcolor and pyfiglet. In this tutorial, I will show you how to create something like the above in 1 line of code.
To change the text color, we use a Python library called termcolor. To install termcolor, use
pip install termcolor
Now let’s see how it works! To change a white text into a red text on your terminal, simply use colored(text, 'red') like below
Now you have a red text on your terminal!
You might want to repeat printing some text in red, but you might find it inconvenient to keep repeating the function colored(text, 'red') . Is there an easier way to print text in red?
Yes! You can create a function to print red text like below:
After assigning cprint toprint_red and print_green , you can print red or green by just calling print_red() or print_green() . How cool is that?
Your text is colorful now, but you want it to be bigger and probably “prettier”. How can you do that? That is when pyfiglet comes in handy.
Pyfiglet allows you to take ASCII text and render it in ASCII art fonts like below
Find other fonts here.
To add color to our stylish text, we can combine pyfiglet and termcolor to create pretty text like below:
This is cool! Let’s make something useful with what we have learned.
If you are developing a Python package, it looks much cooler with a welcome message when users first use the package. And it is a plus to have a stylish and colorful text like below!
Imagine you are running a lengthy code to train your model. You might want to make it easier to recognize the text that specifies which model is being used. That is when a big and colorful text will be really useful!
I will use Gist now so you can copy and paste the code below to observe the magic.
Now do the same thing with your script and impress your teammates!
Congratulations! You have just learned how to prettify your terminal text. I hope this will give you the motivation to create a nice terminal output.
Feel free to star and play with the code for this article in this Github repo.
I like to write about basic data science concepts and play with different algorithms and data science tools. You could connect with me on LinkedIn and Twitter.
Star this repo if you want to check out the codes for all of the articles I have written. Follow me on Medium to stay informed with my latest data science articles like these:
Print all subsequences of a string in Python

20 Aug, 2020
Given a string, we have to find out all subsequences of it. A String is a subsequence of a given String, that is generated by deleting some character of a given string without changing its order.Examples:  
Input : abc
Output : a, b, c, ab, bc, ac, abc

Input : aaa
Output : a, aa, aaa


 
Using Pick and Don’t Pick concept :
Python3
def printSubSequences(STR, subSTR=""):    """    function:        To print all subsequences of string        concept:            Pick and Don’t Pick        variables:            STR = string            subSTR = to store subsequence    """    if len(STR) == 0:        print(subSTR, end=" ")        return     # we add adding 1st character in string    printSubSequences(STR[:-1], subSTR + STR[-1])    """    Not adding first character of the string    because the concept of subsequence either    character will present or not    """    printSubSequences(STR[:-1], subSTR)    return  def main():    """    main function to drive code    """    STR = "abc"    printSubSequences(STR)  if __name__ == "__main__":    main() # by itsvinayak
Output:
cba cb ca c ba b a  
pythonic implementations:
Prerequisite: itertools.combinations() module in Python to print all possible combinations  
Python3
# Python Implementation of the approachimport itertools def Sub_Sequences(STR):    combs = []    for l in range(1, len(STR)+1):        combs.append(list(itertools.combinations(STR, l)))    for c in combs:        for t in c:            print (''.join(t), end =' ') # Testing with driver codeif __name__ == '__main__':    Sub_Sequences('abc')
a b c ab ac bc abc


 
itsvinayak
Python list-programs
subsequence
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Count the number of NA values in a DataFrame column in R

26 Mar, 2021
A null value in R is specified using either NaN or NA. In this article, we will see how can we count these values in a column of a dataframe.
Approach
Create dataframe
Pass the column to be checked to is.na() function
Syntax: is.na(column)
Parameter:
column: column to be searched for na values
Returns:
A vector with boolean values, TRUE for NA otherwise FALSE
From the vector add the values which are TRUE
Display this numberHere, 0 means no NA value
Here, 0 means no NA value
Given below are few examples
Example 1:
R
df<-data.frame(x = c(1,2,NA), y = rep(NA, 3))print("dataframe is ")print(df)  print("vector is")vec = is.na(df[,1])print(vec)  count = sum(vec)  print("count of NA in first column is" )print(count)
Output:
Example 2:
R
df<-data.frame(x = c("kapil","rahul",NA,NA), y = c(1,2,NA,3))print("dataframe is ")print(df)  print("vector is")vec = is.na(df[,1])print(vec)  count = sum(vec)  print("count of NA in first column is" )print(count)
Output:
Picked
R DataFrame-Programs
R-DataFrame
R Language
R Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Javascript eval() Function

30 May, 2022
Below is the example of the eval() function.
Example: 
Javascript
<script>    // JavaScript to illustrate eval() function    function func() {         // Original string        var a = 4;        var b = 4;         // Finding the multiplication        var value = eval(new String(a * b));        document.write(value);    }// Driver codefunc();</script>                   
Output:
16
The eval() function is used to evaluates the expression. If the argument represents one or more JavaScript statements, eval() evaluates the statements. We do not call eval() to evaluate an arithmetic expression.JavaScript evaluates arithmetic expressions automatically. 
Syntax:
eval(string)
Parameters: This function accept a single parameter as mentioned above and described below:
String: A string representing a JavaScript expression, statement, or sequence of statements. The expression can include variables and properties of existing objects.
Return Value: The completion value of evaluating the given code is returned by using eval(). If the completion value is empty, undefined is returned. 
Below examples illustrate the eval() function in JavaScript: 
Example 1:
Input : eval(new String('2 + 2'));
Output: returns a String object containing "2 + 2"
Input : eval(new String('4 + 4'));
Output: returns a String object containing "4 + 4"
More example codes for the above function are as follows: 
Program 1: 
Javascript
<script>    // JavaScript to illustrate eval() function    function func() {         // Original string        var a = 2;        var b = 2;         // Finding the sum        var value = eval(new String(a + b));        document.write(value);    }// Driver Codefunc();</script>                   
Output:
4
Program 2: 
Javascript
<script>    // JavaScript to illustrate eval() function    function func() {         // Original string        var a        var b         // Finding the Summation        var value = eval(new String(a + b));        document.write(value);    }// Driver codefunc();</script>               
Output:
NaN
Supported Browsers:
Google Chrome
Internet Explorer
Mozilla Firefox
Safari
Opera
surinderdawra388
javascript-functions
Misc
Web Technologies
Misc
Misc
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to write Regular Expressions?
Association Rule
OOPs | Object Oriented Design
std::unique in C++
Software Engineering | Prototyping Model
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
UUID fromString() Method in Java with Examples

27 Dec, 2018
The fromString() method of UUID class in Java is used for the creation of UUID from the standard string representation of the same.
Syntax:
public static UUID fromString(String UUID_name)
Parameters: The method takes one parameter UUID_name which is the string representation of the UUID.
Return Value: The method returns the actual UUID created from the specified string.
Exception: The method throws IllegalArgumentException if an invalid UUID_name is passed.
Below programs illustrate the working of fromString() method:
Program 1:
// Java code to illustrate fromString() method  import java.util.*;  public class UUID_Demo {    public static void main(String[] args)    {          // Get the string        String UUID_name            = "5fc03087-d265-11e7-b8c6-83e29cd24f4c";          // Displaying the UUID        System.out.println("The specified String is: "                           + UUID_name);          // Creating the UUID        UUID UUID_1            = UUID                  .fromString(UUID_name);          // Displaying the UUID        System.out.println("The UUID from"                           + " specified String: "                           + UUID_1);    }}
The specified String is: 5fc03087-d265-11e7-b8c6-83e29cd24f4c
The UUID from specified String: 5fc03087-d265-11e7-b8c6-83e29cd24f4c

Program 2:
// Java code to illustrate fromString() method  import java.util.*;  public class UUID_Demo {    public static void main(String[] args)    {          // Get the string        String UUID_name            = "58e0a7d7-eebc-11d8-9669-0800200c9a66";          // Displaying the UUID        System.out.println("The specified String is: "                           + UUID_name);          // Creating the UUID        UUID UUID_1            = UUID                  .fromString(UUID_name);          // Displaying the UUID        System.out.println("The UUID from"                           + " specified String: "                           + UUID_1);    }}
The specified String is: 58e0a7d7-eebc-11d8-9669-0800200c9a66
The UUID from specified String: 58e0a7d7-eebc-11d8-9669-0800200c9a66

Java - util package
Java-Functions
Java-UUID
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
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
ArrayList in Java
Multidimensional Arrays in Java
Collections in Java
Stream In Java
Set in Java
Singleton Class in Java
Construct a graph from given degrees of all vertices in C++

Suppose we have a list of vertices, and their degrees are given. We have to generate one undirected graph from that degree sequence. It will not include loop or multiple edges. So if the degree sequence is like [2, 2, 1, 1], then the graph can be like
To solve this, we will follow these steps −
Define adjacency matrix adj to store the graph
Define adjacency matrix adj to store the graph
for each vertex i, dofor each vertex j that is valid, and next to iif the degree of vertex i and j are more than zero, then connect them
for each vertex i, do
for each vertex j that is valid, and next to iif the degree of vertex i and j are more than zero, then connect them
for each vertex j that is valid, and next to i
if the degree of vertex i and j are more than zero, then connect them
if the degree of vertex i and j are more than zero, then connect them
display the matrix.
display the matrix.
 Live Demo
#include <iostream>
#include <iomanip>
using namespace std;
void generateGraph(int vert_degree[], int n) {
   int adj_mat[n][n];
   for(int i = 0; i<n; i++){
      for(int j = 0; j < n; j++){
         adj_mat[i][j] = 0;
      }
   }
   for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
         if (vert_degree[i] > 0 && vert_degree[j] > 0) {
            vert_degree[i]--; vert_degree[j]--;
            adj_mat[i][j] = adj_mat[j][i] = 1;
         }
      }
   }
   cout << endl << setw(3) << " ";
   for (int i = 0; i < n; i++)
      cout << setw(3) << "(" << i << ")";
      cout << endl << endl;
   for (int i = 0; i < n; i++) {
      cout << setw(4) << "(" << i << ")";
   for (int j = 0; j < n; j++)
      cout << setw(5) << adj_mat[i][j];
      cout << endl;
   }
}
int main() {
   int vert_degree[] = { 2, 2, 1, 1, 1 };
   int n = sizeof(vert_degree) / sizeof(vert_degree[0]);
   generateGraph(vert_degree, n);
}

      (0)   (1)  (2)  (3)  (4)

(0)    0    1    1    0    0
(1)    1    0    0    1    0
(2)    1    0    0    0    0
(3)    0    1    0    0    0
(4)    0    0    0    0    0
JavaScript - Date getMilliseconds() Method

Javascript date getMilliseconds() method returns the milliseconds in the specified date according to local time. The value returned by getMilliseconds() is a number between 0 and 999.
Its syntax is as follows −
Date.getMilliseconds()

Returns the milliseconds in the specified date according to local time.
Try the following example.
<html>
   <head>
      <title>JavaScript getMilliseconds Method</title>
   </head>
   
   <body>   
      <script type = "text/javascript">
         var dt = new Date( );
         document.write("getMilliseconds() : " + dt.getMilliseconds() ); 
      </script>      
   </body>
</html>

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
CSS Attribute Selector

It is possible to style HTML elements that have specific attributes or attribute values.
The [attribute] selector is used to select elements with a specified 
attribute.
The following example selects all <a> elements with a target attribute:
The [attribute="value"] selector is used to select elements with a specified 
attribute and value.
The following example selects all <a> elements with a target="_blank" attribute:
The [attribute~="value"] selector is used to select elements with an attribute 
value containing a specified word.
The following example selects all elements with a title attribute that 
contains a space-separated list of words, one of which is "flower":
The example above will match elements with title="flower", title="summer 
flower", and title="flower new", but not title="my-flower" or title="flowers".
The [attribute|="value"] selector 
is used to select elements with the specified attribute, whose value can be 
exactly the specified value, or the specified value followed by a hyphen (-).
Note: The value has to be a whole word, either alone, like 
class="top", or followed by a hyphen( - ), like class="top-text".
The [attribute^="value"] selector 
is used to select elements with the specified attribute, whose value starts with 
the specified value.
The following example selects all elements with a class attribute value that 
starts with "top":
Note: The value does not have to be a whole word!
The [attribute$="value"] selector is used to select elements whose attribute 
value ends with a specified value.
The following example selects all elements with a class attribute value that 
ends with "test":
Note: The value does not have to be a whole word!  
The [attribute*="value"] selector is used to select elements whose attribute 
value contains a specified value.
The following example selects all elements with a class attribute value that 
contains "te":
Note: The value does not have to be a whole word!  
The attribute selectors can be useful for styling forms without class or ID:
Tip: Visit our CSS Forms Tutorial for more examples on how to style forms with CSS.
Set the background color to "red" for <a> elements that have a target attribute.
<style>
 {
  background-color: red;
}
</style>

<body>
  <a href="https://w3schools.com">w3schools.com</a>
  <a href="http://disney.com" target="_blank">Disney.com</a>
  <a href="http://wikipedia.org" target="_top">wikipedia.org</a>
</body>

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
H2 Database - Installation

H2 is a database written in Java. We can easily embed this database to our application by using JDBC. We can run this on many different platforms or any version of Java Runtime Environment. However, before installing the database, there should be Java installed in the system.
If JDK is installed in the system, try the following command to verify the Java version.
java –version

If JDk is successfully installed in the system, then we will get the following output.
java version "1.8.0_91" 
Java(TM) SE Runtime Environment (build 1.8.0_91-b14) 
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)

If JDK is not installed in the system, then visit the following link to Install JDK.
We can run this database on many different platforms. In this chapter, we will learn about H2 Database installation on Windows.
Following are the steps to install H2 Database on Windows operating system.
Download the latest version of H2 Database from the given link. In this link, you will get the latest version of H2 database in two types. One is Windows Installer type (that is .exe file) and second is Platform-Independent zip file for other operating systems.
Click the Windows installer for downloading the Windows supportable H2 database after downloading the .exe file. In this case, we are using H2 Database with the version 1.4.192.
After downloading we get the H2 Windows installer file (i.e. h2-setup-yyyy-mm-dd.exe) in the Downloads directory. To start the installation process of H2 Database, double click on the installer file.
The following screen is the first step in the installation process. Provide a path where we want to install the H2 database server as shown in the following screenshot.
As seen in the above screenshot, by default it will take C:\ProgramFiles (x86)\H2 as the destination folder. Click next to proceed to the next step. The following screen pops up.
In the above screenshot, click the Install button to start the installation process. After installation, we get the following screenshot.
Click Finish to complete the installation process.
After installation, let us verify the database installation in the system. Click Windows → type H2 Console → Click H2 console icon. Connect to the URL http://localhost:8082. At the time of connecting, the H2 database will ask for database registration as shown in the following screenshot.
Fill all the details in the above dialog box such as Saved Settings, Settings Name, Driver Class, JDBC URL, User Name, and Password. In the JDBC URL, specify the database is located and the database name. User Name and Password are the fields for user name and password of the database. Click Connect.
The Database welcome page pops up as shown in the following screenshot.

    14 Lectures 
     1 hours 

 Mahesh Kumar

    100 Lectures 
     9.5 hours 

 Hari Om Singh

    108 Lectures 
     8 hours 

 Pavan Lalwani

    10 Lectures 
     1 hours 

 Deepti Trivedi

    20 Lectures 
     2 hours 

 Deepti Trivedi

    14 Lectures 
     1 hours 

 Deepti Trivedi
 Print
 Add Notes
 Bookmark this page
Accessing array values in a MongoDB collection to fetch a specific document

To access array values, use dot(.) notation. Let us create a collection with documents −
> db.demo326.insertOne({id:101,"ProductDetails":[{"ProductId":"Prod-101","ProductName":"Product-1"},
... {"ProductId":"Prod-102","ProductName":"Product-2"}
... ]
... }
... );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e516751f8647eb59e562074")
}
> db.demo326.insertOne({id:103,"ProductDetails":[{"ProductId":"Prod-104","ProductName":"Product-5"},
... {"ProductId":"Prod-105","ProductName":"Product-6"}
... ]
... }
... );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e516771f8647eb59e562075")
}
Display all documents from a collection with the help of find() method −
> db.demo326.find();
This will produce the following output −
{
   "_id" : ObjectId("5e516751f8647eb59e562074"), "id" : 101, "ProductDetails" : [
      { "ProductId" : "Prod-101", "ProductName" : "Product-1" },
      { "ProductId" : "Prod-102", "ProductName" : "Product-2" }
   ]
}
{
   "_id" : ObjectId("5e516771f8647eb59e562075"), "id" : 103, "ProductDetails" : [
      { "ProductId" : "Prod-104", "ProductName" : "Product-5" },
      { "ProductId" : "Prod-105", "ProductName" : "Product-6" }
   ]
}
Following is the query to access the array in a MongoDB collection and fetch a specific document −
> db.demo326.find({"ProductDetails.ProductId":"Prod-104"});
This will produce the following output −
{
   "_id" : ObjectId("5e516771f8647eb59e562075"), "id" : 103, "ProductDetails" : [
      { "ProductId" : "Prod-104", "ProductName" : "Product-5" },
      { "ProductId" : "Prod-105", "ProductName" : "Product-6" }
   ] 
}
HTML | <script> src Attribute - GeeksforGeeks

16 Oct, 2019
The HTML <script> src Attribute is used to specify the URL of external JavaScript file. The External JavaScript file is used to run on the same script on several pages on a website. We can save the JavaScript file with an extension of .js. We can refer the external script using the src attribute of the <script> element.
Syntax:
<script src="URL">
Attribute Values: It contains single value URL which specifies the URL of the external JavaScript file. There are two types of URL link which are listed below:
Absolute URL: It points to another webpage.
Relative URL: It points to other files of the same web page.
Below example illustrates the <script> src attribute in HTML:
Example:
<!DOCTYPE html> <html>   <head>     <title>     HTML  script src Attribute     </title> </head>   <body style="text-align:center;">     <h1>         GeeksForGeeks     </h1>       <h2>         HTML script src Attribute    </h2>       <script id="myGeeks"            type="text/javascript"            src="my_script.js">     </script>     <br>     <button>Submit</button>  </body>   </html> 
Output :
Supported Browsers: The browser supported by HTML <script> src attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
shubham_singh
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
REST API (Introduction)
Design a web page using HTML and CSS
Form validation using jQuery
Angular File Upload
How to Dynamically Add/Remove Table Rows using jQuery ?
Express.js express.Router() Function
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
What is meant by re-throwing exceptions in Java?

When an exception is cached in a catch block, you can re-throw it using the throw keyword (which is used to throw the exception objects).
While re-throwing exceptions you can throw the same exception as it is without adjusting it as −
try {
   int result = (arr[a])/(arr[b]);
   System.out.println("Result of "+arr[a]+"/"+arr[b]+": "+result);
}
catch(ArithmeticException e) {
   throw e;
}
Or, wrap it within a new exception and throw it. When you wrap a cached exception within another exception and throw it, it is known as exception chaining or, exception wrapping, by doing this you can adjust your exception, throwing a higher level of exception maintaining the abstraction.
try {
   int result = (arr[a])/(arr[b]);
   System.out.println("Result of "+arr[a]+"/"+arr[b]+": "+result);
}
catch(ArrayIndexOutOfBoundsException e) {
   throw new IndexOutOfBoundsException();
}
In the following Java example our code in demoMethod() might throw ArrayIndexOutOfBoundsException an ArithmeticException. We are catching these two exceptions in two different catch blocks.
In the catch blocks, we are re-throwing both exceptions one by wrapping within the higher exceptions and the other one directly.
 Live Demo
import java.util.Arrays;
import java.util.Scanner;
public class RethrowExample {
   public void demoMethod() {
      Scanner sc = new Scanner(System.in);
      int[] arr = {10, 20, 30, 2, 0, 8};
      System.out.println("Array: "+Arrays.toString(arr));
      System.out.println("Choose numerator and denominator(not 0) from this array (enter positions 0 to 5)");
      int a = sc.nextInt();
      int b = sc.nextInt();
      try {
         int result = (arr[a])/(arr[b]);
         System.out.println("Result of "+arr[a]+"/"+arr[b]+": "+result);
      }
      catch(ArrayIndexOutOfBoundsException e) {
         throw new IndexOutOfBoundsException();
      }
      catch(ArithmeticException e) {
         throw e;
      }
   }
   public static void main(String [] args) {
      new RethrowExample().demoMethod();
   }
}
Array: [10, 20, 30, 2, 0, 8]
Choose numerator and denominator(not 0) from this array (enter positions 0 to 5)
0
4
Exception in thread "main" java.lang.ArithmeticException: / by zero
   at myPackage.RethrowExample.demoMethod(RethrowExample.java:16)
   at myPackage.RethrowExample.main(RethrowExample.java:25)
Array: [10, 20, 30, 2, 0, 8]
Choose numerator and denominator(not 0) from this array (enter positions 0 to 5)
124
5
Exception in thread "main" java.lang.IndexOutOfBoundsException
   at myPackage.RethrowExample.demoMethod(RethrowExample.java:17)
   at myPackage.RethrowExample.main(RethrowExample.java:23)
Java String hashCode() Method

❮ String Methods

Return the hash code of a string:
String myStr = "Hello";
System.out.println(myStr.hashCode());

Try it Yourself »

The hashCode() method returns the hash code of a string.
The hash code for a String object is computed like this:
s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]

where s[i] is the ith character of the string, n is the length of the string, and ^ indicates exponentiation.
public int hashCode()

None.
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to print a number 100 times without using loop and recursion in C?

10 Oct, 2017
It is possible to solve this problem using loop or a recursion method but what if both are not allowed?
A simple solution is to write the number 100 times in cout statement. A better solution is to use #define directive (Macro expansion)
// CPP program to print "1" 100 times.  // Prints 1 only once#define a cout<<"1"<<endl;  // Puts "a" 10 times#define b a a a a a a a a a a  // Puts "b" 10 times#define c b b b b b b b b b b  int main(){  c;  return 0;}
Output: 100 times 1.
This article is contributed by Aditya Rakhecha. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or 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-puzzle
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.