code-rag-bench/online-tutorials huggingface dataset:
CSS | Percentage Value - GeeksforGeeks

03 Jun, 2020
It represents by <percentage > takes a number as a parameter. It is used to define the relative size to the parent size. With the help of this, you can adjust all the HTML-CSS elements. In CSS, many properties that take a percentage as parameters such as padding, width, height, margin, and font-size.
Syntax:
<Percentage>
It takes a number as parameter followed by percentage sign(%).
The number can be positive and negative but some properties do not accept negative percentages.
Note: No space between number and percentage sign(%) is acceptable.
Example 1:
<!DOCTYPE html><html>  <head>    <style>        div {            border: 1px solid black;            margin: 25% 50% 75% 25%;            background-color: lightblue;        }    </style></head>  <body>    <h2>CSS Value Percentage</h2>      <div>        This div element has a top margin        of 25%, a right margin of 50%, a         bottom margin of 75%, and a left         margin of 25%.    </div>    <hr /></body>  </html>
Output:
Example 2:
<!DOCTYPE html><html>  <head>    <title>        CSS | Percentage Value    </title></head>  <body>    <h2>CSS Value Percentage</h2>      <!-- size of text is 18px -->    <div style="font-size: 18px;">          <p>GeeksForGeeks</p>          <!-- Size of text is 50% of 18px -->        <p><span style="font-size: 50%;">                GeeksForGeeks            </span>        </p>          <!-- Size of text is 200% of 18px -->        <p><span style="font-size: 200%;">                GeeksForGeeks            </span>        </p>    </div>      <hr /></body>  </html>
Output:
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
CSS-Basics
HTML-Misc
Picked
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to set space between the flexbox ?
Design a web page using HTML and CSS
Form validation using jQuery
How to style a checkbox using CSS?
Search Bar using HTML, CSS and JavaScript
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
What are implicit and explicit type conversions in C language?

Converting one data type into another data type is called type conversions.
Implicit type conversion
Explicit type conversion
The compiler provides implicit type conversions when operands are of different data types.
The compiler provides implicit type conversions when operands are of different data types.
It is automatically done by the compiler by converting smaller data type into a larger data type.
It is automatically done by the compiler by converting smaller data type into a larger data type.
int i,x;
float f;
double d;
long int l;
Here, the above expression finally evaluates to a ‘double’ value.
Following is an example for implicit type conversion −
int x;
for(x=97; x<=122; x++){
   printf("%c", x); /*Implicit casting from int to char %c*/
}
Explicit type conversion is done by the user by using (type) operator.
Explicit type conversion is done by the user by using (type) operator.
Before the conversion is performed, a runtime check is done to see if the destination type can hold the source value.
Before the conversion is performed, a runtime check is done to see if the destination type can hold the source value.
int a,c;
float b;
c = (int) a + b
Here, the resultant of ‘a+b’ is converted into ‘int’ explicitly and then assigned to ‘c’.
Following is an example for explicit type conversion −
int x;
for(x=97; x<=122; x++){
   printf("%c", (char)x); /*Explicit casting from int to char*/
}
Let us see the difference between the two types of conversions with examples −
 Live Demo
#include<stdio.h>
main(){
   int i=40;
   float a;
   //Implicit conversion
   a=i;
   printf("implicit value:%f\n",a);
}
Implicit value:40.000000
 Live Demo
#include<stdio.h>
main(){
   int i=40;
   short a;
   //Explicit conversion
   a=(short)i;
   printf("explicit value:%d\n",a);
}
Explicit value:40
Algorithms | Analysis of Algorithms | Question 19 - GeeksforGeeks

28 Jun, 2021
Which of the given options provides the increasing order of asymptotic complexity of functions f1, f2, f3 and f4?
  f1(n) = 2^n
  f2(n) = n^(3/2)
  f3(n) = nLogn
  f4(n) = n^(Logn)
(A) f3, f2, f4, f1(B) f3, f2, f1, f4(C) f2, f3, f1, f4(D) f2, f3, f4, f1Answer: (A)Explanation:
  f1(n) = 2^n
  f2(n) = n^(3/2)
  f3(n) = nLogn
  f4(n) = n^(Logn)
Except f3, all other are exponential. So f3 is definitely first in output. Among remaining, n^(3/2) is next.
One way to compare f1 and f4 is to take Log of both functions. Order of growth of Log(f1(n)) is Θ(n) and order of growth of Log(f4(n)) is Θ(Logn * Logn). Since Θ(n) has higher growth than Θ(Logn * Logn), f1(n) grows faster than f4(n).
Following is another way to compare f1 and f4.
Let us compare f4 and f1. Let us take few values to compare
n = 32, f1 = 2^32, f4 = 32^5 = 2^25
n = 64, f1 = 2^64, f4 = 64^6 = 2^36
...............
............... 
Also see http://www.wolframalpha.com/input/?i=2^n+vs+n^%28log+n%29
Thanks to fella26 for suggesting the above explanation.
Quiz of this Question
Algorithms-Analysis of Algorithms
Analysis of Algorithms
Algorithms Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Algorithms | Dynamic Programming | Question 2
Algorithms | Dynamic Programming | Question 3
Algorithms Quiz | Dynamic Programming | Question 8
Algorithms | Analysis of Algorithms | Question 17
Algorithms | Recursion | Question 9
Algorithms | Graph Traversals | Question 12
Algorithms | Sorting | Question 5
Algorithms | Sorting | Question 9
Algorithms | Greedy Algorithms | Question 1
Algorithms | NP Complete | Question 4
Download Instagram Reel using Python - GeeksforGeeks

19 Nov, 2021
In this article, we will discuss how to download Instagram reel using Python.
Instagram is a social networking platform owned by Facebook. In Python, there are numbers of libraries available by which we can solve some real-life problems and it also provides some tools to scrape information from Instagram. One of the tools is Instascrape Python Package. Instascrape is the powerful Instagram data scrapping toolkit.  
Install insta-scrape library from PyPI
pip install insta-scrape
To download reels from Instagram first import all the required libraries. In our example, we are importing the time module because while saving the file we will concatenate time with the filename to avoid naming conflict. Now add Session-Id and Headers. Session-Id is valid until you logged out. so when u will next time, again you need to pass a new session-id that time. ( You will get your session-id in Session Storage by Inspecting the page ). It is not that easy to scrape data directly due to updated policies of Instagram so we have to pass the session id into the headers. Using Reel Module and Providing Download Location we can get the job done.
Syntax:
insta_reel=Reel(‘instagram link’)
insta_reel.scrape(headers=headers)
insta_reel.download(download_path.mp4′′)
By following the above procedure, you will get downloaded reel in your specified directory.   
Example: Download Instagram reels using Python
Python3
from instascrape import Reelimport time # session idSESSIONID = "Paste session Id Here" # Header with session idheaders = {    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)\    AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.74 \    Safari/537.36 Edg/79.0.309.43",    "cookie": f'sessionid={SESSIONID};'} # Passing Instagram reel link as argument in Reel Moduleinsta_reel = Reel(    'https://www.instagram.com/reel/CKWDdesgv2l/?utm_source=ig_web_copy_link') # Using  scrape function and passing the headersinsta_reel.scrape(headers=headers) # Giving path where we want to download reel to the# download functioninsta_reel.download(fp=f".\\Desktop\\reel{int(time.time())}.mp4") # printing success Messageprint('Downloaded Successfully.')
Output:
abhishek0719kadiyan
python-modules
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
Selecting rows in pandas DataFrame based on conditions
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Python | Get unique values from a list
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
Add a key:value pair to dictionary in Python - GeeksforGeeks

14 Jan, 2019
Dictionary in Python is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only single value as an element, Dictionary holds key:value pair.
While using Dictionary, sometimes, we need to add or modify the key/value inside the dictionary. Let’s see how to add a key:value pair to dictionary in Python.
Code #1: Using Subscript notation
This method will create a new key:value pair on a dictionary by assigning a value to that key.
# Python program to add a key:value pair to dictionary  dict = {'key1':'geeks', 'key2':'for'} print("Current Dict is: ", dict)     # using the subscript notation # Dictionary_Name[New_Key_Name] = New_Key_Value   dict['key3'] = 'Geeks'dict['key4'] = 'is'dict['key5'] = 'portal'dict['key6'] = 'Computer'print("Updated Dict is: ", dict)
Current Dict is: {‘key2’: ‘for’, ‘key1’: ‘geeks’}Updated Dict is: {‘key3’: ‘Geeks’, ‘key5’: ‘portal’, ‘key6’: ‘Computer’, ‘key4’: ‘is’, ‘key1’: ‘geeks’, ‘key2’: ‘for’}
Code #2: Using update() method
dict = {'key1':'geeks', 'key2':'for'} print("Current Dict is: ", dict)   # adding dict1 (key3, key4 and key5) to dict dict1 = {'key3':'geeks', 'key4':'is', 'key5':'fabulous'} dict.update(dict1)   # by assigning dict.update(newkey1 ='portal') print(dict) 
Current Dict is: {‘key2’: ‘for’, ‘key1’: ‘geeks’}{‘newkey1’: ‘portal’, ‘key4’: ‘is’, ‘key2’: ‘for’, ‘key1’: ‘geeks’, ‘key5’: ‘fabulous’, ‘key3’: ‘geeks’}
Code #3: Taking Key:value as input
# Let's add key:value to a dictionary, the functional way   # Create your dictionary class class my_dictionary(dict):       # __init__ function     def __init__(self):         self = dict()               # Function to add key:value     def add(self, key, value):         self[key] = value   # Main Function dict_obj = my_dictionary()   # Taking input key = 1, value = Geekdict_obj.key = input("Enter the key: ")dict_obj.value = input("Enter the value: ")  dict_obj.add(dict_obj.key, dict_obj.value) dict_obj.add(2, 'forGeeks')   print(dict_obj) 
Output:
 {'1': 'Geeks', 2: 'forGeeks'}
Python dictionary-programs
python-dict
Python
Python Programs
python-dict
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
C program to find sum and difference of two numbers

Suppose we have two integer numbers a, b and two floating point numbers c, d. We shall have to find the sum of a and b as well as c and d. We also have to find the sum of a and c as well. So depending on the printf function style, output may differ.
So, if the input is like a = 5, b = 58 c = 6.32, d = 8.64, then the output will be a + b = 63 c + d = 14.960001 a + c = 11.320000
To solve this, we will follow these steps −
To print a + b, they both are integers, so printf("%d") will work
To print a + b, they both are integers, so printf("%d") will work
To print c + d, they both are floats, so printf("%f") will work
To print c + d, they both are floats, so printf("%f") will work
To print a + c, as one of them is integer and another one is float so we shall have to use printf("%f") to get correct result.
Let us see the following implementation to get better understanding −
#include <stdio.h>
int main(){
    int a = 5, b = 58;
    float c = 6.32, d = 8.64;
    printf("a + b = %d\n", a + b);
    printf("c + d = %f\n", c + d);
    printf("a + c = %f\n", a + c);
}

a = 5, b = 58;
c = 6.32, d = 8.64;
a + b = 63
c + d = 14.960001
a + c = 11.320000
How to SELECT * and rename a column in MySQL?

Let us first create a table −
mysql> create table DemoTable
   (
   Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   Name varchar(20),
   Age int
   );
Query OK, 0 rows affected (1.15 sec)
Insert records in the table using insert command −
mysql> insert into DemoTable(Name,Age) values('John',21);
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable(Name,Age) values('Carol',24);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable(Name,Age) values('David',22);
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable(Name,Age) values('Sam',23);
Query OK, 1 row affected (0.23 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable;
This will produce the following output −
+----+-------+------+
| Id | Name  | Age  |
+----+-------+------+
| 1  | John  | 21   |
| 2  | Carol | 24   |
| 3  | David | 22   |
| 4  | Sam   | 23   |
+----+-------+------+
4 rows in set (0.00 sec)
Following is the query to SELECT * and rename a column −
mysql> select tbl.*,Name AS StudentName from DemoTable tbl;
This will produce the following output −
+----+-------+------+-------------+
| Id | Name  | Age  | StudentName |
+----+-------+------+-------------+
| 1  | John  | 21   | John        |
| 2  | Carol | 24   | Carol       |
| 3  | David | 22   | David       |
| 4  | Sam   | 23   | Sam         |
+----+-------+------+-------------+
4 rows in set (0.00 sec)
Character Class in Java

The Character class wraps a value of the primitive type char in an object. An object of class Character contains a single field whose type is char.
Following are some of the methods of the Character class −
Let us see an example −
 Live Demo
import java.lang.*;
public class Demo {
   public static void main(String[] args){
      System.out.println(Character.isLetter('0'));
      System.out.println(Character.isLetter('h'));
      System.out.println(Character.isLetter('K'));
   }
}
This will produce the following output −
false
true
true
Let us now see another example −
 Live Demo
import java.lang.*;
public class Demo {
   public static void main(String[] args){
      System.out.println(Character.isLetter('0'));
      System.out.println(Character.isLetter('h'));
      System.out.println(Character.isLetter('K'));
      System.out.println(Character.toString('0'));
      System.out.println(Character.toString('H'));
   }
}
This will produce the following output −
false
true
true
0
H
Java Syntax

In the previous chapter, we created a Java file called Main.java, and we used the following code to print "Hello World" to the screen:
Main.java
public class Main {
  public static void main(String[] args) {
    System.out.println("Hello World");
  }
}


Try it Yourself »

Every line of code that runs in Java must be inside a class.
In our example, we named the class Main. A class should always start with 
an uppercase first letter.
Note: Java is case-sensitive: "MyClass" and "myclass" has 
different meaning.
The name of the java file must match the class name.
When saving the file, save it using the class name and add ".java" to the end of 
the filename. To run the example above on your computer, make sure that Java is 
properly installed: Go to the Get Started Chapter for how to install Java. The output should be:
The main() method is required and you will 
see it in every Java 
program:
public static void main(String[] args)

Any code inside the main() method will be executed. 
Don't worry about the keywords before and after main. You will get to know 
them bit by bit while reading this tutorial.
For now, just remember that every Java program has a class name which 
must match the filename, and that every program must contain the 
main() method.
Inside the main() method, we can use the println() 
method to print a line of text to the screen:
public static void main(String[] args) {
  System.out.println("Hello World");
}


Try it Yourself »

Note: The curly braces {} marks the beginning and the end of a block of code.
System is a built-in Java class that contains useful members, such as out, 
  which is short for "output". The println() method, short for 
  "print line", is used to print a value to the screen (or a file).
Don't worry too much about System, out and println(). Just know that you need them 
together to print stuff to the screen.
You should also note that each code statement must end with a semicolon (;).
Insert the missing part of the code below to output "Hello World".
public class MyClass {
  public static void main(String[] args) {
    ..("Hello World");
  }
}

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.
NPDA for accepting the language L = {anb(2n) | n>=1} U {anbn | n>=1} - GeeksforGeeks

25 Jan, 2019
Prerequisite – Pushdown automata, Pushdown automata acceptance by final stateProblem – Design a non deterministic PDA for accepting the language L = {  : n>=1} U {  : n>=1}, i.e.,
L = {abb, aabbbb, aaabbbbbb, aaaabbbbbbbb, ......} 
          U {ab, aabb, aaabbb, aaaabbbb, ......} 
In each string, the number of a’s are followed by double number of b’s or the number of a’s are followed by equal number of b’s.
Explanation –Here, we need to maintain the order of a’s and b’s.That is, all the a’s are are coming first and then all the b’s are coming. Thus, we need a stack along with the state diagram. The count of a’s and b’s is maintained by the stack.We will take 2 stack alphabets:
 = { a, z } 
Where, = set of all the stack alphabetz = stack start symbol
Approach used in the construction of PDA –In designing a NPDA, for every ‘a’ comes before ‘b’. If ‘b’ comes then
For   : Whenever ‘a’ comes, push it in stack and if ‘a’ comes again then also push it in the stack.
For   : Whenever ‘a’ comes, push ‘a’ two time in stack and if ‘a’ comes again then do the same.When ‘b’ comes (remember b comes after ‘a’) then pop one ‘a’ from the stack each time.
So that the stack becomes empty.If stack is empty then we can say that the string is accepted by the PDA.
Stack transition functions –
(q0, a, z)  (q1, az)
(q0, a, z)  (q3, aaz)
(q1, a, a)  (q1, aa)
(q1, b, a)  (q2, ) 
(q2, b, a)  (q2, ) 
(q2, , z)  (qf1, z)   
(q3 a, a)  (q3, aaa)
(q3, b, a)  (q4, ) 
(q4, b, a)  (q4, ) 
(q4, , z)  (qf2, z)   

Where, q0 = Initial stateqf1, qf2 = Final state = indicates pop operation
So, this is our required non deterministic PDA for accepting the language L ={  : n>=1} U {  : n>=1}.
GATE CS
Theory of Computation & Automata
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between Clustered and Non-clustered index
Phases of a Compiler
Regular Expressions, Regular Grammar and Regular Languages
Preemptive and Non-Preemptive Scheduling
Introduction of Process Synchronization
Regular Expressions, Regular Grammar and Regular Languages
Difference between DFA and NFA
Introduction of Finite Automata
Difference between Mealy machine and Moore machine
Pumping Lemma in Theory of Computation
basic_istream::operator>> in C++ - GeeksforGeeks

22 Jul, 2021
The basic_istream::operator>> is known as the extraction operator. This operator is used to apply on the input string. Header File:  
<iostream>
Syntax:  
basic_istream& operator>>( int& a );
basic_istream& operator>>( unsigned int& a );
Parameters:  
a : This represents the value where the extracted character are stored.
Return Value: The istream::operator>> returns the basic_istream object.Below is the program to illustrate std::basic_istream::operator>>:Program 1:  
CPP14
// C++ code for basic_istream::operator>>#include <bits/stdc++.h>using namespace std; // Driver codeint main(){    // Declare the string "12 12.2 GeeksforGeeks"    string gfg = "12 12.2 GeeksforGeeks";     istringstream stream(gfg);    int a;    float b;    bool c;     stream >> a >> b >> boolalpha >> c;    cout << "a = " << a << '\n'         << "b = " << b << '\n'         << "c = " << boolalpha << c << endl;     return 0;}
a = 12
b = 12.2
c = false
 
Program 2:  
CPP14
// C++ code for basic_istream::operator>>#include <bits/stdc++.h>using namespace std; // Driver codeint main(){    // Declare the string "144 0.26 GFG"    string gfg = "144 0.26 GFG";     istringstream stream(gfg);    int a;    float b;    bool c;     stream >> a >> b >> boolalpha >> c;    cout << "a = " << a << '\n'         << "b = " << b << '\n'         << "c = " << boolalpha << c << endl;     return 0;}
a = 144
b = 0.26
c = false
 
Reference: http://www.cplusplus.com/reference/istream/basic_istream/operator%3E%3E/ 
adnanirshad158
CPP-Functions
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Operator Overloading in C++
Polymorphism in C++
Sorting a vector in C++
Friend class and function in C++
Pair in C++ Standard Template Library (STL)
Convert string to char array in C++
Iterators in C++ STL
Inline Functions in C++
List in C++ Standard Template Library (STL)
Multithreading in C++
What is the best way to handle list empty exception in Python?

List is an ordered sequence of elements. Individual element in list is accessed using index starting with 0 and goes up to length-1. If index goes beyond this range, IndexError exception is encountered.
In following example, an infinite loop is used to pop one element at a time. As loop tries to go even after last element is popped, IndexError exception will be encountered. We trap it using try – except mechanism.
a=[1,2,3]
while True:
  try:
    b=a.pop()
    print (b)
  except (IndexError):
    break
GATE | GATE-CS-2004 | Question 90 - GeeksforGeeks

15 Oct, 2019
The relation scheme Student Performance (name, courseNo, rollNo, grade) has the following functional dependencies:
name, courseNo → grade
rollNo, courseNo → grade
name → rollNo
rollNo → name 
The highest normal form of this relation scheme is(A) 2 NF(B) 3 NF(C) BCNF(D) 4NFAnswer: (B)Explanation: For easy understanding let’s say attributes (name, courseNo, rollNo, grade) be (A,B,C,D). Then given FDs are as follows:
AB->D, CB->D, A->C, C->A 
Here there are two Candidate keys, AB and CB.
Now AB->D and CB->D satisfy BCNF as LHS is superkey in both.
But, A->C and C->A, doesn’t satisfy BCNF. Hence we check for 3NF for these 2 FDs.
As C and A on RHS of both the FDs are prime attributes, they satisfy 3NF.
Hence for the whole relation the highest normal form is 3NF.Quiz of this Question
GATE-CS-2004
GATE-GATE-CS-2004
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-IT-2004 | Question 71
GATE | GATE CS 2011 | Question 7
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE CS 2010 | Question 24
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2016 (Set 1) | Question 65
GATE | GATE-CS-2014-(Set-3) | Question 38
GATE | GATE CS 2018 | Question 37
GATE | GATE-IT-2004 | Question 83
GATE | GATE-CS-2016 (Set 1) | Question 63
Java Program to access character of a string

To access character of a string in Java, use the charAt() method. The position is to be added as the parameter.
Let’s say we have the following string −
String str = "laptop";
Let’s find the character at the 4th position using charAt() method.
str.charAt(3));
The following is the final example.
 Live Demo
public class Demo {
   public static void main(String[] args) {
      String str = "laptop";
      System.out.println("String: "+str);
      // finding character at 4th position
      System.out.println("Character at 4th position: "+str.charAt(3));
   }
}
String: laptop
Character at 4th position: t
UUID hashCode() Method in Java with Examples - GeeksforGeeks

27 Dec, 2018
The hashCode() method of UUID class in Java is generally used to get the hash code value of the UUID.
Syntax:
public int hashCode()
Parameters: This method does not take any parameter.
Return Value: This method returns an integer value which is the hashCode value for this UUID instance.
Below programs illustrate the working of hashCode() method:
Program 1:
// Java code to illustrate hashCode() method  import java.util.*;  public class UUID_Demo {    public static void main(String[] args)    {          // Creating two UUIDs        UUID UUID_1            = UUID                  .fromString(                      "58e0a7d7-eebc-11d8-9669-0800200c9a66");          // Displaying the UUID        System.out.println("UUID: "                           + UUID_1);          // Displaying the hashCode value        System.out.println("The hashCode value is: "                           + UUID_1.hashCode());    }}
UUID: 58e0a7d7-eebc-11d8-9669-0800200c9a66
The hashCode value is: 3744873

Program 2:
// Java code to illustrate hashCode() method  import java.util.*;  public class UUID_Demo {    public static void main(String[] args)    {          // Creating two UUIDs        UUID UUID_1            = UUID                  .fromString(                      "5fc03087-d265-11e7-b8c6-83e29cd24f4c");          // Displaying the UUID        System.out.println("UUID: "                           + UUID_1);          // Displaying the hashCode Value        System.out.println("The hashCode value is: "                           + UUID_1.hashCode());    }}
UUID: 5fc03087-d265-11e7-b8c6-83e29cd24f4c
The hashCode value is: -1447957042

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.
Stream In Java
Constructors in Java
Exceptions in Java
Functional Interfaces in Java
Different ways of Reading a text file in Java
Generics in Java
Introduction to Java
Comparator Interface in Java with Examples
PriorityQueue in Java
Internal Working of HashMap in Java
How to disable button element dynamically using JavaScript ? - GeeksforGeeks

25 Dec, 2020
The Button disabled property in HTML DOM is used to set or return whether a Button element would be disabled or not. A disabled element is un-clickable and unusable. It contains a boolean value.
Syntax: It is used to set the button disabled property.
buttonObject.disabled = "value"
Property Values:
true: It defines that the Button element is disabled.
false: It is the default value. It defines that the Button is not disabled.
Return Value: It returns a boolean value which represents the Button is disabled or not.
Example:
HTML
<!DOCTYPE html><html>  <head>    <title>        How to disable button element        dynamically using JavaScript?    </title></head>  <body style="text-align:center">      <h1 style="color: green;">        GeeksforGeeks    </h1>      <h2>        How to disable button element<br>        dynamically using JavaScript?    </h2>      <!-- Assigning id to Button. -->    <button id="GFG" onclick="Geeks()">        Submit    </button>      <br><br>      <p id="sudo"></p>      <script>        function Geeks() {              document.getElementById("GFG")                .disabled = "true";              document.getElementById("sudo")                .innerHTML = "Button is Disabled";        }     </script></body>  </html>
Output:
Before Click the Button:
After Click the Button:
Supported Browsers: The browser supported by DOM Button disabled property are listed below:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
CSS-Misc
HTML-Misc
JavaScript-Misc
CSS
HTML
JavaScript
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a web page using HTML and CSS
How to set space between the flexbox ?
Form validation using jQuery
Search Bar using HTML, CSS and JavaScript
How to style a checkbox using CSS?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
How to set input type date in dd-mm-yyyy format using HTML ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
Leaf starting point in a Binary Heap data structure - GeeksforGeeks

07 Feb, 2018
Binary Heap is a complete tree (All levels are completely filled except possibly the last level and the last level has all keys as left as possible). In other words, we can say that it’s an almost complete binary tree.
A Binary heap is typically represented as array. If we take a closer look, we can noticed that in a Heap with number of nodes n, the leaves start from a particular index and following it, all the nodes are leaves till index n.
Let’s see an example to observe this:
            10 
         /      \               
       20        100          
      /                      
    30                     

Let us represent this in the form of an array Arr whose index starts from 1 :we have:Arr[1] = 10Arr[2] = 20Arr[3] = 100Arr[4] = 30If we observe, the first leaf (i.e. 100) starts from the index 3. Following it Arr[4] is also a leaf.
By carefully analyzing, the following conclusion is observed:
The first leaf in a Heap starts from [floor(n/2)]+1 and all the nodes following it tilln are leaves.
Conclusion: In a Heap having n elements, Elements from indexes [(floor(n/2)+1) to n] are leaves.
What is starting index of leaves if indexes start from 0 instead of 1?The above explanation assumes indexes starting from 1, but in most of the programming languages, index starts with 0.
If we consider 0 as starting index, then leaves starts from floor(n/2) and exist till end, i.e., (n-1).
This article is contributed by Ranju Kumari. 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.
Heap
Heap
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Building Heap from Array
Insertion and Deletion in Heaps
Sliding Window Maximum (Maximum of all subarrays of size k)
Max Heap in Java
Priority Queue in Python
Merge k sorted arrays | Set 1
Priority Queue using Binary Heap
Median in a stream of integers (running integers)
Real-time application of Data Structures
Max Heap in Python
ArrayDeque push() Method in Java - GeeksforGeeks

10 Dec, 2018
The Java.util.ArrayDeque.push(E element) method is used to push an element into the Deque. The operation is similar to the operation in the stack. The element gets pushed onto the top of the deque.
Syntax:
Array_Deque.push(E element)
Parameters: The parameter element is of the type ArrayDeque and refers to the element to be pushed into the deque.
Return Value: The method does not return any value.
Exceptions: The method throws NullPointerException if the passed parameter is NULL.
Below programs illustrate the Java.util.ArrayDeque.push() method:Program 1: Adding String elements into the Deque.
// Java code to illustrate push()import java.util.*;  public class ArrayDequeDemo {    public static void main(String args[])    {        // Creating an empty ArrayDeque        Deque<String> de_que = new ArrayDeque<String>();          // Use add() method to add elements into the Deque        de_que.add("Welcome");        de_que.add("To");        de_que.add("Geeks");        de_que.add("4");        de_que.add("Geeks");          // Displaying the initial ArrayDeque        System.out.println("Initial Deque: " + de_que);          // Pushing elements into the deque        de_que.push("Hello");        de_que.push("World");          // Displaying the final ArrayDeque        System.out.println("Final Deque: " + de_que);    }}
Initial Deque: [Welcome, To, Geeks, 4, Geeks]
Final Deque: [World, Hello, Welcome, To, Geeks, 4, Geeks]

Program 2: Adding Integer elements into the Deque.
// Java code to illustrate push()import java.util.*;  public class ArrayDequeDemo {    public static void main(String args[])    {        // Creating an empty ArrayDeque        Deque<Integer> de_que = new ArrayDeque<Integer>();          // Use add() method to add elements into the Deque        de_que.add(10);        de_que.add(15);        de_que.add(30);        de_que.add(20);        de_que.add(5);          // Displaying the initial ArrayDeque        System.out.println("Initial Deque: " + de_que);          // Pushing elements into the deque        de_que.push(1254);        de_que.push(4521);          // Displaying the final ArrayDeque        System.out.println("Final Deque: " + de_que);    }}
Initial Deque: [10, 15, 30, 20, 5]
Final Deque: [4521, 1254, 10, 15, 30, 20, 5]

Java - util package
Java-ArrayDeque
Java-Collections
Java-Functions
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Java
Split() String method in Java with examples
For-each loop in Java
Object Oriented Programming (OOPs) Concept in Java
Arrays.sort() in Java with examples
HashMap in Java with Examples
Reverse a string in Java
Stream In Java
Interfaces in Java
How to iterate any Map in Java
FileExtensionValidator - Validate File Extensions in Django - GeeksforGeeks

16 Mar, 2021
Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.
To demonstrate use of FileExtensionValidator, we will create a file uploader application that will validate ‘pdf’ files at backend.
First create new project.
django-admin startproject fileuploader
cd fileuploader
Then create new app inside the project
python manage.py startapp main
Then add the app name inside your INSTALLED_APPS inside the settings.py
Syntax :-
FileExtensionValidator(allowed_extensions, message, code)
Raises a ValidationError with a code of ‘invalid_extension’ if the extension of value.name (value is a File) isn’t found in allowed_extensions. The extension is compared case-insensitively with allowed_extensions.
models.py
Python3
from django.core.validators import FileExtensionValidatorclass Post(models.Model):    PDF = models.FileField(null=True,                            blank=True,                            validators=[FileExtensionValidator( ['pdf'] ) ])
forms.py
Python3
from django.forms import ModelFormfrom .models import *from django import forms    class PostForm(ModelForm):    class Meta:        model = Post        fields = __all__
views.py
Python3
from django.shortcuts import render,HttpResponsefrom .forms import *# Create your views here.  def home(request):    form = PostForm()    return render(request,"main/index.html",{"form":form})
index.html
HTML
<!DOCTYPE html><html><head><title>Page Title</title></head><body><h2>Welcome To GFG</h2><form method="post">    {% csrf_token %}      {{form}}  <button type="submit">Upload</button></form></body></html>
User can only upload pdf files in this filefield. Otherwise it will throw exception. Moreover, it is always recommended to add client-side validation for such requirements. This article illustrates how can you validate file uploads at server end.
Python Django
Python Framework
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
Python OOPs Concepts
Python | Get unique values from a list
Check if element exists in list in Python
Python Classes and Objects
Python | os.path.join() method
How To Convert Python Dictionary To JSON?
Python | Pandas dataframe.groupby()
Create a directory in Python
Python Pandas - Date Functionality

Extending the Time series, Date functionalities play major role in financial data analysis. While working with Date data, we will frequently come across the following −
Generating sequence of dates
Convert the date series to different frequencies
Using the date.range() function by specifying the periods and the frequency, we can create the date series. By default, the frequency of range is Days.
import pandas as pd

print pd.date_range('1/1/2011', periods=5)
Its output is as follows −
DatetimeIndex(['2011-01-01', '2011-01-02', '2011-01-03', '2011-01-04', '2011-01-05'],
   dtype='datetime64[ns]', freq='D')

import pandas as pd

print pd.date_range('1/1/2011', periods=5,freq='M')
Its output is as follows −
DatetimeIndex(['2011-01-31', '2011-02-28', '2011-03-31', '2011-04-30', '2011-05-31'],
   dtype='datetime64[ns]', freq='M')

bdate_range() stands for business date ranges. Unlike date_range(), it excludes Saturday and Sunday.
import pandas as pd

print pd.date_range('1/1/2011', periods=5)
Its output is as follows −
DatetimeIndex(['2011-01-01', '2011-01-02', '2011-01-03', '2011-01-04', '2011-01-05'],
   dtype='datetime64[ns]', freq='D')

Observe, after 3rd March, the date jumps to 6th march excluding 4th and 5th. Just check your calendar for the days.
Convenience functions like date_range and bdate_range utilize a variety of frequency aliases. The default frequency for date_range is a calendar day while the default for bdate_range is a business day.
import pandas as pd
start = pd.datetime(2011, 1, 1)
end = pd.datetime(2011, 1, 5)

print pd.date_range(start, end)
Its output is as follows −
DatetimeIndex(['2011-01-01', '2011-01-02', '2011-01-03', '2011-01-04', '2011-01-05'],
   dtype='datetime64[ns]', freq='D')

A number of string aliases are given to useful common time series frequencies. We will refer to these aliases as offset aliases.

    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
Upper bound and Lower bound for non increasing vector in C++

In this article we are going to discuss the vector::upper_bound() and vector::lower_bound() for an array sorted in non-increasing order in C++ STL.
Vectors are similar to the dynamic arrays; they have the ability to modify its size itself whenever a value is inserted into or removed from the container where we are storing the value.
In a Vector, lower bound returns an iterator pointing to the first element in the range that does not compare the given value. Upper Bound returns an iterator pointing element in the range that smaller than given value.
Input 
30 30 30 20 20 20 10 10
Output 
Lower bound of 20= 3
Upper bound of 20= 6
Input 
9 9 8 8 8 7 7 7 6 6 6 6
Output 
Lower bound of 7= 5
Upper bound of 7= 8
It returns an iterator pointing to the first element of the range and also returns and iterator pointing to the last element of the range.
Firstly, we initialize the vector.
Firstly, we initialize the vector.
Then we sort the vector element in non-increasing order.
Then we sort the vector element in non-increasing order.
Then we find its lower bound.
Then we find its lower bound.
Then we find its upper bound.
Then we find its upper bound.
At last we print both the bounds.
At last we print both the bounds.
By using above approach, we can find out the lower bound and upper bound of any vector, it is necessary to sort the vector to find it lower and upper bound. If the vector is not sorted, then we cannot find its bound
/ / C++ program to demonstrate the working of lower bound and upper bound
#include<iosteam.h>
#include<vector.h>
Using namespace std;
int main ( ){
   int vect[ ] = {13,13,13,16,16,16,17,17,17,17,18,18}
   vector<int> v(vect, vect+8);
   sort (v.begin( ), v.end( ), greater<int>( ));
   cout<< “ \n Sorted Vector: ”;
   for( auto i = vect.begin( ), i =! vect.end( ), ++i)
      vector<int> iterator low, up;
   low = lower_bound (v.begin( ), v.end( ), 17);
   up = upper_bound (v.begin( ), v.end( ), 17);
   cout<<” Lower bound” << (lower – v.begin( ))<< “ \n”;
   cout<< “ Upper bound “<< (upper – v,begin( ))<<”\n”;
   return 0;
}
If we run the above code it will generate the following output
Sorted Vector: 18 18 17 17 17 17 16 16 16 13 13 13
Lower bound = 2
Upper bound = 6
#include<iosteam.h>
#include<vector.h>
Using namespace std;
int main ( ){
   int vect[ ] = {5,5,5,5,7,7 7,8,8,8,8,9,9,9,10,10}
   vector<int> v(vect, vect+16);
   sort (v.begin( ), v.end( ));
   cout<< “ \n Sorted Vector: ”;
   for( auto i = vect.begin( ), i =!vect.end( ), ++i)
      vector<int> iterator low, up;
   low = lower_bound (v.begin( ), v.end( ), 8);
   up = upper_bound (v.begin( ), v.end( ), 8);
   cout<<” Lower bound” << (lower – v.begin( ))<< “ \n”;
   cout<< “ Upper bound “<< (upper – v,begin( ))<<”\n”;
   return 0;
}
If we run the above code it will generate the following output
Sorted Vector: 10 10 9 9 9 8 8 8 8 7 7 7 5 5 5 5
Lower bound = 5
Upper bound = 9
java.time.Instant.getLong() Method Example

The java.time.Instant.getLong(TemporalField field) method gets the value of the specified field from this instant as long.
Following is the declaration for java.time.Instant.getLong(TemporalField field) method.
public long getLong(TemporalField field)

field − the field to get, not null.
the value for the field.
DateTimeException − if a value for the field cannot be obtained or the value is outside the range of valid values for the field.
DateTimeException − if a value for the field cannot be obtained or the value is outside the range of valid values for the field.
UnsupportedTemporalTypeException − if the field is not supported or the range of values exceeds an int.
UnsupportedTemporalTypeException − if the field is not supported or the range of values exceeds an int.
ArithmeticException − if numeric overflow occurs.
ArithmeticException − if numeric overflow occurs.
The following example shows the usage of java.time.Instant.getLong(TemporalField field) method.
package com.tutorialspoint;

import java.time.Instant;
import java.time.temporal.ChronoField;

public class InstantDemo {
   public static void main(String[] args) {

      Instant instant = Instant.parse("2017-03-03T10:37:30.00Z");
      System.out.println(instant.getLong(ChronoField.NANO_OF_SECOND));
   }
}
Let us compile and run the above program, this will produce the following result −
0

 Print
 Add Notes
 Bookmark this page
PyQt5 - Drawing API

All the QWidget classes in PyQt are sub classed from QPaintDevice class. A QPaintDevice is an abstraction of two dimensional space that can be drawn upon using a QPainter. Dimensions of paint device are measured in pixels starting from the top-left corner.
QPainter class performs low level painting on widgets and other paintable devices such as printer. Normally, it is used in widget’s paint event. The QPaintEvent occurs whenever the widget’s appearance is updated.
The painter is activated by calling the begin() method, while the end() method deactivates it. In between, the desired pattern is painted by suitable methods as listed in the following table.
begin()
Starts painting on the target device
drawArc()
Draws an arc between the starting and the end angle
drawEllipse()
Draws an ellipse inside a rectangle
drawLine()
Draws a line with endpoint coordinates specified
drawPixmap()
Extracts pixmap from the image file and displays it at the specified position
drwaPolygon()
Draws a polygon using an array of coordinates
drawRect()
Draws a rectangle starting at the top-left coordinate with the given width and height
drawText()
Displays the text at given coordinates
fillRect()
Fills the rectangle with the QColor parameter
setBrush()
Sets a brush style for painting
setPen()
Sets the color, size and style of pen to be used for drawing
In the following code, various methods of PyQt's drawing methods are used.
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

class Example(QWidget):
   def __init__(self):
      super(Example, self).__init__()
      self.initUI()

   def initUI(self):
      self.text = "hello world"
      self.setGeometry(100,100, 400,300)
      self.setWindowTitle('Draw Demo')
      self.show()

   def paintEvent(self, event):
      qp = QPainter()
      qp.begin(self)
      qp.setPen(QColor(Qt.red))
      qp.setFont(QFont('Arial', 20))
      qp.drawText(10,50, "hello Python")
      qp.setPen(QColor(Qt.blue))
      qp.drawLine(10,100,100,100)
      qp.drawRect(10,150,150,100)
      qp.setPen(QColor(Qt.yellow))
      qp.drawEllipse(100,50,100,50)
      qp.drawPixmap(220,10,QPixmap("pythonlogo.png"))
      qp.fillRect(20,175,130,70,QBrush(Qt.SolidPattern))
      qp.end()

def main():
   app = QApplication(sys.argv)
   ex = Example()
   sys.exit(app.exec_())

if __name__ == '__main__':
   main()
The above code produces the following output −

    146 Lectures 
     22.5 hours 

 ALAA EID
 Print
 Add Notes
 Bookmark this page
Fortran - Nested Loops

You can use one or more loop construct inside any another loop construct. You can also put labels on loops.
iloop: do i = 1, 3
   print*, "i: ", i
   
   jloop: do j = 1, 3         
      print*, "j: ", j         
      
      kloop: do k = 1, 3
         print*, "k: ", k
         
      end do kloop
   end do jloop  
end do iloop

program nestedLoop 
implicit none

   integer:: i, j, k
   
   iloop: do i = 1, 3      
      jloop: do j = 1, 3         
         kloop: do k = 1, 3              
         
            print*, "(i, j, k): ", i, j, k               
            
         end do kloop       
      end do jloop
   end do iloop

end program nestedLoop  
When the above code is compiled and executed, it produces the following result −
 (i, j, k):            1           1           1
 (i, j, k):            1           1           2
 (i, j, k):            1           1           3
 (i, j, k):            1           2           1
 (i, j, k):            1           2           2
 (i, j, k):            1           2           3
 (i, j, k):            1           3           1
 (i, j, k):            1           3           2
 (i, j, k):            1           3           3
 (i, j, k):            2           1           1
 (i, j, k):            2           1           2
 (i, j, k):            2           1           3
 (i, j, k):            2           2           1
 (i, j, k):            2           2           2
 (i, j, k):            2           2           3
 (i, j, k):            2           3           1
 (i, j, k):            2           3           2
 (i, j, k):            2           3           3
 (i, j, k):            3           1           1
 (i, j, k):            3           1           2
 (i, j, k):            3           1           3
 (i, j, k):            3           2           1
 (i, j, k):            3           2           2
 (i, j, k):            3           2           3
 (i, j, k):            3           3           1
 (i, j, k):            3           3           2
 (i, j, k):            3           3           3

 Print
 Add Notes
 Bookmark this page