code-rag-bench/online-tutorials huggingface dataset:
HTML | input value Attribute - GeeksforGeeks

16 Apr, 2019
The value attribute for <input> element in HTML is used to specify the initial value of the input element. It has different meaning for different input type:
The “button”, “reset” and “submit” property specifies the text on the button.
The “text”, “password” and “hidden” property specifies the initial value of the input field.
The “checkbox”, “radio” and “image” property specifies the value associated with the input.
Syntax:
<input value = "text">
Attribute Value: It contains single value text which specifies the value of input element.
Example 1: This example describes the <input> value attribute.
<!DOCTYPE html><html>  <head>    <title>HTML input value Attribute</title></head>  <body style = "text-align:center">          <h1 style = "color:green;">        GeeksforGeeks    </h1>              <h2>        HTML input value Attribute    </h2>              Input: <input type = "text"             value = "GeeksforGeeks"></body>  </html>                    
Output:
Example 2: This example describes the <input> value attribute.
<!DOCTYPE html><html>  <head>    <title>HTML input value Attribute</title></head>  <body style = "text-align:center">          <h1 style = "color:green;">        GeeksforGeeks    </h1>               <h2>        HTML input value Attribute    </h2>               <input type = "button" value = "Submit"></body>  </html>
Output:
Supported Browsers: The browser supported by <input> value attribute are listed below:
Apple Safari 1.0
Google Chrome 1.0
Firefox 1.0
Opera 1.0
Internet Explorer 2.0
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
HTML-Attributes
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 ?
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
Types of CSS (Cascading Style Sheet)
Form validation using HTML and JavaScript
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
gcd() function Python

Greatest common divisor or gcd is a mathematical expression to find the highest number which can divide both the numbers whose gcd has to be found with the resulting remainder as zero. It has many mathematical applications. Python has a inbuilt gcd function in the math module which can be used for this purpose.
It accepts two integers as parameter and returns the integer which is the gcd value.
Syntax: gcd(x,y)
Where x and y are positive integers.
In the below example we print the result of gcd of a pair of integers.
import math
print ("GCD of 75 and 30 is ",math.gcd(75, 30))
print ("GCD of 0 and 12 is ",math.gcd(0, 12))
print ("GCD of 0 and 0 is ",math.gcd(0, 0))
print ("GCD of -24 and -18 is ",math.gcd(-24, -18))
Running the above code gives us the following result −
GCD of 75 and 30 is 15
GCD of 0 and 12 is 12
GCD of 0 and 0 is 0
GCD of -24 and -18 is 6
How to change the title size of a graph using ggplot2 in R?

The size of a graph title mattes a lot for the visibility because it is the first thing people look at after plot area. Its size must not be very large nor very small but is should be different from the axis titles and axes labels so that there exists a clarity in the graph. This can be done by using theme function.
Consider the below data frame −
set.seed(1)
x <-rnorm(100)
df <-data.frame(x)
library(ggplot2)
Creating histogram of x and writing title of the graph −
ggplot(df,aes(x))+geom_histogram(binwidth=0.5)+ggtitle("Histogram")
Changing the size of the title
ggplot(df,aes(x))+geom_histogram(binwidth=0.5)+ggtitle("Histogram")+theme(plot.title = element_text(size=20))
Initialization of static variables in C - GeeksforGeeks

31 Jul, 2018
In C, static variables can only be initialized using constant literals. For example, following program fails in compilation.
#include<stdio.h>int initializer(void){    return 50;}  int main(){    static int i = initializer();    printf(" value of i = %d", i);    getchar();    return 0;}
If we change the program to following, then it works without any error.
#include<stdio.h>int main(){    static int i = 50;    printf(" value of i = %d", i);    getchar();    return 0;}
The reason for this is simple: All objects with static storage duration must be initialized (set to their initial values) before execution of main() starts. So a value which is not known at translation time cannot be used for initialization of static variables.
Thanks to Venki and Prateek for their contribution.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
C-Storage Classes and Type Qualifiers
C Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
fork() in C
Command line arguments in C/C++
Function Pointer in C
Substring in C++
Different methods to reverse a string in C/C++
Structures in C
TCP Server-Client implementation in C
Enumeration (or enum) in C
Data Types in C
std::string class in C++
Calculate age based on date of birth in MySQL?

Calculate Age based on date of birth with the help of DATE_FORMAT() method in MySQL. Firstly, get the current date time with the help of now() method and you can place your date of birth in DATE_FORMAT().
The syntax is as follows −
SELECT DATE_FORMAT(FROM_DAYS(DATEDIFF(now(),'yourDateofbirth')), '%Y')+0 AS anyVariableName;
Apply the above syntax to calculate age from yourDateofbirth. In the above syntax, replace yourDateofbirth with your date of birth. The query is as follows −
SELECT DATE_FORMAT(FROM_DAYS(DATEDIFF(now(),'2010-11-25')), '%Y')+0 AS Age;
The following is the output −
+------+
| Age  |
+------+
|    8 |
+------+
1 row in set (0.00 sec)
Let us now see this in an example. Firstly, create a table −
mysql> create table AgeCalculationFromDatetime
   -> (
   -> YourDateofBirth datetime
   -> );
Query OK, 0 rows affected (0.52 sec)
Inserting date of birth into table. The query is as follows −
mysql> insert into AgeCalculationFromDatetime values('1995-11-25');
Query OK, 1 row affected (0.13 sec)
Displaying all records with the help of select statement. The query is as follows −
mysql> select *from AgeCalculationFromDatetime;
The following is the output −
+---------------------+
| YourDateofBirth     |
+---------------------+
| 1995-11-25 00:00:00 |
+---------------------+
1 row in set (0.00 sec)
The query to calculate age is as follows −
mysql> SELECT DATE_FORMAT(FROM_DAYS(DATEDIFF(now(),YourDateofBirth)), '%Y')+0 AS Age from AgeCalculationFromDatetime;
Here is the output −
+------+
| Age  |
+------+
| 23   |
+------+
1 row in set (0.00 sec)`
MySQLi - PHP Syntax

MySQL works very well in combination of various programming languages like PERL, C, C++, JAVA and PHP. Out of these languages, PHP is the most popular one because of its web application development capabilities.
This tutorial focuses heavily on using MySQL in a PHP environment. If you are interested in MySQL with PERL, then you can consider reading the PERL Tutorial.
PHP provides various functions to access the MySQL database and to manipulate the data records inside the MySQL database. You would require to call the PHP functions in the same way you call any other PHP function.
The PHP functions for use with MySQL have the following general format −
mysqli function(value,value,...);

The second part of the function name is specific to the function, usually a word that describes what the function does. The following are two of the functions, which we will use in our tutorial −
$mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
mysqli→query(,"SQL statement");

The following example shows a generic syntax of PHP to call any MySQL function.
<html>
   <head>
      <title>PHP with MySQL</title>
   </head>
   <body>
      <?php
         $retval = mysqli - > <i>function</i>(value, [value,...]);
         if( !$retval ) {
            die ( "Error: a related error message" );
         }
         // Otherwise MySQL  or PHP Statements
      ?>
   </body>
</html>
Starting from the next chapter, we will see all the important MySQL functionality along with PHP.

    14 Lectures 
     1.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
HSQLDB - Create Table

The basic mandatory requirements to create a table are table name, field names, and the data types to those fields. Optionally, you can also provide the key constraints to the table.
Take a look at the following syntax.
CREATE TABLE table_name (column_name column_type);

Let us create a table named tutorials_tbl with the field-names such as id, title, author, and submission_date. Take a look at the following query.
CREATE TABLE tutorials_tbl (
   id INT NOT NULL,
   title VARCHAR(50) NOT NULL,
   author VARCHAR(20) NOT NULL,
   submission_date DATE,
   PRIMARY KEY (id) 
);
After execution of the above query, you will receive the following output −
(0) rows effected

Following is the JDBC program used to create a table named tutorials_tbl into the HSQLDB database. Save the program into CreateTable.java file.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class CreateTable {
   
   public static void main(String[] args) {
      
      Connection con = null;
      Statement stmt = null;
      int result = 0;
      
      try {
         Class.forName("org.hsqldb.jdbc.JDBCDriver");
         con = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost/testdb", "SA", "");
         stmt = con.createStatement();
         
         result = stmt.executeUpdate("CREATE TABLE tutorials_tbl (
            id INT NOT NULL, title VARCHAR(50) NOT NULL,
            author VARCHAR(20) NOT NULL, submission_date DATE,
            PRIMARY KEY (id));
         ");
			
      }  catch (Exception e) {
         e.printStackTrace(System.out);
      }
      System.out.println("Table created successfully");
   }
}
You can start the database using the following command.
\>cd C:\hsqldb-2.3.4\hsqldb
hsqldb>java -classpath lib/hsqldb.jar org.hsqldb.server.Server --database.0
file:hsqldb/demodb --dbname.0 testdb
Compile and execute the above program using the following command.
\>javac CreateTable.java
\>java CreateTable

After execution of the above command, you will receive the following output −
Table created successfully

 Print
 Add Notes
 Bookmark this page
Print all subsequences of a string using Iterative Method in C++

In this problem, we are given a string and we have to find the substring from the given string. The substring to be found should start with a vowel and end
with constant character.
A string is an array of characters.
The substring that is to be generated in this problem can be generated by
deleting some characters of the string. And without changing the order of the string.
Input: ‘abc’
Output: ab, ac, abc
To solve this problem, we will iterate the string and fix vowels and check for
the next sequence. Let’s see an algorithm to find a solution −
Step 1: Iterate of each character of the string, with variable i.
Step 2: If the ith character is a vowel.
Step 3: If the jth character is a consonant.
Step 4: Add to the HashSet, substring from 1st character to jth character.
Step 5: Repeat the following steps and find substrings from the string.
In the iterative approach, we will iterate over all string. From 1 to 2legth(string)−1.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
string subString(string s, int binary){
   string sub = "";
   int pos;
   while(binary>0){
      pos=log2(binary&-binary)+1;
      sub=s[pos-1]+sub;
      binary= (binary & ~(1 << (pos-1)));
   }
   reverse(sub.begin(),sub.end());
   return sub;
}
void findAllSubStrings(string s){
   map<int, set<string> > sorted_subsequence;
   int len = s.size();
   int limit = pow(2, len);
   for (int i = 1; i <= limit - 1; i++) {
      string sub = subString(s, i);
      sorted_subsequence[sub.length()].insert(sub);
   }
   for (auto it : sorted_subsequence) {
      for (auto ii : it.second)
         cout<<ii<<" ";
      cout<<"\t";
   }
}
int main() {
   string s = "wxyz";
   cout<<"The substring are :\n";
   findAllSubStrings(s);
   return 0;
}
The substring is −
w x y z wx wy wz xy xz yz wxy wxz wyz xyz wxyz
Count digits in a factorial in C++

We are given an integer value and the task is to first calculate the factorial of a number and then calculate the total number of digits in a result.
Factorial of a number is calculated by multiplying the digits in a number while decrementing the value of digit by 1. It is denoted by the symbol ‘!’ i.e. 0!, 1!, 2!, 3!, 5!,....,etc. Factorial of 0! and 1! is always 1.
I.e. factorial of 2 = 2 * (2-1) = 2 * 1 = 2
      factorial of 3 = 3 * (3-1) * (2-1) = 3 * 2 * 1 = 6
Input − factorial(6)
Output − number of digits in factorial(6) is: 3
Explanation − since the factorial value of 6 is 720 and it contains 3 digits therefore, the result is 3
Input − factorial(12)
Output− number of digits in factorial(12) is: 9
Explanation − since the factorial value of 12 is 479001600 and it contains 9 digits therefore, the result is 9.
Input the number of which factorial needs to be calculated .
Input the number of which factorial needs to be calculated .
If the number is less than 0 then return 0 because negative number don’t have any
factorial value
If the number is less than 0 then return 0 because negative number don’t have any
factorial value
If the number is 1 then return 1 because 1! Is 1 and it has 1 digit.
If the number is 1 then return 1 because 1! Is 1 and it has 1 digit.
If the number is greater than 1 i.e. starts with 2 or more than create one loop, starting from 2 till it is less than or equals to number
If the number is greater than 1 i.e. starts with 2 or more than create one loop, starting from 2 till it is less than or equals to number
Take one temporary variable let’s say d and initialise it with 0 outside the loop and inside the loop keep adding it with the value of log10(i) till every iteration of i.
Take one temporary variable let’s say d and initialise it with 0 outside the loop and inside the loop keep adding it with the value of log10(i) till every iteration of i.
After that, return the floor value of ‘floor(d)+1’
After that, return the floor value of ‘floor(d)+1’
Print the result.
Print the result.
 Live Demo
#include <iostream>
#include <cmath>
using namespace std;
// This function returns the number of digits present in num!
int count_digits(int num){
   // factorial exists only if num <= 0
   if (num < 0){
      return 0;
   }
   // base case
   if (num <= 1){
      return 1;
   }
   // else iterate through num and calculate the
   // value
   double d = 0;
   for (int i=2; i<=num; i++){
      d += log10(i);
   }
   return floor(d) + 1;
}
int main(){
   cout<<"number of digits in factorial(1) is: "<<count_digits(1)<< endl;
   cout<<"number of digits in factorial(6) is: "<<count_digits(6) << endl;
   cout<<"number of digits in factorial(106) is: "<<count_digits(106) << endl;
   return 0;
}
If we run the above code it will generate the following output −
number of digits in factorial(1) is: 1
number of digits in factorial(6) is: 3
number of digits in factorial(106) is: 171
Python | Check for Nth index existence in list - GeeksforGeeks

27 Aug, 2019
Sometimes, while working with lists, we can have a problem in which we require to insert a particular element at an index. But, before that it is essential to know that particular index is part of list or not. Let’s discuss certain shorthands that can perform this task error free.
Method #1 : Using len()This task can be performed easily by finding the length of list using len(). We can check if the desired index is smaller than length which would prove it’s existence.
# Python3 code to demonstrate working of# Check for Nth index existence in list# Using len()  # initializing listtest_list = [4, 5, 6, 7, 10]  # printing original listprint("The original list is : " + str(test_list))  # initializing N N = 6  # Check for Nth index existence in list# Using len()res = len(test_list) >= N  # printing result print("Is Nth index available? : " + str(res))
The original list is : [4, 5, 6, 7, 10]
Is Nth index available? : False

 
Method #2 : Using try-except block + IndexError exceptionThis task can also be solved using the try except block which raises a IndexError exception if we try to access an index not a part of list i.e out of bound.
# Python3 code to demonstrate working of# Check for Nth index existence in list# Using try-except block + IndexError exception  # initializing listtest_list = [4, 5, 6, 7, 10]  # printing original listprint("The original list is : " + str(test_list))  # initializing N N = 6  # Check for Nth index existence in list# Using try-except block + IndexError exceptiontry:    val = test_list[N]    res = Trueexcept IndexError:    res = False    # printing result print("Is Nth index available? : " + str(res))
The original list is : [4, 5, 6, 7, 10]
Is Nth index available? : False

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
Selecting rows in pandas DataFrame based on conditions
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
MySQL - Queries on Date Manipulation - GeeksforGeeks

09 May, 2021
In MySQL date is a data type and by default follows the format ‘YYYY-MM-DD’ but by using date formatting functions we can format date and can get the required format of date in the tables and can even manipulate the date by using different date functions.
In this article let us execute some queries on date formatting in detail step-by-step:
Creating a database student by using the following SQL query as follows.
CREATE DATABASE orders;
Using the database student using the following SQL query as follows.
USE orders;
Table –Creating a table order_details with 3 columns using the following SQL query as follows.
CREATE TABLE order_details(
order_id varchar(8),
customer_name varchar(20),
order_date DATE);
To view the description of the tables in the database using the following SQL query as follows.
 DESCRIBE order_details;
Inserting rows into order_details table using the following SQL query as follows.
 INSERT INTO order_details VALUES
     ('O0001','PRADEEP','2021-04-11'),
     ('O0002','KOUSHIK','2021-04-09'),
     ('O0003','SRINIVAS','2021-04-05'),
     ('O0004','SATWIK','2021-04-08'),
     ('O0005','LOKESH','2021-04-03');
Viewing the table order_details after inserting rows by using the following SQL query as follows.
 SELECT* FROM order_details;
1.Query to format order_date as ‘DD-MM-YY’.
The default date can be formatted from the default date by using the DATE_FORMAT( ) function:
SYNTAX:
DATE_FORMAT(date,new_format);
In this query, we are using %d to get day then %b to get abbreviated month and %y to get the year.
 SELECT *,DATE_FORMAT(order_date,'%d-%b-%y') AS formatted_date
 FROM order_details;
2. Query to get the estimated delivery date after 15 days from the order date.
The days required can be added by using the DATE_ADD( ) function:
SYNTAX:
DATE_ADD(date, INTERVAL no_of_days DAY);
 SELECT *,DATE_ADD(order_date,INTERVAL 15 DAY)
 AS estimated_delivery
 FROM order_details;
3.Query to get the estimated delivery day.
This can be done by using both DATE_FORMAT( ) and DATE_ADD( ) functions.
 SELECT *,DATE_FORMAT(DATE_ADD(order_date,INTERVAL 15 DAY),'%W')
 AS delivery_day
 FROM order_details;
Here %W to format the date as a weekday.
4. Query to get the order_id and customer name of the persons who are getting their order delivered before  2021-04-23.
Here DATE_ADD( ) function is used to get the estimated delivery and check if it is less than 2021-04-23.
 SELECT order_id,customer_name
   FROM order_details
   WHERE DATE_ADD(order_date,INTERVAL 15 DAY)<'2021-04-23';
mysql
SQL-Query
DBMS
SQL
DBMS
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Types of Functional dependencies in DBMS
Introduction of Relational Algebra in DBMS
What is Temporary Table in SQL?
Two Phase Locking Protocol
KDD Process in Data Mining
SQL | DDL, DQL, DML, DCL and TCL Commands
How to find Nth highest salary from a table
SQL | ALTER (RENAME)
How to Update Multiple Columns in Single Update Statement in SQL?
MySQL | Group_CONCAT() Function
How to add group labels for bar charts in Matplotlib?

To make grouped labels for bar charts, we can take the following steps −
Create lists for labels, men_means and women_means with different data elements.
Create lists for labels, men_means and women_means with different data elements.
Return evenly spaced values within a given interval, using numpy.arrange() method.
Return evenly spaced values within a given interval, using numpy.arrange() method.
Set the width variable, i.e., width=0.35.
Set the width variable, i.e., width=0.35.
Create fig and ax variables using subplots method, where default nrows and ncols are 1.
Create fig and ax variables using subplots method, where default nrows and ncols are 1.
The bars are positioned at *x* with the given *align*\ment. Their dimensions are given by *height* and *width*. The vertical baseline is *bottom* (default 0), so create rect1 and rect2 using plt.bar() method.
The bars are positioned at *x* with the given *align*\ment. Their dimensions are given by *height* and *width*. The vertical baseline is *bottom* (default 0), so create rect1 and rect2 using plt.bar() method.
Set the Y-Axis label using plt.ylabel() method.
Set the Y-Axis label using plt.ylabel() method.
Set a title for the axes using set_title() method.
Set a title for the axes using set_title() method.
Get or set the current tick locations and labels of the X-axis, using set_xticks() method.
Get or set the current tick locations and labels of the X-axis, using set_xticks() method.
Set X-axis tick labels of the grid, using set_xticklabels() method.
Set X-axis tick labels of the grid, using set_xticklabels() method.
Place a legend on the figure, using legend() method.
Place a legend on the figure, using legend() method.
Annotate created bars (rect1 and rect2) with some label using autolabel() method, that is userdefined method.
Annotate created bars (rect1 and rect2) with some label using autolabel() method, that is userdefined method.
To show the figure, use the plt.show() method.
To show the figure, use the plt.show() method.
import matplotlib.pyplot as plt
import numpy as np

plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
labels = ['G1', 'G2', 'G3', 'G4', 'G5']
men_means = [20, 34, 30, 35, 27]
women_means = [25, 32, 34, 20, 25]
x = np.arange(len(labels))
width = 0.35
fig, ax = plt.subplots()
rects1 = ax.bar(x - width / 2, men_means, width, label='Men')
rects2 = ax.bar(x + width / 2, women_means, width, label='Women')
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(x)
ax.set_xticklabels(labels)
ax.legend()

def autolabel(rects):
   for rect in rects:
      height = rect.get_height()
      ax.annotate('{}'.format(height),
         xy=(rect.get_x() + rect.get_width() / 2, height),
         xytext=(0, 3), # 3 points vertical offset
         textcoords="offset points",
         ha='center', va='bottom')

autolabel(rects1)
autolabel(rects2)
plt.show()
C# Program to perform Currency Conversion

Let’s say you need to get the value of 10 dollars in INR.
Firstly, set the variables:
double usd, inr, val;
Now set the dollars and convert it to INR.
// how many dpllars
usd = 10;
// current value of US$
val = 69;
inr = usd * val;
Let us see the complete code −
 Live Demo
using System;
namespace Demo {
   public class Program {
      public static void Main(string[] args) {
         Double usd, inr, val;
         // how many dpllars
         usd = 10;
         // current value of US$
         val = 69;
         inr = usd * val;
         Console.WriteLine("{0} Dollar = {1} INR", usd, inr);
      }
   }
}
10 Dollar = 690 INR
Python program to check if a string is palindrome or not

Given a string, our task is to check weather this string is palindrome or not.
Step1: Enter string as an input.
Step2: Using string slicing we reverse the string and compare it back to the original string.
Step3: Then display the result.
my_string=input("Enter string:")
if(my_string==my_string[::-1]):
   print("The string is a palindrome")
else:
   print("The string isn't a palindrome")
Enter string:madam
The string is a palindrome
Enter string:python
The string isn't a palindrome
Java Program to fill elements in an int array

Elements can be filled in an int array using the java.util.Arrays.fill() method. This method assigns the required int value to the int array in Java. The two parameters required are the array name and the value that is to be stored in the array elements.
A program that demonstrates this is given as follows −
 Live Demo
import java.util.Arrays;
public class Demo {
   public static void main(String[] argv) throws Exception {
      int[] intArray = new int[5];
      int intValue = 9;
      Arrays.fill(intArray, intValue);
      System.out.println("The int array content is: " + Arrays.toString(intArray));
   }
}
The int array content is: [9, 9, 9, 9, 9]
Now let us understand the above program.
First the int array intArray[] is defined. Then the value 9 is filled in the int array using the Arrays.fill() method. Finally, the int array is printed using the Arrays.toString() method. A code snippet which demonstrates this is as follows −
int[] intArray = new int[5];
int intValue = 9;
Arrays.fill(intArray, intValue);
System.out.println("The int array content is: " + Arrays.toString(intArray));
MySQL Tryit Editor v1.0

SELECT CustomerName, LENGTH(CustomerName) AS LengthOfName
FROM Customers;
​
        
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.
How to share x axes of two subplots after they have been created in Matplotlib?

First, we can create two axes using the subplot method where nrows=2, ncols=1. That means, we can have two indices to plot the desired plot. We can use ax1.get_shared_x_axes().join(ax1,ax2) method for our plot.
Create two lists of the numbers.
Create two lists of the numbers.
Add a subplot to the current figure, ax1, where nrows = 2, ncols = 1, and index is 1 for ax1.
Add a subplot to the current figure, ax1, where nrows = 2, ncols = 1, and index is 1 for ax1.
Add a subplot to the current figure, ax2, where nrows = 2, ncols = 1, and index is 2 for ax2.
Add a subplot to the current figure, ax2, where nrows = 2, ncols = 1, and index is 2 for ax2.
Plot x and y using points that are created in step 1.
Plot x and y using points that are created in step 1.
Using get_shared_x_axes().join(ax1, ax2), return a reference to the shared axes Grouper object for axes.
Using get_shared_x_axes().join(ax1, ax2), return a reference to the shared axes Grouper object for axes.
Set X-axis tick labels of the grid, with empty list, using set_xticklabels method.
Set X-axis tick labels of the grid, with empty list, using set_xticklabels method.
Use plt.show() to show the figure.
Use plt.show() to show the figure.
import matplotlib.pyplot as plt

x = [2, 4, 6, 8, 9]
y = [12, 40, 16, 81, 19]

ax1 = plt.subplot(211)
ax2 = plt.subplot(212)

ax1.plot(y, x)
ax2.plot(x, y)

ax1.get_shared_x_axes().join(ax1, ax2)
ax1.set_xticklabels([])

plt.show()
Tryit Editor v3.7

Tryit: HTML table - set row height
How to work the timezone using PowerShell?

To get the timezone of the System, you can use the Get-TimeZone command.
PS C:\> Get-TimeZone

Id                         : Mountain Standard Time
DisplayName                : (UTC-07:00) Mountain Time (US & Canada)
StandardName               : Mountain Standard Time
DaylightName               : Mountain Daylight Time
BaseUtcOffset              : -07:00:00
SupportsDaylightSavingTime : True
To Set the TimeZone of the System, you can you the ID or the Name of the timezone.
PS C:\> Set-TimeZone -Id "Pacific Standard Time" -PassThru
Id                         : Pacific Standard Time
DisplayName                : (UTC-08:00) Pacific Time (US & Canada)
StandardName               : Pacific Standard Time
DaylightName               : Pacific Daylight Time
BaseUtcOffset              : -08:00:00
SupportsDaylightSavingTime : True
To retrieve the list of all the available timezones we need to use System.TimeZoneInfo .net class and method GetSystemTimeZones().
[System.TimeZoneInfo]::GetSystemTimeZones() |ft -AutoSize
pod2html - Unix, Linux Command

pod2html --help --htmlroot=<name> --infile=<name> --outfile=<name>
             --podpath=<name>:...:<name> --podroot=<name>
             --libpods=<name>:...:<name> --recurse --norecurse --verbose
             --index --noindex --title=<name>


  --help



Displays the usage message.


  --htmlroot=name



Sets the base URL for the HTML files.  When cross-references are made,
the HTML root is prepended to the URL.


  --infile=name



Specify the pod file to convert.  Input is taken from STDIN if no
infile is specified.


  --outfile=name



Specify the HTML file to create.  Output goes to STDOUT if no outfile
is specified.


  --podroot=name



Specify the base directory for finding library pods.


  --podpath=name:...:name



Specify which subdirectories of the podroot contain pod files whose
HTML converted forms can be linked-to in cross-references.


  --libpods=name:...:name



List of page names (eg, perlfunc) which contain linkable =items.


  --netscape



Use Netscape HTML directives when applicable.


  --nonetscape



Do not use Netscape HTML directives (default).


  --index



Generate an index at the top of the HTML file (default behaviour).


  --noindex



Do not generate an index at the top of the HTML file.


  --recurse



Recurse into subdirectories specified in podpath (default behaviour).


  --norecurse



Do not recurse into subdirectories specified in podpath.


  --title=title



Specify the title of the resulting HTML file.


  --verbose



Display progress messages.


Advertisements


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
How to draw a polygon in OpenCV using Java?

A polygon with all the interior angles less than 180 is known as a convex polygon. The org.opencv.imgproc package of Java OpenCV library contains a class named Imgproc. To draw a polygon you need to invoke the fillConvexPoly() method of this class. This method accepts 3 parameters −
A Mat object representing the image on which the polygon is to be drawn.
A Mat object representing the image on which the polygon is to be drawn.
A MatOfPoint object points between which the polygon is to be drawn.
A MatOfPoint object points between which the polygon is to be drawn.
A Scalar object representing the color of the polygon.
A Scalar object representing the color of the polygon.
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.MatOfPoint;
import org.opencv.core.Point;
import org.opencv.core.Scalar;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
public class DrawingConvexPolygon {
   public static void main(String args[]) {
      //Loading the OpenCV core library
      System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
      //Reading the source image in to a Mat object
      Mat src = Imgcodecs.imread("D:\\images\\blank.jpg");
      //Drawing an arrowed line
      MatOfPoint points = new MatOfPoint (
         new Point(108, 71), new Point(232, 52),
         new Point(321, 161), new Point(269, 250),
         new Point(126, 232), new Point(108, 71)
      );
      Scalar color = new Scalar(64, 64, 64);
      Imgproc.fillConvexPoly (src, points, color);
      //Saving and displaying the image
      Imgcodecs.imwrite("arrowed_line.jpg", src);
      HighGui.imshow("Drawing an polygon", src);
      HighGui.waitKey();
   }
}
On executing, the above program generates the following window −
Angular Highcharts - Donut Chart

Following is an example of a Donut Chart.
We have already seen the configurations used to draw a chart in Highcharts Configuration Syntax chapter. 
An example of a Donut Chart is given below.
Let us now see the additional configurations/steps taken.

Configure the chart type to be 'pie' based. chart.type decides the series type for the chart. Here, the default value is "line".
var series = {
   type: 'pie'
};
app.component.ts
import { Component } from '@angular/core';
import * as Highcharts from 'highcharts';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
   highcharts = Highcharts;
   chartOptions = {   
      chart : {
         plotBorderWidth: null,
         plotShadow: false
      },
      title : {
         text: 'Browser market shares at a specific website, 2014'   
      },
      tooltip : {
         pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
      },
      plotOptions : {
         pie: {
            shadow: false,
            center: ['50%', '50%'],
            size:'45%',
            innerSize: '20%'            
         }
      },
      series : [{
         type: 'pie',
         name: 'Browser share',
         data: [
            ['Firefox',   45.0],
            ['IE',       26.8],
            {
               name: 'Chrome',
               y: 12.8,
               sliced: true,
               selected: true
            },
            ['Safari',    8.5],
            ['Opera',     6.2],
            ['Others',      0.7]
         ]
      }]
   };
}
Verify the result.

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
numpy.char.center()

This function returns an array of the required width so that the input string is centered and padded on the left and right with fillchar.
import numpy as np 
# np.char.center(arr, width,fillchar) 
print np.char.center('hello', 20,fillchar = '*')
Here is its output −
*******hello********


    63 Lectures 
     6 hours 

 Abhilash Nelson

    19 Lectures 
     8 hours 

 DATAhill Solutions Srinivas Reddy

    12 Lectures 
     3 hours 

 DATAhill Solutions Srinivas Reddy

    10 Lectures 
     2.5 hours 

 Akbar Khan

    20 Lectures 
     2 hours 

 Pruthviraja L

    63 Lectures 
     6 hours 

 Anmol
 Print
 Add Notes
 Bookmark this page
Java Examples - Execute multiple SQL statements

How to execute multiple SQL commands on a database simultaneously?
Following example uses addBatch & executeBatch commands to execute multiple SQL commands simultaneously.
import java.sql.*;

public class jdbcConn {
   public static void main(String[] args) throws Exception {
      Class.forName("org.apache.derby.jdbc.ClientDriver");
      Connection con = DriverManager.getConnection(
         "jdbc:derby://localhost:1527/testDb","name","pass");
      
      Statement stmt = con.createStatement(
         ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
      
      String insertEmp1 = "insert into emp values(10,'jay','trainee')";
      String insertEmp2 = "insert into emp values(11,'jayes','trainee')";
      String insertEmp3 = "insert into emp values(12,'shail','trainee')";
      con.setAutoCommit(false);
      
      stmt.addBatch(insertEmp1);
      stmt.addBatch(insertEmp2);
      stmt.addBatch(insertEmp3);
      
      ResultSet rs = stmt.executeQuery("select * from emp");
      rs.last();
      System.out.println("rows before batch execution= "+ rs.getRow());
      stmt.executeBatch();
      con.commit();
      
      System.out.println("Batch executed");
      rs = stmt.executeQuery("select * from emp");
      rs.last();
      System.out.println("rows after batch execution = "+ rs.getRow());
   }
} 
The above code sample will produce the following result. The result may vary.
rows before batch execution = 6
Batch executed
rows after batch execution = = 9 

 Print
 Add Notes
 Bookmark this page
Python String | strip() - GeeksforGeeks

21 Jan, 2021
The strip() method in-built function of Python is used to remove all the leading and trailing spaces from a string.
Syntax :string.strip([chars])
Parameter:
chars(optional): Character or a set of characters, that needs to be removed from the string.
Returns: A copy of the string with both leading and trailing characters stripped.
In case the character of the string to the left doesn’t match with the characters in the char parameter, the method stops removing the leading characters.
In case the character of the string to the right doesn’t match with the characters in the char parameter, the method stops removing the trailing characters.
Example #1: 
Python3
# Python code to illustrate the working of strip()string = '   Geeks for Geeks   ' # Leading spaces are removedprint(string.strip()) # Geeks is removedprint(string.strip('   Geeks')) # Not removed since the spaces do not matchprint(string.strip('Geeks'))
Output : 
Geeks for Geeks
for
   Geeks for Geeks   
Example #2: 
Python3
# Python code to illustrate the working of strip()string = '@@@@Geeks for Geeks@@@@@' # Strip all '@' from beginning and endingprint(string.strip('@')) string = 'www.Geeksforgeeks.org' # '.grow' removes 'www' and 'org' and '.'print(string.strip('.grow'))
Output: 
Geeks for Geeks
Geeksforgeeks
Example #3:The following code shows an application of strip() in python. 
Python3
# Python code to check for identifiersdef Count(string):     print("Length before strip()")    print(len(string))     # Using strip() to remove white spaces    str = string.strip()    print("Length after removing spaces")    return str  # Driver Codestring = "  Geeks for Geeks   "print(len(Count(string)))
Output:
Length before strip()
17
Length after removing spaces
15
nandishwar001
Akanksha_Rai
RajuKumar19
Python-Built-in-functions
python-string
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Create a Pandas DataFrame from Lists
Box Plot in Python using Matplotlib
Python | Get dictionary keys as a list
Enumerate() in Python
Python Dictionary
Bar Plot in Matplotlib
Multithreading in Python | Set 2 (Synchronization)
Python Dictionary keys() method
loops in python
Python - Call function from another file
Highest and lowest in an array JavaScript

We are required to write a function that takes in an array of numbers and returns the difference between its highest and lowest number.
At first, create an array −
const arr = [23,54,65,76,87,87,431,-6,22,4,-454];
Now, find maximum and minimum values with Math.max() and Math.min() methods, respectively −
const arrayDifference = (arr) => {
   let min, max;
   arr.forEach((num, index) => {
      if(index === 0){
         min = num;
         max = num;
      }else{
         min = Math.min(num, min);
         max = Math.max(num, max);
   };
});
The complete code is as follows −
const arr = [23,54,65,76,87,87,431,-6,22,4,-454];
const arrayDifference = (arr) => {
   let min, max;
   arr.forEach((num, index) => {
      if(index === 0){
         min = num;
         max = num;
      }else{
         min = Math.min(num, min);
         max = Math.max(num, max);
      };
   });
   return max - min;
};
console.log(arrayDifference(arr));
The output in the console will be −
885
How can I display text over columns in a bar chart in Matplotlib?

To display text over columns in a bar chart, we can use text() method so that we could place text at a specific location (x and y) of the bars column.
Create lists for x, y and percentage.
Create lists for x, y and percentage.
Make a bar plot using bar() method.
Make a bar plot using bar() method.
Iterate zipped x, y and percentage to place text for the bars column.
Iterate zipped x, y and percentage to place text for the bars column.
To display the figure, use show() method.
To display the figure, use show() method.
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
x = ['A', 'B', 'C', 'D', 'E']
y = [1, 3, 2, 0, 4]
percentage = [10, 30, 20, 0, 40]
ax = plt.bar(x, y)
for x, y, p in zip(x, y, percentage):
   plt.text(x, y, p)
plt.show()
Pandas GroupBy – Count the occurrences of each combination

To groupby columns and count the occurrences of each combination in Pandas, we use the DataFrame.groupby() with size(). The groupby() method separates the DataFrame into groups.
At first, let us import the pandas library with an alias pd −
import pandas as pd
Initialize the data of lists −
# initializing the data
mylist = {'Car': ['BMW', 'Mercedes', 'Lamborgini', 'Audi', 'Mercedes', 'Porche', 'RollsRoyce', 'BMW'], 'Place': ['Delhi', 'Hyderabad', 'Chandigarh', 'Bangalore', 'Hyderabad', 'Mumbai', 'Mumbai','Delhi'],
'Sold': [95, 80, 80, 75, 90, 90, 95, 50 ]}
Next, we will create a DataFrame −
# DataFrame
dataFrame = pd.DataFrame(mylist, columns=['Car', 'Place', 'Sold'])
Now, use the groupby() to count the occurrence with the size() −
print("Counting the occurrences...")
res = dataFrame.groupby(['Car', 'Place']).size()
Following is the code to count the occurrences of each combination −
# importing library
import pandas as pd

# initializing the data
mylist = {'Car': ['BMW', 'Mercedes', 'Lamborgini', 'Audi', 'Mercedes', 'Porsche', 'RollsRoyce', 'BMW'],
'Place': ['Delhi', 'Hyderabad', 'Chandigarh', 'Bangalore', 'Hyderabad', 'Mumbai', 'Mumbai','Delhi'],
'Sold': [95, 80, 80, 75, 90, 90, 95, 50 ]}

# DataFrame
dataFrame = pd.DataFrame(mylist, columns=['Car', 'Place', 'Sold'])

print(dataFrame)

print("Counting the occurrences...")
res = dataFrame.groupby(['Car', 'Place']).size()

# Displaying the occurrences
print(res)
This will produce the following output −
          Car           Place       Sold
0         BMW           Delhi         95
1    Mercedes       Hyderabad         80
2  Lamborgini      Chandigarh         80
3        Audi       Bangalore         75
4    Mercedes       Hyderabad         90
5     Porsche          Mumbai         90
6  RollsRoyce          Mumbai         95
7         BMW           Delhi         50
Counting the occurrences...
Car         Place
Audi        Bangalore     1
BMW         Delhi         2
Lamborgini  Chandigarh    1
Mercedes    Hyderabad     2
Porsche     Mumbai        1
RollsRoyce  Mumbai        1
dtype: int64
Shadowing of static functions in Java - GeeksforGeeks

19 Feb, 2021
In Java, if the name of a derived class static function is the same as a base class static function then the base class static function shadows (or conceals) the derived class static function. For example, the following Java code prints “A.fun()” Note: Static method is a class property, so if a static method is called from a class name or object having a class container then the method of that class is called not the object’s method.  
Java
// file name: Main.java // Parent classclass A {    static void fun() { System.out.println("A.fun()"); }} // B is inheriting A// Child classclass B extends A {    static void fun() { System.out.println("B.fun()"); }} // Driver Methodpublic class Main {    public static void main(String args[])    {        A a = new B();        a.fun(); // prints A.fun();         // B a = new B();        // a.fun(); // prints B.fun()         // the variable type decides the method        // being invoked, not the assigned object type    }}
A.fun()

Note: If we make both A.fun() and B.fun() as non-static then the above program would print “B.fun()”. While both methods are static types, the variable type decides the method being invoked, not the assigned object typePlease write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
NikhilJaiswal
Shreevardhan
indranilsharma
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Object Oriented Programming (OOPs) Concept in Java
HashMap in Java with Examples
How to iterate any Map in Java
Initialize an ArrayList in Java
ArrayList in Java
Multidimensional Arrays in Java
Stack Class in Java
Singleton Class in Java
LinkedList in Java
Collections in Java
Python SQLite - Cursor Object

The sqlite3.Cursor class is an instance using which you can invoke methods that execute SQLite statements, fetch data from the result sets of the queries. You can create Cursor object using the cursor() method of the Connection object/class.
import sqlite3

#Connecting to sqlite
conn = sqlite3.connect('example.db')

#Creating a cursor object using the cursor() method
cursor = conn.cursor()
Following are the various methods provided by the Cursor class/object.
execute()
This routine executes an SQL statement. The SQL statement may be parameterized (i.e., placeholders instead of SQL literals). The psycopg2 module supports placeholder using %s sign
For example:cursor.execute("insert into people values (%s, %s)", (who, age))
executemany()
This routine executes an SQL command against all parameter sequences or mappings found in the sequence sql.
fetchone()
This method fetches the next row of a query result set, returning a single sequence, or None when no more data is available.
fetchmany()
This routine fetches the next set of rows of a query result, returning a list. An empty list is returned when no more rows are available. The method tries to fetch as many rows as indicated by the size parameter.
fetchall()
This routine fetches all (remaining) rows of a query result, returning a list. An empty list is returned when no rows are available.
Following are the properties of the Cursor class −
arraySize
This is a read/write property you can set the number of rows returned by the fetchmany() method.
description
This is a read only property which returns the list containing the description of columns in a result-set.
lastrowid
This is a read only property, if there are any auto-incremented columns in the table, this returns the value generated for that column in the last INSERT or, UPDATE operation.
rowcount
This returns the number of rows returned/updated in case of SELECT and UPDATE operations.
connection
This read-only attribute provides the SQLite database Connection used by the Cursor object.

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page