code-rag-bench/online-tutorials huggingface dataset:
Python - Create list of tuples using for loop - GeeksforGeeks

14 Sep, 2021
In this article, we will discuss how to create a List of Tuples using for loop in Python.
Let’s suppose we have a list and we want a create a list of tuples from that list where every element of the tuple will contain the list element and its corresponding index.
Here we will use the for loop along with the append() method. We will iterate through elements of the list and will add a tuple to the resulting list using the append() method.
Example:
Python3
L = [5, 4, 2, 5, 6, 1]res = []  for i in range(len(L)):    res.append((L[i], i))      print("List of Tuples")print(res)
List of Tuples
[(5, 0), (4, 1), (2, 2), (5, 3), (6, 4), (1, 5)]
Enumerate() method adds a counter to an iterable and returns it in a form of enumerating object. So we can use this function to create the desired list of tuples.
Example:
Python3
L = [5, 4, 2, 5, 6, 1]res = []  for index, element in enumerate(L):    res.append((element, index))      print("List of Tuples")print(res)
List of Tuples
[(5, 0), (4, 1), (2, 2), (5, 3), (6, 4), (1, 5)]
Blogathon-2021
Picked
Python List-of-Tuples
Blogathon
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Import JSON Data into SQL Server?
How to Install Tkinter in Windows?
Difference between write() and writelines() function in Python
SQL Query to Create Table With a Primary Key
SQL Query to Convert Datetime to Date
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
StringStream in C++ for Decimal to Hexadecimal and back - GeeksforGeeks

09 May, 2018
Stringstream is stream class present in C++ which is used for doing operations on a string. It can be used for formatting/parsing/converting a string to number/char etc.Hex is an I/O manipulator that takes reference to an I/O stream as parameter and returns reference to the stream after manipulation.Here is a quick way to convert any decimal to hexadecimal using stringstream:
// CPP program to convert integer to// hexadecimal using stringstream and// hex I/O manipulator.#include <bits/stdc++.h>using namespace std;  int main(){    int i = 942;    stringstream ss;    ss << hex << i;    string res = ss.str();    cout << "0x" << res << endl; // this will print 0x3ae    return 0;}
Output:
0x3ae

If we want to change hexadecimal string back to decimal you can do it by following way:
// CPP program to convert hexadecimal to// integer using stringstream and// hex I/O manipulator.#include <bits/stdc++.h>using namespace std;  int main(){    string hexStr = "0x3ae";    unsigned int x;    stringstream ss;    ss << std::hex << hexStr;    ss >> x;    cout << x << endl; // this will print 942    return 0;}
Output:
942

base-conversion
cpp-input-output
cpp-string
cpp-stringstream
C++
C++ Programs
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Map in C++ Standard Template Library (STL)
Inheritance in C++
Constructors in C++
C++ Classes and Objects
Socket Programming in C/C++
Header files in C/C++ and its uses
C++ Program for QuickSort
How to return multiple values from a function in C or C++?
Program to print ASCII Value of a character
C++ program for hashing with chaining
SQL - LEFT JOINS

The SQL LEFT JOIN returns all rows from the left table, even if there are no matches in the right table. This means that if the ON clause matches 0 (zero) records in the right table; the join will still return a row in the result, but with NULL in each column from the right table.
This means that a left join returns all the values from the left table, plus matched values from the right table or NULL in case of no matching join predicate.
The basic syntax of a LEFT JOIN is as follows.
SELECT table1.column1, table2.column2...
FROM table1
LEFT JOIN table2
ON table1.common_field = table2.common_field;

Here, the given condition could be any given expression based on your requirement.
Consider the following two tables,
Table 1 − CUSTOMERS Table is as follows.
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
Table 2 − Orders Table is as follows.
+-----+---------------------+-------------+--------+
| OID | DATE                | CUSTOMER_ID | AMOUNT |
+-----+---------------------+-------------+--------+
| 102 | 2009-10-08 00:00:00 |           3 |   3000 |
| 100 | 2009-10-08 00:00:00 |           3 |   1500 |
| 101 | 2009-11-20 00:00:00 |           2 |   1560 |
| 103 | 2008-05-20 00:00:00 |           4 |   2060 |
+-----+---------------------+-------------+--------+
Now, let us join these two tables using the LEFT JOIN as follows.
SQL> SELECT  ID, NAME, AMOUNT, DATE
   FROM CUSTOMERS
   LEFT JOIN ORDERS
   ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
This would produce the following result −
+----+----------+--------+---------------------+
| ID | NAME     | AMOUNT | DATE                |
+----+----------+--------+---------------------+
|  1 | Ramesh   |   NULL | NULL                |
|  2 | Khilan   |   1560 | 2009-11-20 00:00:00 |
|  3 | kaushik  |   3000 | 2009-10-08 00:00:00 |
|  3 | kaushik  |   1500 | 2009-10-08 00:00:00 |
|  4 | Chaitali |   2060 | 2008-05-20 00:00:00 |
|  5 | Hardik   |   NULL | NULL                |
|  6 | Komal    |   NULL | NULL                |
|  7 | Muffy    |   NULL | NULL                |
+----+----------+--------+---------------------+


    42 Lectures 
     5 hours 

 Anadi Sharma

    14 Lectures 
     2 hours 

 Anadi Sharma

    44 Lectures 
     4.5 hours 

 Anadi Sharma

    94 Lectures 
     7 hours 

 Abhishek And Pukhraj

    80 Lectures 
     6.5 hours 

 Oracle Master Training | 150,000+ Students Worldwide

    31 Lectures 
     6 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
GATE | GATE-CS-2014-(Set-3) | Question 65 - GeeksforGeeks

28 Jun, 2021
A system uses 3 page frames for storing process pages in main memory. It uses the Least Recently Used (LRU) page replacement policy. Assume that all the page frames are initially empty. What is the total number of page faults that will occur while processing the page reference string given below?4, 7, 6, 1, 7, 6, 1, 2, 7, 2(A) 4(B) 5(C) 6(D) 7Answer: (C)Explanation: What is a Page fault ? An interrupt that occurs when a program requests data that is not currently in real memory. The interrupt triggers the operating system to fetch the data from a virtual memory and load it into RAM.
Now, 4, 7, 6, 1, 7, 6, 1, 2, 7, 2 is the reference string, you can think of it as data requests made by a program.
Now the system uses 3 page frames for storing process pages in main memory. It uses the Least Recently Used (LRU) page replacement policy.
[ ] - Initially page frames are empty.i.e. no 
      process pages in main memory.

[ 4 ] - Now 4 is brought into 1st frame (1st 
        page fault) 
Explanation: Process page 4 was requested by the program, but it was not in the main memory(in form of page frames),which resulted in a page fault, after that process page 4 was brought in the main memory by the operating system.

[ 4 7 ] - Now 7 is brought into 2nd frame 
         (2nd page fault) - Same explanation.

[ 4 7 6 ] - Now 6 is brought into 3rd frame
           (3rd page fault)

[ 1 7 6 ] - Now 1 is brought into 1st frame, as 1st 
         frame was least recently used(4th page fault). 
After this 7, 6 and 1 are were already present in the frames hence no replacements in pages.

[ 1 2 6 ] - Now 2 is brought into 2nd frame, as 2nd
          frame was least recently used(5th page fault).

[ 1 2 7 ] -Now 7 is brought into 3rd frame, as 3rd frame
          was least recently used(6th page fault).  
Hence, total number of page faults(also called pf) are 6. Therefore, C is the answer.Quiz of this Question
GATE-CS-2014-(Set-3)
GATE-GATE-CS-2014-(Set-3)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE-CS-2016 (Set 2) | Question 48
GATE | GATE-CS-2014-(Set-1) | Question 30
GATE | GATE-CS-2001 | Question 23
GATE | GATE CS 2010 | Question 45
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE-CS-2004 | Question 3
GATE | GATE-CS-2014-(Set-1) | Question 65
C++ Program to count Vowels in a string using Pointer
GATE | GATE-CS-2015 (Set 1) | Question 42
GATE | GATE-CS-2001 | Question 48
Batch Script - Logical Operators

Logical operators are used to evaluate Boolean expressions. Following are the logical operators available.
The batch language is equipped with a full set of Boolean logic operators like AND, OR, XOR, but only for binary numbers. Neither are there any values for TRUE or FALSE. The only logical operator available for conditions is the NOT operator.
The easiest way to implement the AND/OR operator for non-binary numbers is to use the nested IF condition. The following example shows how this can be implemented.
@echo off
SET /A a = 5
SET /A b = 10
IF %a% LSS 10 (IF %b% GTR 0 (ECHO %a% is less than 10 AND %b% is greater than 0))
The above command produces the following output.
5 is less than 10 AND 10 is greater than 0

Following is an example of the AND operation that can be implemented using the IF statement.
@echo off
SET /A a = 5
SET /A b = 10

IF %a% GEQ 10 (
   IF %b% LEQ 0 (
      ECHO %a% is NOT less than 10 OR %b% is NOT greater than 0
   ) ELSE (
      ECHO %a% is less than 10 OR %b% is greater than 0
   )
) ELSE (
   ECHO %a% is less than 10 OR %b% is greater than 0
)
The above command produces the following output.
5 is less than 10 AND 10 is greater than 0

Following is an example of how the NOT operator can be used.
@echo off
SET /A a = 5
IF NOT %a%==6 echo "A is not equal to 6"
The above command produces the following output.
"A is equal to 5"

 Print
 Add Notes
 Bookmark this page
Create Database in MariaDB using PyMySQL in Python - GeeksforGeeks

14 Oct, 2020
MariaDB is an open source Database Management System and its predecessor to MySQL. The pymysql client can be used to interact with MariaDB similar to that of MySQL using Python.
In this article we will look into the process of creating a database using pymysql. To create a database use the below syntax:
Syntax:CREATE DATABASE databaseName;

Example :
In this example we will be using the pymysql client to create a database named “GFG”:
Python
# import the mysql client for python  import pymysql    # Create a connection object# IP address of the MySQL database serverHost = "localhost"   # User name of the database serverUser = "user"         # Password for the database userPassword = ""             conn  = pymysql.connect(host=Host, user=User, password=Password)  # Create a cursor objectcur  = conn.cursor()  # creating database cur.execute("CREATE DATABASE GFG")   cur.execute("SHOW DATABASES")databaseList = cur.fetchall()  for database in databaseList:  print(database)    conn.close()
Output :
The above program illustrates the creation of MariaDB database “GFG”  in which host-name is ‘localhost‘, the username is ‘user’ and password is ‘your password’.
Let’s suppose we want to create a table in the database, then we need to connect to a database. Below is a program to create a table in the GFG database which was created in the above program.
Example :
Python3
import pymysql  conn = pymysql.connect('localhost','user','password','GFG')cur = conn.cursor()cur.execute("DROP TABLE IF EXISTS PRODUCT") query = """CREATE TABLE PRODUCT (          PRODUCT_ID  CHAR(20) NOT NULL,          price  int(10),          PRODUCT_TYPE VARCHAR(64) ) """  # To execute the SQL querycur.execute(query)     # To commit the changesconn.commit()         conn.close()
Output :
Python-MariaDB
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
Selecting rows in pandas DataFrame based on conditions
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python Classes and Objects
SQL Query to Check if Date is Greater Than Today in SQL - GeeksforGeeks

15 Oct, 2021
In this article, we will see the SQL query to check if DATE is greater than today’s date by comparing date with today’s date using the GETDATE() function. This function in SQL Server is used to return the present date and time of the database system in a ‘YYYY-MM-DD hh:mm: ss. mmm’ pattern.
Features:
This function is used to find the present date and time of the database system.
This function comes under Date Functions.
This function doesn’t accept any parameter.
This function returns output in ‘YYYY-MM-DD hh:mm: ss. mmm‘ format.
To check a current date we use simply GETDATE( ) function.
Query:
SELECT GETDATE();        
Output:
Now, take an example to check if the date is greater than today’s date in MS SQL Server. For this we follow given below steps:
Step 1: Create a database
we can use the following command to create a database called geeks.
Query:
CREATE DATABASE geeks;
Step 2: Use database
Use the below SQL statement to switch the database context to geeks:
Query:
USE geeks;
Step 3: Table definition
We have the following geeks for geeks in our geek’s database.
Query:
CREATE TABLE geeksforgeeks(
NAME VARCHAR(20),
Ordered DATE,
Deliver DATE);
Step 4: Insert data into a table
Query:
INSERT  INTO geeksforgeeks VALUES
 ('ROMY', '2021-01-16', '2021-03-12'),
('AVINAV', '2021-11-12', '2021-12-12'),
 ('PUSHKAR', '2021-06-23', '2021-10-13');
Step 5: For a view a table data
To see the content of the table, run the below command
Query:
SELECT * FROM geeksforgeeks;
Output:
Step 6:  Check date greater than today date or not
For this, we will check from the table, which row has delivered a value greater than today’s date.
Query:
SELECT * FROM geeksforgeeks WHERE Deliver > GETDATE();
Output:
Returned value whose date is 2021-12-12 and 2021-10-13 which is greater than 2021-09-22 (Today’s date)
Check whose ordered date is greater than today’s date.
Query:
SELECT * FROM geeksforgeeks WHERE Ordered > GETDATE();
Output:
kashishsoda
Picked
SQL-Query
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
SQL Trigger | Student Database
Difference between DELETE, DROP and TRUNCATE
SQL | Views
SQL Interview Questions
Difference between DDL and DML in DBMS
CTE in SQL
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | TRANSACTIONS
SQL Correlated Subqueries
What is Cursor in SQL ?
3Sum in Python

Suppose we have an array of numbers. It stores n integers, there are there elements a, b, c in the array, such that a + b + c = 0. Find all unique triplets in the array which satisfies the situation. So if the array is like [-1,0,1,2,-1,-4], then the result will be [[-1, 1, 0], [-1, -1, 2]]
To solve this, we will follow these steps −
Sort the array nums, and define an array res
for i in range 0 to length of nums – 3if i > 0 and nums[i] = nums[i - 1], then skip the next part and continuel := i + 1 and r := length of nums – 1while l < rsum := sum of nums[i], nums[l] and nums[r]if sum < 0, then l := l + 1, otherwise when sum > 0, then r := r – 1otherwise insert nums[i], nums[l], nums[r] into the res arraywhile l < length of nums – 1 and nums[l] = nums[l + 1]increase l by 1while r > 0 and nums[r] = nums[r - 1]decrease r by 1increase l by 1 and decrease r by 1
if i > 0 and nums[i] = nums[i - 1], then skip the next part and continue
l := i + 1 and r := length of nums – 1
while l < rsum := sum of nums[i], nums[l] and nums[r]if sum < 0, then l := l + 1, otherwise when sum > 0, then r := r – 1otherwise insert nums[i], nums[l], nums[r] into the res arraywhile l < length of nums – 1 and nums[l] = nums[l + 1]increase l by 1while r > 0 and nums[r] = nums[r - 1]decrease r by 1increase l by 1 and decrease r by 1
sum := sum of nums[i], nums[l] and nums[r]
if sum < 0, then l := l + 1, otherwise when sum > 0, then r := r – 1
otherwise insert nums[i], nums[l], nums[r] into the res array
while l < length of nums – 1 and nums[l] = nums[l + 1]increase l by 1
increase l by 1
while r > 0 and nums[r] = nums[r - 1]decrease r by 1
decrease r by 1
increase l by 1 and decrease r by 1
return res
Let us see the following implementation to get better understanding −
 Live Demo
class Solution(object):
   def threeSum(self, nums):
      nums.sort()
      result = []
      for i in range(len(nums)-2):
         if i> 0 and nums[i] == nums[i-1]:
            continue
         l = i+1
         r = len(nums)-1
         while(l<r):
            sum = nums[i] + nums[l] + nums[r]
            if sum<0:
               l+=1
            elif sum >0:
               r-=1
            else:
               result.append([nums[i],nums[l],nums[r]])
               while l<len(nums)-1 and nums[l] == nums[l + 1] : l += 1
               while r>0 and nums[r] == nums[r - 1]: r -= 1
               l+=1
               r-=1
      return result
ob1 = Solution()
print(ob1.threeSum([-1,0,1,2,-1,-4]))
[-1,0,1,2,-1,-4]
[[-1,-1,2],[-1,0,1]]
MySQL Tryit Editor v1.0

SELECT CAST("2017-08-29" AS DATE);
​
        
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.
PostgreSQL- LOWER function - GeeksforGeeks

08 Oct, 2021
In PostgreSQL, the LOWER function is used to convert a string, an expression, or values in a column to lower case.
Syntax: LOWER(string or value or expression)
Let’s analyze the above syntax:
The LOWER function takes in value with either all uppercase or partial uppercase values or characters and convert them into lower case of the same type.
If the supplied argument is string-convertible, one can make use of the CAST function which converts a non-string value to a string.
Example 1:
The below statement uses LOWER function to get the full names of the films from the Film table of the sample database, ie, dvdrental:
SELECT LOWER(title) from film;
Output:
Example 2:
The below statement converts an upper case string to lower case:
SELECT LOWER('GEEKSFORGEEKS');
Output:
sooda367
PostgreSQL-function
PostgreSQL-String-function
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
PostgreSQL - GROUP BY clause
PostgreSQL - DROP INDEX
PostgreSQL - LEFT JOIN
PostgreSQL - ROW_NUMBER Function
PostgreSQL - Copy Table
PostgreSQL - Cursor
PostgreSQL - Record type variable
PostgreSQL - SELECT
PostgreSQL - TEXT Data Type
PostgreSQL - Select Into
Symfony - Logging

Logging is very important for a web application. Web applications are used by hundreds to thousands of users at a time. To get sneak preview of happenings around a web application, Logging should be enabled. Without logging, the developer will not be able to find the status of the application. Let us consider that an end customer reports an issue or a project stackholder reports performance issue, then the first tool for the developer is Logging. By checking the log information, one can get some idea about the possible reason of the issue.
Symfony provides an excellent logging feature by integrating Monolog logging framework. Monolog is a de-facto standard for logging in PHP environment. Logging is enabled in every Symfony web application and it is provided as a Service. Simply get the logger object using base controller as follows.
$logger = $this->get('logger'); 

Once the logger object is fetched, we can log information, warning, and error using it.
$logger->info('Hi, It is just a information. Nothing to worry.'); 
$logger->warn('Hi, Something is fishy. Please check it.'); 
$logger->error('Hi, Some error occured. Check it now.'); 
$logger->critical('Hi, Something catastrophic occured. Hurry up!');

Symfony web application configuration file app/config/config.yml has a separate section for the logger framework. It can be used to update the working of the logger framework.
 Print
 Add Notes
 Bookmark this page
C# Type Casting

Type casting is when you assign a value of one data type to another type.
In C#, there are two types of casting:
Implicit Casting (automatically) - converting a smaller type 
to a larger type size
char -> int -> long -> float -> double

Explicit Casting (manually) - converting a larger type 
to a smaller size type
double -> float -> long -> int -> char
Implicit casting is done automatically when passing a smaller size type to a 
larger size type:
int myInt = 9;
double myDouble = myInt;       // Automatic casting: int to double

Console.WriteLine(myInt);      // Outputs 9
Console.WriteLine(myDouble);   // Outputs 9


Try it Yourself »

Explicit casting must be done manually by placing the type in parentheses 
in front of the value:
double myDouble = 9.78;
int myInt = (int) myDouble;    // Manual casting: double to int

Console.WriteLine(myDouble);   // Outputs 9.78
Console.WriteLine(myInt);      // Outputs 9


Try it Yourself »

It is also possible to convert data types explicitly by using built-in methods, such as Convert.ToBoolean, Convert.ToDouble, Convert.ToString, Convert.ToInt32 (int) and Convert.ToInt64 (long):
int myInt = 10;
double myDouble = 5.25;
bool myBool = true;

Console.WriteLine(Convert.ToString(myInt));    // convert int to string
Console.WriteLine(Convert.ToDouble(myInt));    // convert int to double
Console.WriteLine(Convert.ToInt32(myDouble));  // convert double to int
Console.WriteLine(Convert.ToString(myBool));   // convert bool to string

Try it Yourself »

Many times, there's no need for type conversion. But sometimes you have to. Take a look at the next chapter, when working with user input, to see an example of this.
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to create image overlay hover effect with CSS?

Following is the code to produce bottom navigation menu with CSS −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.card-container {
   display: inline-block;
   position: relative;
   width: 50%;
}
img {
   opacity: 1;
   display: block;
   width: 100%;
   transition: .5s ease;
   backface-visibility: hidden;
}
.hoverText {
   transition: .5s ease;
   opacity: 0;
   position: absolute;
   top: 50%;
   left: 40%;
   text-align: center;
}
.card-container:hover img {
   opacity: 0.4;
}
.card-container:hover .hoverText {
   opacity: 1;
}
.caption {
   background-color: rgb(18, 53, 131);
   color: white;
   font-size: 30px;
   padding: 20px;
   border-radius: 6px;
   font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
   font-weight: bolder;
}
</style>
</head>
<body>
<h1>Image Overlay effect Example</h1>
<div class="card-container">
<img src="https://i.picsum.photos/id/237/536/354.jpg">
<div class="hoverText">
<div class="caption">Dog</div>
</div>
</div>
</body>
</html>
The above code will produce the following output −
On hovering above the image the caption will be shown as follows −
How to set auto-increment to an existing column in a table using JDBC API?

You can add/set an auto increment constraint to a column in a table using the ALTER TABLE command.
ALTER TABLE table_name ADD id INT PRIMARY KEY AUTO_INCREMENT
Assume we have a table named Dispatches in the database with 7 columns namely id, CustomerName, DispatchDate, DeliveryTime, Price and, Location with description as shown below:
+--------------+--------------+------+-----+---------+-------+
| Field        | Type         | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+-------+
| ProductName  | varchar(255) | YES  | UNI | NULL    |       |
| CustomerName | varchar(255) | YES  |     | NULL    |       |
| DispatchDate | date         | YES  |     | NULL    |       |
| DeliveryTime | time         | YES  |     | NULL    |       |
| Price        | int(11)      | YES  |     | NULL    |       |
| Location     | text         | YES  |     | NULL    |       |
| ID           | int(11)      | NO   | PRI | NULL    |       |
+--------------+--------------+------+-----+---------+-------+
Following JDBC program establishes connection with MySQL database ,adds a column named Id and sets the values to the id column as auto-increment.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class SettingAutoIncrement {
   public static void main(String args[]) throws SQLException {
      //Registering the Driver
      DriverManager.registerDriver(new com.mysql.jdbc.Driver());
      //Getting the connection
      String mysqlUrl = "jdbc:mysql://localhost/mydatabase";
      Connection con = DriverManager.getConnection(mysqlUrl, "root", "password");
      System.out.println("Connection established......");
      //Creating the Statement
      Statement stmt = con.createStatement();
      //Setting the column id auto-increment
      String query = "ALTER TABLE Sales ADD id INT PRIMARY KEY AUTO_INCREMENT";
      stmt.execute(query);
      stmt.executeBatch();
      System.out.println("Table altered......");
   }
}
Connection established......
Table altered......
If you retrieve the contents of the Sales table using the Select command you can observe that a column named id added to the table with auto-incremented integer values.
mysql> select * from Sales;
+-------------+--------------+--------------+--------------+-------+----------------+----+
| ProductName | CustomerName | DispatchDate | DeliveryTime | Price | Location       | id |
+-------------+--------------+--------------+--------------+-------+----------------+----+
| Key-Board   | Raja         | 2019-09-01   | 08:51:36     | 7000  | Hyderabad      | 1  |
| Earphones   | Roja         | 2019-05-01   | 05:54:28     | 2000  | Vishakhapatnam | 2  |
| Mouse       | Puja         | 2019-03-01   | 04:26:38     | 3000  | Vijayawada     | 3  |
| Mobile      | Vanaja       | 2019-03-01   | 04:26:35     | 9000  | Vijayawada     | 4  |
| Headset     | Jalaja       | 2019-03-01   | 05:19:16     | 6000  | Vijayawada     | 5  |
+-------------+--------------+--------------+--------------+-------+----------------+----+
5 rows in set (0.00 sec)
How to Find HCF or GCD using Python?

Highest Common Factor or Greatest Common Divisor of two or more integers is the largest positive integer that evenly divides the numbers without a remainder. For example, the GCD of 8 and 12 is 4.
x = int(input("Enter first number: "))  
y = int(input("Enter second number: "))  
if x > y:  
    smaller = y  
else:  
    smaller = x  
for i in range(1,smaller + 1):  
if((x % i == 0) and (y % i == 0)):  
    hcf = i  

print("The H.C.F. of", x,"and", x,"is", hcf)
Program to print path from root to a given node in a binary tree using C++

In this tutorial, we will be discussing a program to print the path from root to a given node in a binary tree.
For a given binary tree having distinct nodes, we have to print the complete path to reach a particularly given node from the root node of the binary tree.
To solve this problem, we will use recursion. While traversing the binary tree, we will recursively search for the particular element to be found. Also alongside we will be storing the path to reach the element to be searched.
#include <bits/stdc++.h>
using namespace std;
struct Node{
   int data;
   Node *left, *right;
};
struct Node* create_node(int data){
   struct Node *new_node = new Node;
   new_node->data = data;
   new_node->left = new_node->right = NULL;
   return new_node;
}
//checks if a path from root node to element exists
bool is_path(Node *root, vector<int>& arr, int x){
   if (!root)
      return false;
   arr.push_back(root->data);
   if (root->data == x)
      return true;
   if (is_path(root->left, arr, x) || is_path(root->right, arr, x))
      return true;
   arr.pop_back();
   return false;
}
//printing the path from the root node to the element
void print_path(Node *root, int x){
   vector<int> arr;
   if (is_path(root, arr, x)){
      for (int i=0; i<arr.size()-1; i++)
         cout << arr[i] << " -> ";
         cout << arr[arr.size() - 1];
   }
   else
      cout << "Path doesn't exists" << endl;
}
int main(){
   struct Node *root = create_node(13);
   root->left = create_node(21);
   root->right = create_node(43);
   root->left->left = create_node(34);
   root->left->right = create_node(55);
   root->right->left = create_node(68);
   root->right->right = create_node(79);
   int x = 68;
   print_path(root, x);
   return 0;
}
13 -> 43 -> 68
Creating Interactive Radar Charts with Python | by M Khorasani | Towards Data Science

Perhaps one of the unsung heroes of data visualization is the benevolent and graceful radar plot. We’ve grown accustomed to a whole slew of other visualizations, choropleths, donuts and heatmaps to name a few, but radar charts are largely missing from our dazzling dashboards. Granted, there are only particular use cases for such charts, namely, visualizing wind roses, geographical data and some other types of multivariate data. But when you do use one, it is remarkably effective at visualizing outliers or commonality amongst numerical and ordinal datasets.
For this tutorial, we will be generating a dashboard with an interactive and dynamic radar chart that will render in real-time. To that end, we will be using Plotly and Streamlit as our formidable Python stack. If you haven’t already done so, fire up Anaconda or any other Python IDE of your choice and install the following packages:
pip install plotlypip install streamlit
Then proceed with importing the following packages into your script:
Plotly is one of the most versatile and interactive data visualization tools currently out there. It is armed with bindings for Python and R, and its integration into dashboards is seamless. Plotly is able to generate interactive radar charts with practically no overhead for you as the developer. All you need to do is to input an array of numbers corresponding to the value of each of your variables, and leave the rest to Plotly as shown below:
For our dashboard, we will be using Streamlit. Long story short, Streamlit is a pure Python web framework that renders dashboards as web apps in real-time. Once your dashboard is ready, you can port-forward it to one of your local TCP ports and open it on your browser. Alternatively you can deploy your dashboard to the cloud with the likes of Heroku, AWS or Streamlit’s own one-click deployment service, if you have the stomach for more headache.
For the Streamlit dashboard, we will create a slider that will enable us to input any value we like into our radar_chart function.
Once the script is completed, you can render the dashboard/app by opening Anaconda prompt and typing in the following commands.
Initially, change the directory to the location of your script:
cd C:/Users/.../script_directory
Then run your app by typing:
streamlit run script_name.py
Streamlit will then automatically generate your app and will forward it to your local host, which you can open in any browser of your choice.
And there you have it, an interactive radar chart where you can change the values shown in the visual by modifying the positions of the slider.
You can also play around with all the interactive bells and whistles afforded by Plotly.
If you want to learn more about data visualization and Python, then feel free to check out the following (affiliate linked) courses:
Create a mirror image with CSS

The flip effect is used to create a mirror image of the object. The following parameters can be used in this filter -
You can try to run the following code to create a mirror image
Live Demo
<html>
   <head>
   </head>
   <body>

      <img src="/css/images/logo.png" alt="CSS Logo" style="Filter: FlipH">
      <img src="/css/images/logo.png" alt="CSS Logo" style="Filter: FlipV">

      <p>Text Example:</p>

      <div style="width: 300;
         height: 50;
         font-size: 30pt;
         font-family: Arial Black;
         color: red;
         Filter: FlipV">CSS Tutorials</div>
   </body>

</html>
How to disable browser autofill on input fields using jQuery ? - GeeksforGeeks

21 Dec, 2020
In this article, we will see how to disable the browser auto fill property on the input field. For that, HTML page is created in which jQuery CDN is imported to use jQuery and its code is written.
Approach:
Create a basic HTML page having at least one input field in it with the “id” attribute.
Import jQuery CDN from script tag to use jQuery on the page.
Then write the jQuery code in the script tag for disabling autofill on the input field.
To achieve this, we use two methods of jQuery to set the attribute value to the field:
attr() Method
prop() method
Example 1: Using attr() method
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <meta name="viewport" content=        "width=device-width,initial-scale=1.0">      <!-- Import jQuery cdn library -->    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">    </script>      <script>          // Execute this code when page is        // totally loaded        $(document).ready(function () {              /* Setting the autocomplete of               input field to off to make                autofill to disable */            $("#name").attr("autocomplete", "off");        });    </script></head>  <body>    <label for="name">Name:</label>          <input type="text" name="name" id="name"></body>  </html>
Output:
This will be output of code
Example 2: Using prop() method
<!DOCTYPE html><html lang="en">  <head>    <meta charset="UTF-8">    <meta name="viewport" content=        "width=device-width, initial-scale=1.0">      <title>Disable Autofill</title>      <!-- Import jQuery cdn library -->    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">    </script>      <script>          // Execute this code when page is        // totally loaded        $(document).ready(function () {                      /* Setting the autocomplete of                input field to off to make                autofill to disable */            $("#name").prop("autocomplete", "off");        });    </script></head>  <body>    <label for="name">Name:</label>          <input type="text" name="name" id="name"></body>  </html>
Output:
Output of code. In this field there is no autofill
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
jQuery-Misc
Picked
HTML
JQuery
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?
JQuery | Set the value of an input text field
Form validation using jQuery
How to change selected value of a drop-down list using jQuery?
How to change the background color after clicking the button in JavaScript ?
How to fetch data from JSON file and display in HTML table using jQuery ?
First Normal Form (1NF) - GeeksforGeeks

28 Mar, 2022
If a table has data redundancy and is not properly normalized, then it will be difficult to handle and update the database, without facing data loss. It will also eat up extra memory space and Insertion, Update and Deletion Anomalies are very frequent if database is not normalized. 
Normalization is the process of minimizing redundancy from a relation or set of relations. Redundancy in relation may cause insertion, deletion and update anomalies. So, it helps to minimize the redundancy in relations. Normal forms are used to eliminate or reduce redundancy in database tables. 
There are various level of normalization. These are some of them: 
1. First Normal Form (1NF)
2. Second Normal Form (2NF)
3. Third Normal Form (3NF) 
4. Boyce-Codd Normal Form (BCNF)
5. Fourth Normal Form (4NF)
6. Fifth Normal Form (5NF) 
In this article, we will discuss First Normal Form (1NF). 
First Normal Form (1NF): If a relation contains a composite or multi-valued attribute, it violates the first normal form, or the relation is in first normal form if it does not contain any composite or multi-valued attribute. A relation is in first normal form if every attribute in that relation is singled valued attribute. 
A table is in 1 NF iff: 
There are only Single Valued Attributes.Attribute Domain does not change.There is a unique name for every Attribute/Column.The order in which data is stored does not matter.  
There are only Single Valued Attributes.
Attribute Domain does not change.
There is a unique name for every Attribute/Column.
The order in which data is stored does not matter.  
Consider the examples given below. 
Example-1: Relation STUDENT in table 1 is not in 1NF because of multi-valued attribute STUD_PHONE. Its decomposition into 1NF has been shown in table 2. 
Example-2: 
ID   Name   Courses
------------------
1    A      c1, c2
2    E      c3
3    M      C2, c3 
In the above table, Course is a multi-valued attribute so it is not in 1NF. 
Below Table is in 1NF as there is no multi-valued attribute:  
ID   Name   Course
------------------
1    A       c1
1    A       c2
2    E       c3
3    M       c2
3    M       c3
Note: A database design is considered as bad if it is not even in the First Normal Form (1NF). https://youtu.be/-JOpBzyrZ_8 
meshachmitchell
joenebula123
rajatkhanna
DBMS-Normalization
DBMS
GATE CS
DBMS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
SQL Interview Questions
SQL Trigger | Student Database
CTE in SQL
Introduction of B-Tree
Difference between Clustered and Non-clustered index
Layers of OSI Model
TCP/IP Model
Types of Operating Systems
Page Replacement Algorithms in Operating Systems
Differences between TCP and UDP
How to count elements in a nested Python dictionary?

It is possible to iterate over each key value pair in a dictionary by the expression
for k,v in students.items():
Since value component of each item is itself a dictionary in nested Python dictionary, length of each sub-dictionary is len(v). Perform cumulative addition over the loop to obtain count of all elements
>>> students={"student1":{"name":"Raaj", "age":23, "subjects":["Phy", "Che", "maths"],"GPA":8.5},"student2":{"name":"Kiran", "age":21, "subjects":["Phy", "Che", "bio"],"GPA":8.25}}
>>> s=0
>>> for k,v in students.items():
    s=s+len(v)
>>> s
8
A more compact representation of above will be −
>>> sum(len(v)for v in students.values())
8
Get the substring before the last occurrence of a separator in Java

We have the following string with a separator.
String str = "David-Warner";
We want the substring before the last occurrence of a separator. Use the lastIndexOf() method.
For that, you need to get the index of the separator using indexOf()
String separator ="-";
int sepPos = str.lastIndexOf(separator);
System.out.println("Substring before last separator = "+str.substring(0,sepPos));
The following is an example.
 Live Demo
public class Demo {
   public static void main(String[] args) {
      String str = "David-Warner";
      String separator ="-";
      int sepPos = str.lastIndexOf(separator);
      if (sepPos == -1) {
         System.out.println("");
      }
      System.out.println("Substring before last separator = "+str.substring(0,sepPos));
   }
}
Substring before last separator = David
Concatenate Multiple Strings in Java.

You can concatenate multiple strings using the ‘+’ operator of Java.
public class Test {
   public static void main(String args[]) {
      String st1 = "Hello";
      String st2 = "How";
      String st3 = "You";
      String res = st1+st2+st3;
      System.out.println(res);
   }
}
HelloHowYou
How to import and export a module/library in JavaScript?

Note − To run this example you will need to run a localhost server.
Following is the code for importing and exporting a module/library in JavaScript −
INDEX.html
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 18px;
      font-weight: 500;
   }
</style>
</head>
<body>
<h1>JavaScript Importing and Exporting Modules</h1>
<button class="Btn">IMPORT</button>
<div class="result"></div>
<h3>Click on the above button to import module </h3>
<script src="script.js" type="module"></script>
<script src="sample.js" type="module">
</script>
</body>
</html>
script.js
import test from './sample.js';
document.querySelector('.Btn').addEventListener('click',()=>{
   test();
})
sample.js
let resultEle = document.querySelector(".result");
export default function testImport(){
   resultEle.innerHTML = 'Module testImport has been imported';
}
The above code will produce the following output −
On clicking the ‘IMPORT’ button −
Building a Map from 2 arrays of values and keys in JavaScript

Suppose, we have two arrays −
const keys = [0, 4, 2, 3, 1];
const values = ["first", "second", "third", "fourth", "fifth"];
We are required to write a JavaScript function that takes in the keys and the values array and maps the values to the corresponding keys. The output should be −
const map = {
   0 => 'first',
   4 => 'second',
   2 => 'third',
   3 => 'fourth',
   1 => 'fifth'
};
Following is the code −
const keys = [0, 4, 2, 3, 1];
const values = ["first", "second", "third", "fourth", "fifth"];
const buildMap = (keys, values) => {
   const map = new Map();
   for(let i = 0; i < keys.length; i++){
      map.set(keys[i], values[i]);
   };
   return map;
};
console.log(buildMap(keys, values));
This will produce the following output in console −
Map(5) {
   0 => 'first',
   4 => 'second',
   2 => 'third',
   3 => 'fourth',
   1 => 'fifth'
}
How to load external HTML into a <div> using jQuery?

To load external HTML into a <div>, wrap your code inside the load() function. To load a page in div in jQuery, use the load() method. Firstly, add the web page you want to add.
Here’s the code for new.html −
<html>
<head>    
</head>
<body>
<p>This is demo text.<p>
</body>
</html>
The following is the  code snippet for the file which adds the above page,
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
   
   $('#content').load("new.html");

});
</script>
</head>
<body>

<div id="content"></div>

</body>
</html>
C library function - isprint()

The C library function int isprint(int c) checks whether the passed character is printable. A printable character is a character that is not a control character.
Following is the declaration for isprint() function.
int isprint(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 printable character else, zero (false).
The following example shows the usage of isprint() function.
#include <stdio.h>
#include <ctype.h>

int main () {
   int var1 = 'k';
   int var2 = '8';
   int var3 = '\t';
   int var4 = ' ';
    
   if( isprint(var1) ) {
      printf("var1 = |%c| can be printed\n", var1 );
   } else {
      printf("var1 = |%c| can't be printed\n", var1 );
   }
   
   if( isprint(var2) ) {
      printf("var2 = |%c| can be printed\n", var2 );
   } else {
      printf("var2 = |%c| can't be printed\n", var2 );
   }
   
   if( isprint(var3) ) {
      printf("var3 = |%c| can be printed\n", var3 );
   } else {
      printf("var3 = |%c| can't be printed\n", var3 );
   }
   
   if( isprint(var4) ) {
      printf("var4 = |%c| can be printed\n", var4 );
   } else {
      printf("var4 = |%c| can't be printed\n", var4 );
   }
   
   return(0);
}   
Let us compile and run the above program to produce the following result −
var1 = |k| can be printed                                                   
var2 = |8| can be printed                                                   
var3 = |        | can't be printed                                          
var4 = | | can be printed


    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
What are the rules to create a constructor in java?

A constructor is used to initialize an object when it is created. It is syntactically similar to a method. The difference is that the constructors have same name as their class and, have no return type.
There is no need to invoke constructors explicitly these are automatically invoked at the time of instantiation.
While defining the constructors you should keep the following points in mind.
A constructor does not have return type.
A constructor does not have return type.
The name of the constructor is same as the name of the class.
The name of the constructor is same as the name of the class.
A constructor cannot be abstract, final, static and Synchronized.
A constructor cannot be abstract, final, static and Synchronized.
You can use the access specifiers public, protected & private with constructors.
You can use the access specifiers public, protected & private with constructors.
The following Java program demonstrates the creation of constructors.
 Live Demo
public class Student {
   public String name;
   public int age;
   public Student(){
      this.name = "Raju";
      this.age = 20;
   }
   public void display(){
      System.out.println("Name of the Student: "+this.name );
      System.out.println("Age of the Student: "+this.age );
   }
   public static void main(String args[]) {
      new Student().display();
   }
}
Name of the Student: Raju
Age of the Student: 20