code-rag-bench/online-tutorials huggingface dataset:
Python | Converting list string to dictionary

28 Apr, 2019
Yet another problem regarding the interconversion between data types is conversion of string of list to a dictionary of keys and values. This particular problem can occur at the places where we need huge amount of string data to be converted to dictionary for preprocessing in Machine Learning domain. Let’s discuss certain ways in which this task can be done.
Method #1 : Using dictionary comprehension + split()Dictionary comprehension can be used for construction of dictionary and split function can be used to perform the necessary splits in list to get the valid key and value pair for dictionary.
# Python3 code to demonstrate# Converting list string to dictionary # Using dictionary comprehsion + split()  # initializing stringtest_string = '[Nikhil:1, Akshat:2, Akash:3]'  # printing original stringprint("The original string : " + str(test_string))  # using dictionary comprehsion + split()# Converting list string to dictionary res = {sub.split(":")[0]: sub.split(":")[1] for sub in test_string[1:-1].split(", ")}  # print resultprint("The dictionary after extraction is : " + str(res))
The original string : [Nikhil:1, Akshat:2, Akash:3]
The dictionary after extraction is : {'Nikhil': '1', 'Akash': '3', 'Akshat': '2'}

 
Method #2 : Using eval() + replace()This particular task can also be performed using the combination of above two functions, the eval and replace functions. In this method, eval function performs like dictionary comprehension, constructing the dictionary and replace function performs the necessary replaces. This function is used when keys and values has to be converted to integer.
# Python3 code to demonstrate# Converting list string to dictionary # Using eval() + replace()  # initializing stringtest_string = '[120:1, 190:2, 140:3]'  # printing original stringprint("The original string : " + str(test_string))  # using eval() + replace()# Converting list string to dictionary res = eval(test_string.replace("[", "{").replace("]", "}"))  # print resultprint("The dictionary after extraction is : " + str(res))
The original string : [120:1, 190:2, 140:3]
The dictionary after extraction is : {120: 1, 140: 3, 190: 2}

Python list-programs
python-list
python-string
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Python OOPs Concepts
Introduction To PYTHON
Convert integer to string in Python
How to Create a Histogram in Excel?

19 Apr, 2021
A histogram is one of the most common data analysis tools in the business world. It is a graphical representation of data that clubs all the data that fall under specific regions.
The numbers on the X-axis represent bins
Note: We’re using Microsoft Excel 2010 for this article, but the steps shown further will be applicable for all later versions of Excel.
Step 1: So the first step is to set up your table. For this article, I’m taking a table that shows the students’ names and the marks they obtained in their exams.
Step 2: Now, we need to set up the Bins/Ranges for our marks. This will help us to choose the bins for our histogram chart. 
So, once that is done, we must calculate our data frequencies for our bins. Let us make another column titled, ‘Frequencies’
We can calculate these frequencies easily by using the Excel function, ‘FREQUENCY’Just go to the first cell of the Frequencies column and type the following –
=FREQUENCY(Start_cell_of_data_column: end_cell_of_data_column, 
                                      Start_cell_of_bins_column: end_cell_of_bins_column) 
And press Ctrl + L-Shift + Enter.
In our case, it will look like this: =FREQUENCY(B2:B15, E2:E5) 
Now that the first frequency of the frequencies column has been successfully calculated, we can apply the same formula to the entire column by selecting that cell and dragging the cursor till the end of the column. The final result is as follows:
Step 3: Let us create the chart now. First, select the Bins and the Frequencies columns. Then go to the Insert section and select the Clustered Column from the Column dropdown under the Charts sub-sections
The final result will look something like this
Now, we don’t want the Bins to be displayed like this. Instead, we want them to be displayed under the X-axis. So, let us go ahead and delete it by clicking in the blue bars and pressing the Delete key.
Then, click on values on the X-axis and select them. Go to the Data section and click on “Select Data”. The following box will appear.
Now Click on Edit and wait for the following box to appear.
Now click on the small icon at the end of the dialog box and then select the Bins column from the first number till last and press Enter.
Your Histogram is finally ready!
Picked
Excel
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Iterating over each index of array in Julia – eachindex() Method

26 Mar, 2020
The eachindex() is an inbuilt function in julia which is used to create an iterable object for visiting each index of the specified array.
Syntax:eachindex(A...)
Parameters:
A: Specified array.
Returns: It returns an iterable object for visiting each index of the specified array.
Example 1:
# Julia program to illustrate # the use of Array eachindex() method  # Accessing each index of 1D array A = [1, 2, 3, 4];  # linear indexingfor i in eachindex(A)    println(i)end  # Accessing each index of 2D array B = [2 4; 6 8];  # linear indexingfor i in eachindex(B)    println(i)end  # Accessing each index of 3D array C = cat([1 2; 3 4], [5 6; 7 8], [2 2; 3 4], dims = 3);  # linear indexingfor i in eachindex(C)    println(i)end
Output: Example 2:
# Julia program to illustrate # the use of Array eachindex() method  # Accessing each index of 1D array A = [1, 2, 3, 4];  # Cartesian indexingfor i in eachindex(view(A, 1:2, 1:1))     println(i)end  # Accessing each index of 2D array B = [2 4; 6 8];  # Cartesian indexingfor i in eachindex(view(B, :, 1))     println(i)end  # Accessing each index of 3D array C = cat([1 2; 3 4], [5 6; 7 8], [2 2; 3 4], dims = 3);  # Cartesian indexingfor i in eachindex(view(C, :, :, 1))     println(i)end
Output:
Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Vectors in Julia
Getting rounded value of a number in Julia - round() Method
Reshaping array dimensions in Julia | Array reshape() Method
Storing Output on a File in Julia
Manipulating matrices in Julia
Exception handling in Julia
Formatting of Strings in Julia
while loop in Julia
Creating array with repeated elements in Julia - repeat() Method
Tuples in Julia
Python | Splitting list on empty string

01 Jul, 2020
Sometimes, we may face an issue in which we require to split a list to list of list on the blank character sent as deliminator. This kind of problem can be used to send messages or can be used in cases where it is desired to have list of list of native list. Let’s discuss certain ways in which this can be done.
Method #1 : Using index() and list slicingThe list slicing can be used to get the sublists from the native list and index function can be used to check for the empty string which can potentially act as a separator. The drawback of this is that it only works for a single split i.e can only divide a list to 2 sublists.
# Python3 code to demonstrate# divide list to siblist on deliminator# using index() + list slicing   # initializing list test_list = ['Geeks', 'for', '', 'Geeks', 1, 2]  # printing original listprint("The original list : " + str(test_list))  # using index() + list slicing# divide list to siblist on deliminatortemp_idx = test_list.index('')res = [test_list[: temp_idx], test_list[temp_idx + 1: ]]  # print resultprint("The list of sublist after separation : " + str(res))
The original list : [‘Geeks’, ‘for’, ”, ‘Geeks’, 1, 2]The list of sublist after separation : [[‘Geeks’, ‘for’], [‘Geeks’, 1, 2]]
 
Method #2 : Using itertools.groupby() + list comprehensionThe problem of the above proposed method can be solved using the groupby function which could divide on all the list breaks given by the empty strings.
# Python3 code to demonstrate# divide list to siblist on deliminator# using itertools.groupby() + list comprehensionfrom itertools import groupby  # initializing list test_list = ['Geeks', '', 'for', '', 4, 5, '',                  'Geeks', 'CS', '', 'Portal']  # printing original listprint("The original list : " + str(test_list))  # using itertools.groupby() + list comprehension# divide list to siblist on deliminatorres = [list(sub) for ele, sub in groupby(test_list, key = bool) if ele]  # print resultprint("The list of sublist after separation : " + str(res))
The original list : [‘Geeks’, ”, ‘for’, ”, 4, 5, ”, ‘Geeks’, ‘CS’, ”, ‘Portal’]The list of sublist after separation : [[‘Geeks’], [‘for’], [4, 5], [‘Geeks’, ‘CS’], [‘Portal’]]
nidhi_biet
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PyQt5 – QDoubleSpinBox

14 Jul, 2020
QDoubleSpinBox allows the user to choose a value by clicking the up and down buttons or by pressing Up or Down on the keyboard to increase or decrease the value currently displayed. The user can also type the value in manually. The spin box supports double values but can be extended to use different strings. Below is how the double spin box looks like
Example :A window having a Double Spinbox and a label, when value changes a message will appear in the label displaying the current value.
Below is the implementation
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 500, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for components    def UiComponents(self):          # creating double spin box        d_spin = QDoubleSpinBox(self)          # setting geometry to the double spin box        d_spin.setGeometry(100, 100, 150, 40)          # adding action to the double spin box        d_spin.valueChanged.connect(lambda:  spin_method())          # creating a label        label = QLabel("GeeksforGeeks", self)          # setting geometry to the label        label.setGeometry(100, 200, 300, 80)          # making label multi line        label.setWordWrap(True)          def spin_method():              # getting current value of double spin box            value = d_spin.value()              # setting text to the label            label.setText("Current Value : " + str(value))        # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt-QDoubleSpinBox
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Iterate over a list in Python
HTTP headers | Cookie

30 Oct, 2019
HTTP headers are used to pass additional information with HTTP response or HTTP requests. A cookie is an HTTP request header i.e. used in the requests sent by the user to the server. It contains the cookies previously sent by the server using set-cookies. It is an optional header.
Syntax:
Cookie: <cookie-list>
In case of single cookie syntax is as follow:
Cookie: name=value
In case of multiple cookies syntax is as follow:
Cookie: name=value; name=value; name=value
Directives: This header accept a single directive mentioned above and described below:
<cookie-list> It is the list of name=value pair separated by ; and space i.e ‘;’.
Example 1:
Cookie: user=Bob
Example 2:
Cookie: user=Bob; age=28; csrftoken=u12t4o8tb9ee73
To check this Cookie in action go to Inspect Element -> Network check the request header for Cookie like below, Cookie is highlighted you can see.
Supported Browsers: The browsers are supported by HTTP Cookie header are listed below:
Google Chrome
Internet Explorer
Firefox
Apple Safari
Opera
HTTP-headers
Picked
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
REST API (Introduction)
Node.js fs.readFileSync() Method
How to set the default value for an HTML <select> element ?
How to create footer to stay at the bottom of a Web page?
How to set input type date in dd-mm-yyyy format using HTML ?
Difference Between PUT and PATCH Request
Maximum value of unsigned int in C++

18 Jan, 2021
In this article, we will discuss the maximum value of unsigned int in C++.
Unsigned int data type in C++ is used to store 32-bit integers.
The keyword unsigned is a data type specifier, which only represents non-negative integers i.e. positive numbers and zero. 
Some properties of the unsigned int data type are:
An unsigned data type can only store positive values.
It takes a size of 32 bits.
A maximum integer value that can be stored in an unsigned int data type is typically 4, 294, 967, 295, around 232 – 1(but is compiler dependent).
The maximum value that can be stored in unsigned int is stored as a constant in the <climits> header file. whose value can be used as UINT_MAX.
A minimum integer value that can be stored in an unsigned int data type is typically 0.
In case of overflow or underflow of data type, the value is wrapped around.
For example, if 0 is stored in an int data type and 1 is subtracted from it, the value in that variable will become equal to 4, 294, 967, 295. Similarly, in the case of overflow, the value will round back to 0.
Below is the program to get the highest value that can be stored in unsigned int in C++:
C++
// C++ program to obtain the maximum// value stored in unsigned int#include <climits>#include <iostream>using namespace std;  // Function that prints the maximum// value stored in unsigned intvoid maxUnsignedInt(){    // From the constant of climits    // header file    unsigned int valueFromLimits = UINT_MAX;      cout << "Value from climits constant : "         << valueFromLimits << "\n";      // Using the wrap around property    // of data types      // Initialize a variable with 0    unsigned int value = 0;      // Subtract 1 from value since    // unsigned data type cannot store    // negative number, the value will    // wrap around and store the    // maximum value in it    value = value - 1;      cout << "Value using the wrap"         << " around property : "         << value << "\n";}  // Driver Codeint main(){    // Function call    maxUnsignedInt();      return 0;}
Value from climits constant : 4294967295
Value using the wrap around property : 4294967295

C Basics
CPP-Basics
Data Types
C++
C++ Programs
Programming Language
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting a vector in C++
Polymorphism in C++
Friend class and function in C++
Pair in C++ Standard Template Library (STL)
std::string class in C++
Header files in C/C++ and its uses
Sorting a Map by value in C++ STL
Program to print ASCII Value of a character
How to return multiple values from a function in C or C++?
Shallow Copy and Deep Copy in C++
How to get the IIS Application Pool names using PowerShell?

To get the IIS application pool names using PowerShell, you need to use the IIS PSDrive but for that, we need the IIS PowerShell module WebAdministration or IISAdministration on the server we are running the command.
If the WebAdministration module is already installed, use the below command to import the module.
Import-Module WebAdministration -Verbose
Once you Import the above module, you can see the IIS PSDrive will be activated in the current session.
To get all the application Pools run the below command,
Get-ChildItem IIS:\AppPools\
Name                     State        Applications
----                     -----        ------------
.NET v2.0                Started
.NET v2.0 Classic        Started
.NET v4.5                Started
.NET v4.5 Classic        Started
Classic .NET AppPool     Started
DefaultAppPool           Started      Default Web Site
To retrieve the particular app pool name use the Get-Item command,
Get-Item IIS:\AppPools\DefaultAppPool
Name                     State        Applications
----                     -----        ------------
DefaultAppPool           Started      Default Web Site
Another simple method is by using the Get-IISAppPool command of the IISAdministration module.
Import-Module IISAdministration -Verbose
Use the Get-IISAppPool command.
Name                 Status       CLR Ver  Pipeline Mode  Start Mode
----                 ------       -------  -------------  ----------
DefaultAppPool       Started      v4.0     Integrated     OnDemand
Classic .NET AppPool Started      v2.0     Classic        OnDemand
.NET v2.0 Classic    Started      v2.0     Classic        OnDemand
.NET v2.0            Started      v2.0     Integrated     OnDemand
.NET v4.5 Classic    Started      v4.0     Classic        OnDemand
.NET v4.5            Started      v4.0     Integrated     OnDemand
For the particular app pool use the -Name property,
Get-IISAppPool -Name DefaultAppPool
HTML <section> Tag

17 Mar, 2022
Section tag defines the section of documents such as chapters, headers, footers or any other sections. The section tag divides the content into section and subsections. The section tag is used when requirements of two headers or footers or any other section of documents needed. Section tag grouped the generic block of related contents. The main advantage of the section tag is, it is a semantic element, which describes its meaning to both browser and developer.Syntax:  
<section> Section Contents </section>
Section tag is used to distribute the content i.e, it distributes the sections and subsections. Example:  
HTML
<!DOCTYPE html><html>    <body>        <!-- html section tag is used here -->        <section>            <h1>Geeksforgeeek: Section 1</h1>             <p>Content of section 1</p>         </section>        <section>            <h1>GeeksforGeeks: Section 2</h1>             <p>Content of section 2</p>         </section>        <section>            <h1>GeeksforGeeks: Section 3</h1>             <p>Content of section 3</p>         </section>    </body></html>                   
Output:  
Nested Section tag: The section tag can be nested. The font size of subsection is smaller then section tag if the text contains the same font property. The subsection tag is used for organizing complex documents. A rule of thumb is that section should logically appear in outline of the document. Example:  
HTML
<!DOCTYPE html><html>    <body>        <!-- html section tag is used here -->        <section>            <h1>Geeksforgeeek: Section 1</h1>             <p>Content of section 1</p>             <section>                <h1>Subsection</h1>                <h1>Subsection</h1>            </section>        </section>        <section>            <h1>GeeksforGeeks: Section 2</h1>             <p>Content of section 2</p>             <section>                <h1>Subsection</h1>                <h1>Subsection</h1>            </section>        </section>    </body></html>                   
Output:  
Supported Browsers:  
Google Chrome 6.0 and above
Internet Explorer 9.0 and above
Mozilla 4.0 and above
Opera 11.1 and above
Safari 5.0 and above
 
Akanksha_Rai
shubhamyadav4
HTML-Tags
HTML5
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
REST API (Introduction)
Hide or show elements in HTML using display property
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
Design a Tribute Page using HTML & CSS
Python | Min/Max value in float string list

22 Jan, 2021
Sometimes, while working with a Python list, we can have a problem in which we need to find min/max value in the list. But sometimes, we don’t have a natural number but a floating-point number in string format. This problem can occur while working with data, both in web development and Data Science domain. Let’s discuss a way in which this problem can be solved. Method : Using min()/max() + float() This problem can be solved using the min or max function in which we first convert the strings into float and then pass this logic in functions in respective min/max function. 
Python3
# Python3 code to demonstrate working of# Min / Max value in float string list# using min()/max() + float() + generator # initialize liststest_list = ['4.5', '7.8', '9.8', '10.3'] # printing original listprint("The original list is : " + str(test_list)) # Min / Max value in float string list# using min()/max() +float + lambda functionres_min = min(test_list,key=lambda x:float(x))res_max = max(test_list,key=lambda x:float(x)) # printing resultprint("The min value of list : " + str(res_min))print("The max value of list : " + str(res_max))
The original list is : ['4.5', '7.8', '9.8', '10.3']
The min value of list : 4.5
The max value of list : 10.3

mrmechanical26052000
Python list-programs
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Create a directory in Python
How to stop training a neural-network using callback? | by Supratim Haldar | Towards Data Science

Often, when training a very deep neural network, we want to stop training once the training accuracy reaches a certain desired threshold. Thus, we can achieve what we want (optimal model weights) and avoid wastage of resources (time and computation power).
In this brief tutorial, let’s learn how to achieve this in Tensorflow and Keras, using the callback approach, in 4 simple steps.
# Import tensorflowimport tensorflow as tf
First, set the accuracy threshold till which you want to train your model.
First, set the accuracy threshold till which you want to train your model.
ACCURACY_THRESHOLD = 0.95
2. Now, implement callback class and function to stop training when accuracy reaches ACCURACY_THRESHOLD.
# Implement callback function to stop training# when accuracy reaches e.g. ACCURACY_THRESHOLD = 0.95class myCallback(tf.keras.callbacks.Callback):     def on_epoch_end(self, epoch, logs={}):         if(logs.get('acc') > ACCURACY_THRESHOLD):           print("\nReached %2.2f%% accuracy, so stopping training!!" %(ACCURACY_THRESHOLD*100))           self.model.stop_training = True
What exactly is going on here? We are creating new class by extending tf.keras.callbacks.Callback, and implementing the on_epoch_end() method. This is invoked at the end of each epoch. Next, we are fetching the value of accuracy at the end of that epoch, and if it is greater than our threshold, we are setting the stop_training of model to True.
3. Instantiate an object of myCallback class.
callbacks = myCallback()
Next, build a DNN or Conv-Net model following the normal steps of TensorFlow or Keras. The callback that we have built above will be used while training the model using fit() method.
4. Simply pass an argument as callbacks=[<the newly instantiated object of myCallback class>] to fit() method.
model.fit(x_train, y_train, epochs=20, callbacks=[callbacks])
And that’s all! While training, as soon as accuracy reaches the value set in ACCURACY_THRESHOLD, training will be stopped.
To tie it all together, here’s a complete code snippet.
With our imagination this approach can be used in varied creative ways, especially when we want to run quick PoCs to test and validate multiple DNN architectures. What other interesting usages can you think of? Please share your thoughts in the comments section below.
CSS | Combine background image with gradient overlay - GeeksforGeeks

19 Feb, 2020
CSS gradients allow us to display smooth transitions between two or more colors. They can be added on top of the background image by simply combining background-image url and gradient properties.Syntax:
For linear-gradient on top of the Background Image:element {
    background-image: linear-gradient(direction, 
     color-stop1, color-stop2, ...), url('url');
}
element {
    background-image: linear-gradient(direction, 
     color-stop1, color-stop2, ...), url('url');
}
For radial-gradient on top of the Background Image:element {
    background-image: radial-gradient(direction, 
    color-stop1, color-stop2, ...), url('url');
}
element {
    background-image: radial-gradient(direction, 
    color-stop1, color-stop2, ...), url('url');
}
Below examples illustrate the above approach:Example 1: Background image with Linear gradient.
<!DOCTYPE html><html lang="en">  <head>    <title>Background Image with Gradient</title>    <meta charset="utf-8">    <meta name="viewport"          content="width=device-width, initial-scale=1">    <link rel="stylesheet"          href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">    <style>        .my_bg {            background-image:               linear-gradient(45deg, rgba(                145, 146, 122, 0.62), rgba(                  217, 91, 132, 0.58)), url('https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png');            width: 100%;            height: 280px;            text-align: center;        }    </style></head>  <body>    <div class="my_bg">        This is my background!    </div></body>  </html>
Output:
Example 2: Background image with Radial gradient.
<!DOCTYPE html><html lang="en">  <head>    <title>Background Image with Gradient</title>    <meta charset="utf-8">    <meta name="viewport"           content="width=device-width, initial-scale=1">    <link rel="stylesheet"           href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">    <style>        .my_bg {            background-image: radial-gradient(rgba(              145, 146, 122, 0.62), rgba(217, 91, 132, 0.58)), url('https://media.geeksforgeeks.org/wp-content/uploads/20200120152724/gfg_icon.png');            width: 100%;            height: 200px;            text-align: center;        }    </style></head>  <body>    <div class="my_bg">        This is my background!    </div></body>  </html>
Output:
CSS-Misc
Picked
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Types of CSS (Cascading Style Sheet)
How to create footer to stay at the bottom of a Web page?
Design a web page using HTML and CSS
How to Upload Image into Database and Display it using PHP ?
Create a Responsive Navbar using ReactJS
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
Materialize - Dropdowns

Materialize provides dropdown CSS class to make a ul element as a dropdown and add the id of the ul element to the data-activates attribute of the button or anchor element. The following table mentions the available classes and their effects.
dropdown-content
Identifies ul as a materialize dropdown component. Required for ul element.
data-activates
id of the dropdown ul element.
Following is an example of using a dropdown.
<!DOCTYPE html>
<html>
   <head>
      <title>The Materialize Dropdowns Example</title>
         <meta name="viewport" content="width=device-width, initial-scale=1">
         <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
         <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/css/materialize.min.css">
         <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
         <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/js/materialize.min.js"></script>
   </head>
   <body class="container">
      <h3>Drop Down Demo</h3>
      <ul id="dropdown" class="dropdown-content">
         <li><a href="#">Inbox<span class="badge">12</span></a></li>
         <li><a href="#!">Unread<span class="new badge">4</span></a></li>
         <li><a href="#">Sent</a></li>
         <li class="divider"></li> 
         <li><a href="#">Outbox<span class="badge">14</span></a></li>
      </ul>
      <a class="btn dropdown-button" href="#" data-activates="dropdown">Mail Box<i class="mdi-navigation-arrow-drop-down right"></i></a>
   </body>
</html>
Verify the output.
 Print
 Add Notes
 Bookmark this page
MySQL Tryit Editor v1.0

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

To create a global variable, you need to place variable inside the <script> </script> tag.
Following is the code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>Document</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<button
onclick="createGlobalVariable()">checkGlobalVariable</button>
<script>
   var globalVariable;
   $(document).ready(function() {
      function initializeGlobalVariable() {
         globalVariable = [{
            "name":"John",
            "age":23
         }];
      }
      initializeGlobalVariable();
   });
   function createGlobalVariable() {
      if (globalVariable.length) {
         console.log('The Global variable name
         is='+globalVariable[0].name+" The Global variable age is="+globalVariable[0].age);
      }
   }
</script>
</body>
</html>
To run the above program, save the file name “anyName.html(index.html)” and right click on the
file. Select the option “Open with Live Server” in VS Code editor.
This will produce the following output −
When you click on the button checkGlobalvariable, the following output will be visible −
How to format Java LocalDateTime as ISO_DATE_TIME format

At first, set the date:
LocalDateTime dateTime = LocalDateTime.of(2019, Month.JULY, 9, 10, 20);
Now, format the datetime as ISO_DATE_TIME format:
String str = dateTime.format(DateTimeFormatter.ISO_DATE_TIME);
import java.time.LocalDateTime;
import java.time.Month;
import java.time.format.DateTimeFormatter;
public class Demo {
   public static void main(String[] args) {
      LocalDateTime dateTime = LocalDateTime.of(2019, Month.JULY, 9, 10, 20);
      System.out.println("DateTime = "+dateTime);
      String str = dateTime.format(DateTimeFormatter.ISO_DATE_TIME);
      System.out.println("Formatted date = "+str);
   }
}
DateTime = 2019-07-09T10:20
Formatted date = 2019-07-09T10:20:00
How to add a unique id for an element in HTML?

Use the id attribute in HTML to add the unique id of an element.
You can try to run the following code to implement id attribute −
<html>
   <body>
      <h1>Tutorialspoint</h1>
      <p id = "myid">We provide Tutorials!</p>
      <button onclick = "display()">More...</button>

      <script>
         function display() {
            document.getElementById("myid").innerHTML = "We provide learning videos as well";
         }
      </script>
   </body>
</html>
How to verify color of a web element in Selenium Webdriver?

We can verify the color of a webelement in Selenium webdriver using the getCssValue method and then pass color as a parameter to it. This returnsthe color in rgba() format.
Next, we have to use the class Color to convert the rgba() format to Hex. Let us obtain the color an element highlighted in the below image. The corresponding color for the element is available under the Styles tab in Chrome browser.
The color of the element is also provided in the hex code #797979.
WebElement t = driver.findElement(By.tagName("h1"));
String s = t.getCssValue("color");
String c = Color.fromString(s).asHex();
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.support.Color;
public VerifyColor{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.get("https://www.tutorialspoint.com/about/about_careers.htm");
      // identify text
      WebElement t = driver.findElement(By.tagName("h1"));
      //obtain color in rgba
      String s = t.getCssValue("color");
      // convert rgba to hex
      String c = Color.fromString(s).asHex();
      System.out.println("Color is :" + s);
      System.out.println("Hex code for color:" + c);
      driver.quit();
   }
}
Convert a list of multiple integers into a single integer in Python

Sometimes we may have a list whose elements are integers. There may be a need to combine all these elements and create a single integer out of it. In this article we will explore the ways to do that.
The join method can Join all items in a tuple into a string. So we will use it to join each element of the list by iterating through them through a for loop.
 Live Demo
listA = [22,11,34]
# Given list
print("Given list A: ", listA)
# Use
res = int("".join([str(i) for i in listA]))
# Result
print("The integer is : ",res)
Running the above code gives us the following result −
Given list A: [22, 11, 34]
The integer is : 221134
We can apply the map function to convert each element of the list into a string and then join each of them to form a final list. Applying the int function makes the final result an integer.
 Live Demo
listA = [22,11,34]
# Given list
print("Given list A: ", listA)
# Use
res = int("".join(map(str, listA)))
# Result
print("The integer is : ",res)
Running the above code gives us the following result −
Given list A: [22, 11, 34]
The integer is : 221134
Plot multiple columns of Pandas DataFrame using Seaborn

To plot multiple columns of Pandas DataFrame using Seaborn, we can take the following steps −
Make a dataframe using Pandas.
Make a dataframe using Pandas.
Plot a bar using Seaborn's barplot() method.
Plot a bar using Seaborn's barplot() method.
Rotate the xticks label by 45 angle.
Rotate the xticks label by 45 angle.
To display the figure, use show() method.
To display the figure, use show() method.
import pandas
import matplotlib.pylab as plt
import seaborn as sns
import numpy as np
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
df = pandas.DataFrame({"X-Axis": [np.random.randint(10) for i in range(10)], "YAxis": [i for i in range(10)]})
bar_plot = sns.barplot(x='X-Axis', y='Y-Axis', data=df)
plt.xticks(rotation=45)
plt.show()
How do I import all the submodules of a Python namespace package?

The "from module import *" statement is used to import all submodules from a Python package/module. For example, if you want to import all modules from your module(say nyModule) and do not want to prefix "myModule." while calling them, you can do it as follows:
>>> from myModule import *
Note that for any reasonable large set of code, if you import * you will likely be cementing it into the module, unable to be removed. This is because it is difficult to determine what items used in the code are coming from 'module', making it easy to get to the point where you think you don't use the import any more but it's extremely difficult to be sure. It basically clutters the namespace and leaves you with lesser options to name things in your module.
Quantitative Aptitude - GeeksforGeeks

28 Nov, 2021
Woman     Child      Earns
  6    +    4     =   10
  |         |         |60%
 __        max 6   =  16

Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Maintain the aspect ratio of a div with CSS

09 Jul, 2021
In order to maintain the aspect ratio of a div with CSS create flexible elements that keep their aspect ratio (4:3, 16:9, etc.) when resize the browser window.What is aspect ratio? The aspect ratio of an element describes the proportional relationship between its width and height. Two common video aspect ratios are 4:3 and 16:9.To maintain the aspect ratio of the div add a percentage value for padding-top. Different aspect ratio have different percentage values. Some of them are shown below:  
aspect ratio  | padding-top value
--------------|----------------------
    1:1       |       100%
    16:9      |       56.25%
    4:3       |       75%
    3:2       |       66.66%
    8:5       |       62.5%
Syntax:  
element {
    padding-top: %value;
}
Example:  
html
<!DOCTYPE html><html>    <head>        <meta name="viewport" content="width=device-width,        initial-scale=1">        <style>            .container {                background-color: green;                position: relative;                width: 100%;                padding-top: 56.25%; /* 16:9 Aspect Ratio */            }             .text {                position: absolute;                top: 0;                left: 0;                bottom: 0;                right: 0;                text-align: center;                font-size: 25px;                color: white;            }            .example {                background: white;                color: green;                font-weight:bold;                font-size: 40px;                padding-bottom: 20px;            }        </style>        </head>    <body>        <div class="container">            <div class="text">                <div class = "example">GeeksforGeeks</div>                 <p>A Computer Science portal for geeks. It                contains well written, well thought and well                explained computer science and programming                articles, quizzes etc. Also it contains several                coding questions to practice and develop your                skills in programming.</p>             </div>        </div>    </body></html>                               
Output:  
The output of above example is set to Aspect Ratio of 16:9. Resize the window to see the effect. Also change the corresponding values of the aspect ratio to see the desired changes in the browser window. 
sweetyty
Web-Programs
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
CSS to put icon inside an input element in a form
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
REST API (Introduction)
Hide or show elements in HTML using display property
Java Examples - Find common elements from arrays

How to find common elements from arrays ?
Following example shows how to find common elements from two arrays and store them in an array.
import java.util.ArrayList;

public class NewClass {
   public static void main(String[] args) {
      ArrayList objArray = new ArrayList();
      ArrayList objArray2 = new ArrayList();
      objArray2.add(0,"common1");
      objArray2.add(1,"common2");
      objArray2.add(2,"notcommon");
      objArray2.add(3,"notcommon1");
      objArray.add(0,"common1");
      objArray.add(1,"common2");
      objArray.add(2,"notcommon2");
      System.out.println("Array elements of array1"+objArray);
      System.out.println("Array elements of array2"+objArray2);
      objArray.retainAll(objArray2);
      System.out.println("Array1 after retaining common elements of array2 & array1"+objArray);
   }
}
The above code sample will produce the following result.
Array elements of array1[common1, common2, notcommon2]
Array elements of array2[common1, common2, notcommon,
notcommon1]
Array1 after retaining common elements of array2 & array1
[common1, common2]

Another sample example of Find common elements from arrays
public class HelloWorld {
   public static void main(String a[]) {
      int[] arr1 = {4,7,3,9,2};
      int[] arr2 = {3,2,12,9,40,32,4};
      
      for(int i = 0;i < arr1.length; i++) {
         for(int j = 0; j < arr2.length; j++) {
            if(arr1[i] == arr2[j]) { 
               System.out.println(arr1[i]);
            } 
         } 
      }
   }
}
The above code sample will produce the following result.
SQL – SELECT FIRST

14 May, 2021
In this article we are going to study the SELECT FIRST commands in SQL, as we all know that there is already a command for selecting all the rows from a table by “SELECT * FROM Table” but if we want to select only the top row, here SELECT FIRST comes into play. This FIRST query can be used for login related purpose in any website, or if we want to make a billing system we can implement this that increment the Bill number from the top row number.
The first () function is used to return the first row of any table.
Syntax : SELECT FIRST(columnName) FROM tableName
So we will start by creating a database to perform the operations.
Step 1: Create a database.
CREATE DATABASE GFG
Step 2: Use this database
USE GFG
Step 3: Create a table
/****** (1,1) indicates that increment 1 every time insert is performed ******/

CREATE TABLE first 
                  (ID INT PRIMARY KEY IDENTITY (1,1),
                  Name VARCHAR (20) NOT NULL,
                  Age INT NOT NULL,
                  Dept VARCHAR (20) NOT NULL)
Step 4: Check the created table schema  
Schema of table
Step 4: Insert the values in Table
/****** Insertion queries ******/

INSERT INTO [dbo].[first]
           ([Name]
           ,[Age]
           ,[Dept])
     VALUES
           ('Devesh', 20, 'CSE')
GO

INSERT INTO [dbo].[first]
           ([Name]
           ,[Age]
           ,[Dept])
     VALUES
           ('Aditya', 19, 'BT')
GO

INSERT INTO [dbo].[first]
           ([Name]
           ,[Age]
           ,[Dept])
     VALUES
           ('Megha', 20, 'CSE')
GO
Step 5: Use first() function in table( first() is used in MS ACCESS ).
SELECT TOP 1 Name FROM first
Picked
SQL-Functions
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
Window functions in SQL
SQL | Sub queries in From Clause
What is Temporary Table in SQL?
SQL using Python
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
RANK() Function in SQL Server
SQL Query to Convert VARCHAR to INT
SQL Query to Compare Two Dates
SQL Query to Insert Multiple Rows
How to find the unique values in a column of R dataframe? - GeeksforGeeks

21 Apr, 2021
In this article, we will discuss how to find out the unique value in a column of dataframe in R Programming language. For this task, unique() function is used where the column name is passed for which unique values are to be printed.
Syntax: unique(x)
parameters:
x: data frame
For a column name select the column using $
dataframe$column_name
Example 1:
R
id<- c(1,2,3,4,5,6,7,8,9)  country <- c("INDIA","AMERICA","JAPAN","CHINA","BANGLADESH",             "SRILANKA","NEPAL","AMERICA","CHINA")  data<-data.frame(id,country)  unique(data$country)
Output:
[1] INDIA      AMERICA    JAPAN      CHINA      BANGLADESH SRILANKA   NEPAL      
Levels: AMERICA BANGLADESH CHINA INDIA JAPAN NEPAL SRILANKA
Example 2: 
R
data <- data.frame(x1 = c(9, 5, 6, 8, 9),                              x2 = c(2, 4, 2, 7, 1),                         x3 = c(3,6,7,0,3),                         x4 = c("Hello", "value", "value", "geeksforgeeks", NA)                  )                                                                               unique(data[c("x2")])    unique(data[c("x1")])
Output:
Unique data in column x2
  x2
1  2
2  4
4  7
5  1
Unique data in column x1
  x1
1  9
2  5
3  6
4  8
Example 3: 
R
data<- data.frame(Student=c('John','Lee','Guy',                            'John','Lee','Guy'),                                      Age=c(18,19,20,18,19,20),                                      Gender=c('Male','Female','Male',                           'Male','Female','Male'))   unique(data)
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.
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
How to filter R DataFrame by values in a column?
How to filter R dataframe by multiple conditions?
Convert Matrix to Dataframe in R