code-rag-bench/online-tutorials huggingface dataset:
HTML <ol> Tag - GeeksforGeeks

09 Dec, 2021
In this article, we will know HTML <ol> Tag, & its implementation through the examples. The <ol> tag is for an ordered list, an ordered list can be numerical or alphabetical. Inside the <ol> tag you have to make a list <li> of items that will follow the order.
Syntax:
<ol>
   <li>Item1</li>
   <li>Item2</li>
   <li>Item3</li>
</ol>
Accepted attributes: 
HTML <ol> compact Attribute: It defines the list should be compacted (compact attribute is not supported HTML5. Use CSS instead.).
HTML <ol> reversed Attribute: It defines that the order will be descending.
HTML <ol> start Attribute: It defines that from which number or alphabet the order will start.
HTML <ol> type Attribute: It defines which type(1, A, a, I, and i) of an order you want in your list numeric, alphabetic, or roman numbers.
Example: In this example, we have created an ordered list of Frontend Technologies using the <ol> tag.
HTML
<!DOCTYPE html><html>  <head>  <title>HTML Ordered Lists</title></head>  <body>  <h2>Welcome To GeeksforGeeks</h2>  <ol>    <li>HTML</li>    <li>CSS</li>    <li>JavaScript</li>    <li>React.Js</li>  </ol></body>  </html>
Output:
HTML Ordered List
Example: This example explains the HTML Ordered list by specifying the different attribute & their values.
HTML
<!DOCTYPE html><html>  <head>  <title>HTML ol tag</title></head>  <body>  <h1 style="color:green;">GeeksforGeeks</h1>  <h3>HTML <ol> tag</h3>  <p>reversed attribute</p>    <ol reversed>    <li>HTML</li>    <li>CSS</li>    <li>JS</li>  </ol>    <p>start attribute</p>  <ol start=5>    <li>HTML</li>    <li>CSS</li>    <li>JS</li>  </ol>    <p>type attribute</p>  <ol type="i">    <li>HTML</li>    <li>CSS</li>    <li>JS</li>  </ol>  </body>  </html>
Output:
HTML Ordered List with different attribute
Supported Browsers:  
Google Chrome
Internet Explorer
Microsoft Edge
Firefox
Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
nidhi_biet
shubhamyadav4
bhaskargeeksforgeeks
HTML-Tags
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
HTML Cheat Sheet - A Basic Guide to HTML
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Difference Between Single and Multiple Inheritance

In this post, we will understand the difference between single inheritance and multiple inheritance.
It is the one wherein the derived class inherits the single base class.
It is the one wherein the derived class inherits the single base class.
The derived class inherits the features of the base class.
The derived class inherits the features of the base class.
It requires a small run time in comparison to multiple inheritance.
It requires a small run time in comparison to multiple inheritance.
It has less overhead.
It has less overhead.
It is a generalization.
It is a generalization.
It is simple in comparison to multiple inheritance.
It is simple in comparison to multiple inheritance.
It can be implemented in any programming language.
It can be implemented in any programming language.
Class DerivedClass_name : access_specifier Base_Class{};
The derived class derives from two or more base classes.
The derived class derives from two or more base classes.
The derived class uses the combined features of the multiple base classes.
The derived class uses the combined features of the multiple base classes.
It requires more run time in comparison to single inheritance.
It requires more run time in comparison to single inheritance.
It has more overhead.
It has more overhead.
It is a specialization.
It is a specialization.
It is complex in comparison to single inheritance.
It is complex in comparison to single inheritance.
Only C++ supports multiple inheritance
Only C++ supports multiple inheritance
Class DerivedClass_name : access_specifier Base_Class1, access_specifier Base_Class2, ....{};
C | Structure & Union | Question 10 - GeeksforGeeks

28 Jun, 2021
struct node {    int i;    float j; }; struct node *s[10];
The above C declaration define ‘s’ to be (GATE CS 2000)(A) An array, each element of which is a pointer to a structure of type node(B) A structure of 2 fields, each field being a pointer to an array of 10 elements(C) A structure of 3 fields: an integer, a float, and an array of 10 elements(D) An array, each element of which is a structure of type node.Answer: (A)Explanation: Refer Structures in C.Quiz of this Question
C-Structure & Union
Structure & Union
C Language
C Quiz
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
TCP Server-Client implementation in C
'this' pointer in C++
Exception Handling in C++
Multithreading in C
UDP Server-Client implementation in C
Compiling a C program:- Behind the Scenes
Operator Precedence and Associativity in C
C | Structure & Union | Question 4
C | File Handling | Question 5
C | Dynamic Memory Allocation | Question 5
Extract first N rows from dataframe in R - GeeksforGeeks

26 Mar, 2021
A required number of rows can be retrieved from a dataframe for some computation that demands so. In this article, we will be discussing two different approaches for extracting the first n rows from the data frame
File in Use:
Method 1: Using head() function
This function will help to extract the given first N number of the rows.
Syntax: head(x,n=..)
Parameters:-
x:-an object
n:-a single integer for the first number of elements of x
Returns:-
Returns the first parts of a vector, matrix, table, data frame.
Approach
Import file
Pass the number of rows required
Select rows
Print selection
Example:
R
gfg=read.csv('input_gfg.csv')  head(gfg,5)
Output:
Method 2: Using index 
Under this method of extracting the first N rows of the data frame, the user must provide the machine with the proper index of the required rows and columns.And with this, it will return the new data frame as per the provided index of rows and columns.
Syntax:
data[row.index, column.index]
Approach
Import file
Pass the range of rows to be selected
Display selection
Example:
R
gfg=read.csv('input_gfg.csv')  gfg[1:5,]
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.
How to Replace specific values in column in R DataFrame ?
Filter data by multiple conditions in R using Dplyr
Loops in R (for, while, repeat)
Change Color of Bars in Barchart using ggplot2 in R
How to change Row Names of DataFrame in R ?
How to Replace specific values in column in R DataFrame ?
How to change Row Names of DataFrame in R ?
How to Split Column Into Multiple Columns in R DataFrame?
Replace Specific Characters in String in R
Remove rows with NA in one column of R DataFrame
How to Install Go on Debian 10? - GeeksforGeeks

06 Oct, 2021
Go is an open-source programming language built by google to write microservices. Its syntax is inspired by java and the c++. Using Golang it is easy to build simple, reliable, and efficient software In this article we are going to see how we can install Golang in our Debian System.
System on which we are going to install Go:
Install neofetch to list the information about your system.
sudo apt install neofetch
Run the following command to execute neofetch:
neofetch
System Information
Installing Golang:
Step 1: Go to the Golang installation page and download the setup file.
Downloading Golang
Or run the following command:
wget https://golang.org/dl/go1.17.1.linux-amd64.tar.gz
Step 2: Navigate to the Downloads folder and extract the downloaded archive into /usr/localb, by running the following command in the terminal.
sudo tar -C /usr/local -xzf go1.17.1.linux-amd64.tar.gz
Extracting and moving the file
Step 3: Add /usr/local/go/bin to the PATH environment variable. To add the PATH, place the following command to the $HOME/.profile or /etc/profile.
export PATH=$PATH:/usr/local/go/bin
Exporting the path of the Golang
Step 4: Verify the installation of Golang by opening a new terminal and typing the following command:
go version
Golang  successfully installed
how-to-install
Picked
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install FFmpeg on Windows?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Set Git Username and Password in GitBash?
How to create a nested RecyclerView in Android
How to Install Jupyter Notebook on MacOS?
Installation of Node.js on Linux
How to Install FFmpeg on Windows?
How to Install Pygame on Windows ?
How to Add External JAR File to an IntelliJ IDEA Project?
How to Install Jupyter Notebook on MacOS?
Logger getResourceBundle() Method in Java with Examples - GeeksforGeeks

03 Jun, 2021
getResourceBundle() method of a Logger class is used to localise resource bundle for this logger. We can set ResourceBundle either by the setResourceBundle method or mapped from the resource bundle name set via the getLogger factory method for the current default locale and this method will return a ResourceBundle set by above-mentioned ways. If the result is null, then the Logger will use a resource bundle or resource bundle name inherited from its parent.Syntax:  
public ResourceBundle getResourceBundle()
Parameters: This method accepts nothing.Return value: This method return localization bundle.Below programs illustrate the getResourceBundle() method: Program 1:  
Java
// Java program to demonstrate// Logger.getParent() method import java.util.logging.*;import java.util.ResourceBundle; public class GFG {     private static Logger logger        = Logger.getLogger(            String                .class                .getPackage()                .getName());     public static void main(String args[])    {         logger.info("printing the message...");         ResourceBundle rs            = logger.getResourceBundle();         logger.info("Resource Bundle " + rs);    }}
Output: The output printed on eclipse IDE shown below-  
Program 2:  
Java
// Java program to demonstrate// Logger.getParent() method import java.util.logging.*;import java.util.ResourceBundle; public class GFG {     private static Logger logger        = Logger.getLogger(            GFG                .class                .getPackage()                .getName());     public static void main(String args[])    {         // Create ResourceBundle using getBundle        // myResource is a properties file        ResourceBundle bundle            = ResourceBundle                  .getBundle("myResource");         // Set ResourceBundle to logger        logger.setResourceBundle(bundle);         // Get ResourceBundle from logger        ResourceBundle rs            = logger.getResourceBundle();         // Log the ResourceBundle details        logger.info("Resource Bundle "                    + rs.getBaseBundleName());    }}
For above program there is a properties file name myResource. we have to add this file along side the class to execute the program. Output: The output printed on eclipse IDE shown below-  
Reference: https://docs.oracle.com/javase/10/docs/api/java/util/logging/Logger.html#getResourceBundle() 
ruhelaa48
Java - util package
Java-Functions
Java-Logger
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
Internal Working of HashMap in Java
Strings in Java
How will you detect the condition of the end of cursor rows in a COBOL-DB2 program?

The cursor can be used to fetch multiple rows from a DB2 table. However, we have to fetch this cursor in a loop so that values corresponding to a single row are assigned to host variables at a time. Based on this logic we have to process our loop till the cursor reaches the last row result.
The SQLCODE field takes the value as 100 when there are no more rows left in the cursor to be fetched. Practically, we can implement this in the following way.
SET WF-END-CURSOR-N TO TRUE
PERFORM UNTIL WF-END-CURSOR-Y
   EXEC SQL
      FETCH ORDER_CUR INTO :ORDER-ID
   END-EXEC
   IF SQLCODE = 100
      SET WF-END-CURSOR-Y TO TRUE
   ELSE
      PERFORM A20-PROCESS-RECORD
   END-IF
END-PERFORM
WF-END-CURSOR-Y and WF-END-CURSOR-N are two flags at 88 level which is used to control the loop. Once the SQLCODE has the value 100 that means the cursor has reached at the last row and loop is terminated.
Teradata - Drop Tables

DROP TABLE command is used to drop a table. When the DROP TABLE is issued, data in the table is deleted and the table is dropped.
Following is the generic syntax for DROP TABLE.
DROP TABLE <tablename>;

The following example drops the table ‘employee’.
DROP TABLE employee;

If you run the SHOW TABLE command after this, you will get an error message stating that the table doesn’t exist.
SHOW TABLE employee; 
*** Failure 3807 Object 'employee' does not exist. 
   Statement# 1, Info = 0 
*** Total elapsed time was 1 second.

 Print
 Add Notes
 Bookmark this page
How can we avoid a deadlock in Java?

In Java, a deadlock is a programming situation where two or more threads are blocked forever. A deadlock condition will occur with at least two threads and two or more resources.
Avoid Nested Locks: A deadlock mainly happens when we give locks to multiple threads. Avoid giving a lock to multiple threads if we already have given to one.
Avoid Unnecessary Locks: We can have a lock only those members which are required. Having a lock unnecessarily can lead to a deadlock.
Using Thread.join(): A deadlock condition appears when one thread is waiting other to finish. If this condition occurs we can use Thread.join() with the maximum time the execution will take.
public class DeadlockTest {
   public static void main(String[] args) throws InterruptedException {
      Object obj1 = new Object();
      Object obj2 = new Object();
      Object obj3 = new Object();
      Thread t1 = new Thread(new SyncThread(obj1, obj2), "t1");
      Thread t2 = new Thread(new SyncThread(obj2, obj3), "t2");
      t1.start();
      Thread.sleep(2000);
      t2.start();
      Thread.sleep(2000);
   }
}
class SyncThread implements Runnable {
   private Object obj1;
   private Object obj2;
   public SyncThread(Object o1, Object o2){
      this.obj1=o1;
      this.obj2=o2;
   }
   @Override
   public void run() {
      String name = Thread.currentThread().getName();
      System.out.println(name + " acquiring lock on " + obj1);
      synchronized (obj1) {
         System.out.println(name + " acquired lock on " + obj1);
         work();
      }
      System.out.println(name + " released lock on " + obj1);
      System.out.println(name + " acquiring lock on " + obj2);
      synchronized (obj2) {
         System.out.println(name + " acquired lock on " + obj2);
         work();
      }
      System.out.println(name + " released lock on " + obj2);
      System.out.println(name + " finished execution.");
   }
   private void work() {
      try {
         Thread.sleep(5000);
      } catch (InterruptedException ie) {
         ie.printStackTrace();
      }
   }
}
t1 acquiring lock on java.lang.Object@917d8d4
t1 acquired lock on java.lang.Object@917d8d4
t2 acquiring lock on java.lang.Object@5c4b42fb
t2 acquired lock on java.lang.Object@5c4b42fb
t1 released lock on java.lang.Object@917d8d4
t1 acquiring lock on java.lang.Object@5c4b42fb
t1 acquired lock on java.lang.Object@5c4b42fb
t2 released lock on java.lang.Object@5c4b42fb
t2 acquiring lock on java.lang.Object@528cb702
t2 acquired lock on java.lang.Object@528cb702
t1 released lock on java.lang.Object@5c4b42fb
t2 released lock on java.lang.Object@528cb702
t1 finished execution.
t2 finished execution.
Make 3D plot interactive in Jupyter Notebook (Python & Matplotlib)

In this article, we can take a program code to show how we can make a 3D plot interactive using Jupyter Notebook.
Create a new figure, or activate an existing figure.
Create a new figure, or activate an existing figure.
Create fig and ax variables using subplots method, where default nrows and ncols are 1, projection=’3d”.
Create fig and ax variables using subplots method, where default nrows and ncols are 1, projection=’3d”.
Get x, y and z using np.cos and np.sin function.
Get x, y and z using np.cos and np.sin function.
Plot the 3D wireframe, using x, y, z and color="red".
Plot the 3D wireframe, using x, y, z and color="red".
Set a title to the current axis.
Set a title to the current axis.
To show the figure, use plt.show() method.
To show the figure, use plt.show() method.
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
u, v = np.mgrid[0:2 * np.pi:30j, 0:np.pi:20j]
x = np.cos(u) * np.sin(v)
y = np.sin(u) * np.sin(v)
z = np.cos(v)
ax.plot_wireframe(x, y, z, color="red")
ax.set_title("Sphere")
plt.show()
Setting test iterations using Newman (Postman)

We can set test iterations using Newman with the help of the option –n.Newman's command to list down all options is − newman run –h. Options in
Newman is grouped into these categories −
Utility
Utility
Basic setup
Basic setup
Request options
Request options
Other Misc. Options
Other Misc. Options
Thus complete command to set iterations for two times should be −
newman run Collection1.json -n 2
Or,
newman run Collection1.json --iteration-count 2
Machine Learning with Docker and Kubernetes: Batch Inference | by Xavier Vasques | Towards Data Science

In this chapter, we will implement a batch inference from trained models in our Kubernetes Cluster we developed and installed in a previous chapter: https://xaviervasques.medium.com/machine-learning-with-docker-and-kubernetes-training-models-cbe33a08c999
You can find all the files used in this chapter on GitHub.
In order to start, we will need to modify our previous Dockerfile as follows:
Compared to our previous Dockerfile, we just added inference.py :
In inference.py we start to import the necessary libraries, read the environment variables set in our Docker image and read new data (test.csv) stored on GitHub to feed our serialized models to make predictions and provide an accuracy score. Here, we will download our previously trained models (Linear discriminant analysis and a multi-layer perceptron neural network) stored in a specified directory (/home/xavi/output) from a remote server (192.168.1.11) using SSH.
Now, we can go to the next step by building the docker image, run it to test our application locally, tag it with the name of an image repository on the Docker Hub registry, and push it to the registry and be ready to use the image in our Kubernetes cluster:
docker build -t kubernetes-inference -f Dockerfile .
To test if our code is ok, we will run our container locally to test the image:
docker run kubernetes-inference python3 train.py rm ./id_rsa
If everything is ok, we can push the new image to a repository using the CLI:
docker logindocker tag kubernetes-inference:latest xaviervasques/kubernetes-inference:latestdocker push xaviervasques/kubernetes-inference:latest
Once the image is successfully uploaded to the registry, we go to our project directory (connect to kubmaster) and create a configuration file, inference.yaml, that executes our python code:
The equivalent docker command would be:
docker run kubernetes-inference python3 inference.py rm ./id_rsa
We are finally ready to get our application running on Kubernetes. Launch the following command:
kubectl create -f inference.yaml
Check the Job objects by running:
kubectl get jobskubectl get pods — selector=job-name=inference-job
We can view the logs of the process (output of our code):
kubectl logs inference-job-stskf
Kubernetes serves as an excellent framework to deploy models effectively. We can use Kubernetes to deploy each of our models as independent and lightweight microservices. These microservices can be used for other applications. We can also work with Kubernetes to schedule our training and inference processes to run on a recurring schedule. Now, the next steps would be to deploy online inferences using REST APIs. You can find a deployment example of online inferences using REST APIs here:
How to Draw a Horizontal Barplot in R - GeeksforGeeks

03 Dec, 2021
A barplot is a representation of data in form of the bar the height of bar represents the number of values. In this article, we will discuss How to Draw a Horizontal Barplot in R programming language. 
R language supports two ways to plot a bar plot, and we will discuss how this can be modified to be put to our use.
R Language uses the function barplot() to create bar charts. Here, both vertical and Horizontal bars can be drawn.
Syntax: barplot(H, xlab, ylab, main, names.arg, col)
Parameters:
H: This parameter is a vector or matrix containing numeric values which are used in bar chart.
xlab: This parameter is the label for x axis in bar chart.
ylab: This parameter is the label for y axis in bar chart.
main: This parameter is the title of the bar chart.
names.arg: This parameter is a vector of names appearing under each bar in bar chart.
col: This parameter is used to give colors to the bars in the graph.
The bar function has a field named “horiz” keep that field value “True” to create the bar plot horizontally.
Example:
R
# Create example datadata <- data.frame(x_axis = (1:10),                     y_axis = 9:0) # barplot() function is used to# plot the bar and horiz field is# used to plot bar horizontallybarplot(data$x_axis ~ data$y_axis,        horiz = TRUE)
Output:
fig 1: Horizontal bar plot
In this method, we draw the bar plot using the ggplot2 function. ggplot2 have a function named geom_bar() which is used to plot the horizontal bar, and we put our data into the geom_bar function with ggplot() to plot the bar. At last, we will flip the whole plot using the coord_flip() function. A flipped vertical plot will generate a horizontal plot.
Example:
R
# load the library              library("ggplot2") # data frame createddata <- data.frame(x_axis = (1:10),                     y_axis = 9:0) # bar is created with the help of# grom_bar() and ggplot() functionggp <- ggplot(data, aes(x_axis, y_axis)) +     geom_bar(stat = "identity") # complete graph get flipped with the# help of coord_flip() functionggp +  coord_flip()
Output:
fig 2: Horizontal bar plot
sooda367
Picked
R-Charts
R-ggplot
R-Graphs
R-plots
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
K-Means Clustering in R Programming
How to filter R DataFrame by values in a column?
How to import an Excel File into R ?
Logistic Regression in R Programming
How to change the order of bars in bar chart in R ?
How to filter R dataframe by multiple conditions?
Count Non-Leaf nodes in a Binary Tree in C++

We are given with a binary tree and the task is to calculate the count of non-leaf nodes available in a binary tree.
Binary Tree is a special data structure used for data storage purposes. A binary tree has a special condition that each node can have a maximum of two children. A binary tree has the benefits of both an ordered array and a linked list as search is as quick as in a sorted array and insertion or deletion operation are as fast as in linked list. Non-leaf nodes are also known as parent nodes as they have more than 0 child and less than two children.
Structure of a binary tree is given below −
Input −
Output − count of non-leaf nodes is: 3
Explanation − In the given tree, we have 27, 14 and 35 as non-leaf nodes since they have more than 0 children and less than 2 children.
Create the structure of a binary tree containing, pointer to a left node, pointer to a right node and a data part stored in a node
Create the structure of a binary tree containing, pointer to a left node, pointer to a right node and a data part stored in a node
Create a function that will insert a node whenever this function is called. For that, insert data in a new node and also set the right and left pointer of a new node to a NULL and return the node.
Create a function that will insert a node whenever this function is called. For that, insert data in a new node and also set the right and left pointer of a new node to a NULL and return the node.
Create a recursive function that will count the number of non-leaf nodes in a binary tree.Check If root is NULL or left of root is NULL and right of root is NULL then return 0Return 1 + recursive call to this function with left pointer + recursive call to this function with right pointer
Create a recursive function that will count the number of non-leaf nodes in a binary tree.
Check If root is NULL or left of root is NULL and right of root is NULL then return 0
Return 1 + recursive call to this function with left pointer + recursive call to this function with right pointer
Print the count
Print the count
 Live Demo
#include <iostream>
using namespace std;
// Node's structure
struct Node {
   int data;
   struct Node* left;
   struct Node* right;
};
// To define the new node
struct Node* newNode(int data){
   struct Node* node = new Node;
   node->data = data;
   node->left = node->right = NULL;
   return (node);
}
// Count the non leaf nodes.
int nonleaf(struct Node* root){
   if (root == NULL || (root->left == NULL && root->right == NULL)){
      return 0;
   }
   return 1 + nonleaf(root->left) + nonleaf(root->right);
}
// Main function
int main(){
   struct Node* root = newNode(10);
   root->left = newNode(21);
   root->right = newNode(33);
   root->left->left = newNode(48);
   root->left->right = newNode(51);
   cout << nonleaf(root);
   return 0;
}
If we run the above code it will generate the following output −
count of non-leaf nodes is: 2
How to make semilogx and semilogy plots in Matplotlib?

To make semilogx and semilogy plots, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
create a new figure or activate an existing figure.
Scatter and plot x and y data points.
Make a plot with log scaling on the X axis.
Make a plot with log scaling on the Y axis.
To display the figure, use show() method.
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

x = [10, 100, 1000, 10000, 100000]
y = [2, 4, 8, 16, 32]

fig = plt.figure()

plt.scatter(x, y)
plt.plot(x, y)

plt.semilogx()
plt.semilogy(basey=2)

plt.show()
Setting Color Property in CSS

We can define colors for text, borders and background of elements using CSS. The color property is used to specify the text color for an element.
The syntax for CSS color property is as follows −
Selector {
   color: /*value*/
}
The following examples illustrate CSS color property −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
div {
   color: seashell;
   background-color: lightcoral;
}
p {
   font-size: 1.5em;
   color: blue;
   background-color: palegreen;
   box-shadow: 0 0 5px 1px rgb(0,0,0);
}
</style>
</head>
<body>
<div>
This is demo text.
<p>
Text added for reference.
</p>
This is demo text 2.
</div>
</body>
</html>
This gives the following output −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
* {
   text-align: center;
}
h3 {
   color: red;
   border: 2px ridge rosybrown;
}
p {
   color: royalblue;
   background-color: cornsilk;
   box-shadow: 0 0 5px 1px deeppink;
}
</style>
</head>
<body>
<h3>Demo Demo Demo Demo</h3>
<p>Demo text here</p>
</body>
</html>
This gives the following output −
string.byte() function in Lua programming

The string.byte() function is one of the most widely used Lua string library functions that takes a character or a string as an argument and then converts that character into its internal numeric representations.
The character to internal numeric representations can be easily interpreted from the ASCII table.
string.byte(ch)
or
string.byte(ch,idx)
In the above representation of the string.byte() function, the ch identifier represents the character that we want to convert into a decimal value. Also, the idx identifier represents a character at that index of the string passed as an argument.
Let’s consider a few examples where we will make use of the string.byte() function.
Consider an example shown below −
 Live Demo
s = string.byte("a")
print(s)
97
We can also pass a string in the argument to the string.byte() function, and if we don’t specify any index then that string will only print the first character’s internal integer representation.
Consider the example shown below −
 Live Demo
s = string.byte("abc")
print(s)
97
Let’s consider an example where we will pass an index as the second argument to the string.byte() function. Consider the example shown below −
 Live Demo
s = string.byte("abc",2)
print(s)
98
Note − The indexing of the string starts at 1.
What is an Event Handling and describe the components in Event Handling in Java?

The GUI in Java processes the interactions with users via mouse, keyboard and various user controls such as button, checkbox, text field, etc. as the events. These events are to be handled properly to implement Java as an Event-Driven Programming.
Events
Event Sources
Event Listeners/Handlers
The events are defined as an object that describes a change in the state of a source object.
The Java defines a number of such Event Classes inside java.awt.event package
Some of the events are ActionEvent, MouseEvent, KeyEvent, FocusEvent,  ItemEvent and etc.
A source is an object that generates an event.
An event generation occurs when an internal state of that object changes in some way.
A source must register listeners in order for the listeners to receive the notifications about a specific type of event.
Some of the event sources are Button, CheckBox, List, Choice, Window and etc.
A listener is an object that is notified when an event occurs.
A Listener has two major requirements, it should be registered to one more source object to receiving event notification and it must implement methods to receive and process those notifications.
Java has defined a set of interfaces for receiving and processing the events under the java.awt.event package.
Some of the listeners are ActionListener, MouseListener, ItemListener, KeyListener, WindowListener and etc.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class EventListenerTest extends JFrame implements ActionListener {
   JButton button;
   public static void main(String args[]) {
      EventListenerTest object = new EventListenerTest();
      object.createGUI();
   }
   void createGUI() {
      button = new JButton(" Click Me !");
      setSize(300,200);
      setLocationRelativeTo(null);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setVisible(true);
      add(button);
      button.addActionListener(this);
   }
   public void actionPerformed(ActionEvent ae) {
      if(ae.getSource() == button) {
         JOptionPane.showMessageDialog(null, "Generates an Action Event");
      }
   }
}
Explain about nested queries in DBMS

A nested query is a query that has another query embedded within it. The embedded query is called a subquery.
A subquery typically appears within the WHERE clause of a query. It can sometimes appear in the FROM clause or HAVING clause.
Let’s learn about nested queries with the help of an example.
Find the names of employee who have regno=103
The query is as follows −
select E.ename from employee E where E.eid IN (select S.eid from salary S where S.regno=103);
The student table is created as follows −
create table student(id number(10), name varchar2(20),classID number(10), marks varchar2(20));
Insert into student values(1,'pinky',3,2.4);
Insert into student values(2,'bob',3,1.44);
Insert into student values(3,'Jam',1,3.24);
Insert into student values(4,'lucky',2,2.67);
Insert into student values(5,'ram',2,4.56);
select * from student;
You will get the following output −
The teacher table is created as follows −
Create table teacher(id number(10), name varchar(20), subject varchar2(10), classID number(10), salary number(30));
Insert into teacher values(1,’bhanu’,’computer’,3,5000);
Insert into teacher values(2,'rekha','science',1,5000);
Insert into teacher values(3,'siri','social',NULL,4500);
Insert into teacher values(4,'kittu','mathsr',2,5500);
select * from teacher;
You will get the following output −
The class table is created as follows −
Create table class(id number(10), grade number(10), teacherID number(10), noofstudents number(10));
insert into class values(1,8,2,20);
insert into class values(2,9,3,40);
insert into class values(3,10,1,38);
select * from class;
You will get the following output −
Now let’s work on nested queries
Select AVG(noofstudents) from class where teacherID IN(
Select id from teacher
Where subject=’science’ OR subject=’maths’);
You will get the following output −
20.0
SELECT * FROM student
WHERE classID = (
   SELECT id
   FROM class
   WHERE noofstudents = (
      SELECT MAX(noofstudents)
      FROM class));
You will get the following output −
4|lucky |2|2.67
5|ram   |2|4.56
Where does MySQL store database files?

To know where MySQL store database files, you can use the variable @@datadir. The query is as follows −
mysql> select @@datadir;
The following is the output that displays the path −
+---------------------------------------------+
| @@datadir                                   |
+---------------------------------------------+
| C:\ProgramData\MySQL\MySQL Server 8.0\Data\ |
+---------------------------------------------+
1 row in set (0.00 sec)
Here is the snapshot where MySQL store database files i.e. the same path we got above −
Now, let us verify whether the above databases are present or not with the help of SHOW command.
The query is as follows −
mysql> SHOW DATABASES;
Here is the output −
+--------------------+
| Database           |
+--------------------+
| business           |
| database1          |
| databasesample     |
| education          |
| hello              |
| information_schema |
| javadatabase2      |
| javasampledatabase |
| mybusiness         |
| mydatabase         |
| mysql              |
| performance_schema |
| sample             |
| sampledatabase     |
| schemasample       |
| sys                |
| test               |
| test3              |
| universitydatabase |
+--------------------+
19 rows in set (0.12 sec)
Look at the above output, all databases are matched.
C library function - ispunct()

The C library function int ispunct(int c) checks whether the passed character is a punctuation character. A punctuation character is any graphic character (as in isgraph) that is not alphanumeric (as in isalnum).
Following is the declaration for ispunct() function.
int ispunct(int c);
c − This is the character to be checked.
c − This is the character to be checked.
This function returns a non-zero value(true) if c is a punctuation character else, zero (false).
The following example shows the usage of ispunct() function.
#include <stdio.h>
#include <ctype.h>

int main () {
   int var1 = 't';
   int var2 = '1';
   int var3 = '/';
   int var4 = ' ';

   if( ispunct(var1) ) {
      printf("var1 = |%c| is a punctuation character\n", var1 );
   } else {
      printf("var1 = |%c| is not a punctuation character\n", var1 );
   }
   
   if( ispunct(var2) ) {
      printf("var2 = |%c| is a punctuation character\n", var2 );
   } else {
      printf("var2 = |%c| is not a punctuation character\n", var2 );
   }
   
   if( ispunct(var3) ) {
      printf("var3 = |%c| is a punctuation character\n", var3 );
   } else {
      printf("var3 = |%c| is not a punctuation character\n", var3 );
   }
   
   if( ispunct(var4) ) {
      printf("var4 = |%c| is a punctuation character\n", var4 );
   } else {
      printf("var4 = |%c| is not a punctuation character\n", var4 );
   }
   
   return(0);
}   
Let us compile and run the above program that will produce the following result −
var1 = |t| is not a punctuation character
var2 = |1| is not a punctuation character
var3 = |/| is a punctuation character
var4 = | | is not a punctuation character


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
Converting 12 hour format time to 24 hour format in JavaScript

We are required to write a JavaScript function that takes in a time string in the following format −
const timeStr = '05:00 PM';
Note that the string will always be of the same format i.e.
HH:MM mm
Our function should make some computations on the string received and then return the corresponding 24 hour time in the following format: HH:MM
For the above string, the output should be −
const output = '17:00';
The code for this will be −
 Live Demo
const timeStr = '05:00 PM';
const secondTimeStr = '11:42 PM';
const convertTime = timeStr => {
   const [time, modifier] = timeStr.split(' ');
   let [hours, minutes] = time.split(':');
   if (hours === '12') {
      hours = '00';
   }
   if (modifier === 'PM') {
      hours = parseInt(hours, 10) + 12;
   }
   return `${hours}:${minutes}`;
};
console.log(convertTime(timeStr));
console.log(convertTime(secondTimeStr));
And the output in the console will be −
17:00
23:42
How to get ER model of database from server with MySQL Workbench?

To get ER model of database from server, you need to first launch MySQL Workbench. The snapshot is as follows −
After that you need to select the “Database” menu −
Database->Reverse Engineer
After that a wizard will open as in the following screenshot. Add the password and press OK twice.
After pressing the OK button, you will get the next wizard and you need to press next button.
The following would be visible now −
After that you need to select “Model” menu as I have marked in the above wizard.
Model->Create Diagram from Catalog Objects
After selecting the option, you will get the ER model of database.
The following is the screenshot −
Here is the sample ER diagram of our database −
Go if statement

Use the if statement to specify a block of Go code to be executed if a condition is true.

    Note that if is in lowercase letters. Uppercase letters (If or IF) will generate an error.
  
In the example below, we test two values to find out if 20 is greater than 18. If the condition is true, print some text:
We can also test variables:
In the example above we use two variables, x and y, 
to test whether x is greater than y (using the > operator). As x is 20, and y is 18, and we know that 20 is greater than 18, we print to the screen that "x is greater than y".

Print "Hello World" if x is greater than y.
package main   
import ("fmt") 
func main() {
  var x = 50
  var y = 10
   x  y {
  fmt.Print("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.
Tryit Editor v3.7 - Show Java

import java.util.Scanner; // import the Scanner class 

class Main {
  public static void main(String[] args) {
    Scanner myObj = new Scanner(System.in);
    String userName;
    
    // Enter username and press Enter
    System.out.println("Enter username"); 
    userName = myObj.nextLine();   
       
    System.out.println("Username is: " + userName);
Apache Pig - Union Operator

The UNION operator of Pig Latin is used to merge the content of two relations. To perform UNION operation on two relations, their columns and domains must be identical.
Given below is the syntax of the UNION operator.
grunt> Relation_name3 = UNION Relation_name1, Relation_name2;

Assume that we have two files namely student_data1.txt and student_data2.txt in the /pig_data/ directory of HDFS as shown below.
Student_data1.txt
001,Rajiv,Reddy,9848022337,Hyderabad
002,siddarth,Battacharya,9848022338,Kolkata
003,Rajesh,Khanna,9848022339,Delhi
004,Preethi,Agarwal,9848022330,Pune
005,Trupthi,Mohanthy,9848022336,Bhuwaneshwar
006,Archana,Mishra,9848022335,Chennai.

Student_data2.txt
7,Komal,Nayak,9848022334,trivendram.
8,Bharathi,Nambiayar,9848022333,Chennai.

And we have loaded these two files into Pig with the relations student1 and student2 as shown below.
grunt> student1 = LOAD 'hdfs://localhost:9000/pig_data/student_data1.txt' USING PigStorage(',') 
   as (id:int, firstname:chararray, lastname:chararray, phone:chararray, city:chararray); 
 
grunt> student2 = LOAD 'hdfs://localhost:9000/pig_data/student_data2.txt' USING PigStorage(',') 
   as (id:int, firstname:chararray, lastname:chararray, phone:chararray, city:chararray);
Let us now merge the contents of these two relations using the UNION operator as shown below.
grunt> student = UNION student1, student2;
Verify the relation student using the DUMP operator as shown below.
grunt> Dump student; 
It will display the following output, displaying the contents of the relation student.
(1,Rajiv,Reddy,9848022337,Hyderabad) (2,siddarth,Battacharya,9848022338,Kolkata)
(3,Rajesh,Khanna,9848022339,Delhi)
(4,Preethi,Agarwal,9848022330,Pune) 
(5,Trupthi,Mohanthy,9848022336,Bhuwaneshwar)
(6,Archana,Mishra,9848022335,Chennai) 
(7,Komal,Nayak,9848022334,trivendram) 
(8,Bharathi,Nambiayar,9848022333,Chennai)


    46 Lectures 
     3.5 hours 

 Arnab Chakraborty

    23 Lectures 
     1.5 hours 

 Mukund Kumar Mishra

    16 Lectures 
     1 hours 

 Nilay Mehta

    52 Lectures 
     1.5 hours 

 Bigdata Engineer

    14 Lectures 
     1 hours 

 Bigdata Engineer

    23 Lectures 
     1 hours 

 Bigdata Engineer
 Print
 Add Notes
 Bookmark this page
How can we sort a JSONObject in Java?


A JSONObject is an unordered collection of a key, value pairs, and the values can be any of these types like Boolean, JSONArray, JSONObject, Number and String. The constructor of a JSONObject can be used to convert an external form JSON text into an internal form whose values can be retrieved with the get() and opt() methods or to convert values into a JSON text using the put() and toString() methods.
In the below example, we can sort the values of a JSONObject in the descending order.
import org.json.*;
import java.util.*;
public class JSonObjectSortingTest {
   public static void main(String[] args) {
      List<Student> list = new ArrayList<>();
      try {
         JSONObject jsonObj = new JSONObject();
         jsonObj.put("Raja", 123);
         jsonObj.put("Jai", 789);
         jsonObj.put("Adithya", 456);
         jsonObj.put("Ravi", 111);
         Iterator<?> keys = jsonObj.keys();
         Student student;
         while(keys.hasNext()) {
            String key = (String) keys.next();
            student = new Student(key, jsonObj.optInt(key));
            list.add(student);
         }
         Collections.sort(list, new Comparator<Student>() {
            @Override
            public int compare(Student s1, Student s2) {
               return Integer.compare(s2.pwd, s1.pwd);
            }
         });
         System.out.println("The values of JSONObject in the descending order:");
         for(Student s : list) {
            System.out.println(s.pwd);
         }
      } catch(JSONException e) {
         e.printStackTrace();
      }
   }
}
// Student class
class Student {
   String username;
   int pwd;
   Student(String username, int pwd) {
      this.username = username;
      this.pwd = pwd;
   }
}
The values of JSONObject in the descending order:
789
456
123
111
Python program to print check board pattern of n*n using numpy

Given the value of n, our task is to display the check board pattern for a n x n matrix.
Different types of functions to create arrays with initial value are available in numpy . NumPy is the fundamental package for scientific computing in Python.
Step 1: input order of the matrix.
Step 2: create n*n matrix using zeros((n, n), dtype=int).
Step 3: fill with 1 the alternate rows and columns using the slicing technique.
Step 4: print the matrix.

import numpy as np
def checkboardpattern(n):
   print("Checkerboard pattern:")
   x = np.zeros((n, n), dtype = int)
   x[1::2, ::2] = 1
   x[::2, 1::2] = 1
   # print the pattern
   for i in range(n):
      for j in range(n):
         print(x[i][j], end =" ")
      print()
# Driver code
n = int(input("Enter value of n ::>"))
checkboardpattern(n)
Enter value of n ::>4
Checkerboard pattern:
0 1 0 1  
1 0 1 0  
0 1 0 1  
1 0 1 0
Python – Iterate through list without using the increment variable

22 Jun, 2021
Python Lists is much like flexible size arrays, declared in other languages like vector in C++, array list in Java, etc. Lists are heterogeneous, making it the most effective feature in Python. Lists are mutable, and hence can be modified even after they have been formed.
The most common approach is to iterate through a list using the increment variable i:
Python3
# Initializing the listList = ["Geeks", 4, 'Geeks!'] # Using index variable to access# each element of the listfor i in range(len(List)):    print(List[i], end=" ")
Output:
Geeks 4 Geeks! 
This is the most common practice where index variable i is used for accessing each element of the list using only the index of that element in that list. However, there are various ways to iterate through a list without using the index variable.
Below are some methods to Iterate through a list without using the index variable:
Method 1: 
Explicitly iterating through the list using a common variable for each element rather than the index.
Python3
# Initializing the listList = ["Geeks", 4, 'Geeks!'] # Using a common variable to access# each element of the listfor ele in List:    print(ele, end=" ")
Output:
Geeks 4 Geeks! 
Method 2: 
The enumerate() method adds a counter to the list and returns it in a form of enumerate object which can be used to access elements of the list 
Python3
# Initializing the listList = ["Geeks", 4, 'Geeks!'] # Using enumerate()for ele in enumerate(List):    print(ele[1], end=" ")
Output:
Geeks 4 Geeks! 
Method 3: 
Using the nditer() method in numpy to iterate over a list after converting them into an array. 
Python3
# Importing required modulesimport numpy # Initializing the listList = ["Geeks", 4, 'Geeks!'] # Converting to arrayArray = numpy.array(List) # Using enumeratefor ele in numpy.nditer(Array):    print(ele, end=" ")
Output:
Geeks 4 Geeks!
surindertarika1234
python-basics
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.