code-rag-bench/online-tutorials huggingface dataset:
How to Install xlrd in Python in Windows? - GeeksforGeeks

26 Sep, 2021
The xlrd module in python is used to retrieve information from a spreadsheet. In this article, we will look into the process of installing the xldr module in a Windows machine.
The only thing that you need for installing the xlrd module on Windows are:
Python
PIP or Conda (depending upon user preference)
If you want the installation to be done through conda,  open up the Anaconda Powershell Prompt and use the below command:
conda install -c anaconda xlrd
Type y for yes when prompted.
You will get a similar message once the installation is complete:
Make sure you follow the best practices for installation using conda as:
Use an environment for installation rather than in the base environment using the below command:
conda create -n my-env
conda activate my-env
Note: If your preferred method of installation is conda-forge, use the below command:
conda config --env --add channels conda-forge
Users who prefer to use pip can use the below command to install the xlrd package on Windows:
pip install xlrd
You will get a similar message once the installation is complete:
Use the below code in your Python ide to verify successful installation of the xlrd package:
Python3
import xlrdxlrd.__version__
If successfully installed you will get the following output:
sooda367
Blogathon-2021
how-to-install
Picked
Blogathon
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Re-rendering Components in ReactJS
Python NOT EQUAL operator
How to build a basic CRUD app with Node.js and ReactJS ?
Banking Transaction System using Java
How to parse JSON Data into React Table Component ?
How to Find the Wi-Fi Password Using CMD in Windows?
How to Align Text in HTML?
How to Install OpenCV for Python on Windows?
Java Tutorial
How to Install FFmpeg on Windows?
Swing Examples - Add Title Border to JPanel

Following example showcase how to add title to border of a JPanel in a Java Swing application.
We are using the following APIs.
BorderFactory.createTitledBorder() − To create a titled border.
BorderFactory.createTitledBorder() − To create a titled border.
JPanel.setBorder(border) − To set the desired border to the JPanel.
JPanel.setBorder(border) − To set the desired border to the JPanel.
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.LayoutManager;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;

public class SwingTester {

   public static void main(String[] args) {
      createWindow();
   }

   private static void createWindow() {    
      JFrame frame = new JFrame("Swing Tester");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      createUI(frame);
      frame.setSize(560, 200);      
      frame.setLocationRelativeTo(null);  
      frame.setVisible(true);
   }

   private static void createUI(JFrame frame){
      //Create a border
      Border blackline = BorderFactory.createTitledBorder("Title");
      JPanel panel = new JPanel();
      LayoutManager layout = new FlowLayout();  
      panel.setLayout(layout);       

      JPanel panel1 = new JPanel();
      String spaces = "                   ";

      panel1.add(new JLabel(spaces + "Title border to JPanel" + spaces));  
      panel1.setBorder(blackline);

      panel.add(panel1);
      frame.getContentPane().add(panel, BorderLayout.CENTER);    
   }
}
 Print
 Add Notes
 Bookmark this page
SQL LIKE Operator

The LIKE operator is used in a 
WHERE clause to search for a specified pattern in a column.
There are two wildcards often used in conjunction with the 
LIKE operator:
 The percent sign (%) represents zero, one, or multiple characters
 The underscore sign (_) represents one, single character
Note: MS Access uses an asterisk (*) instead of the percent 
sign (%), and a question mark (?) instead of the underscore (_).
The percent sign and the underscore can also be used in combinations!
Tip: You can also combine any number of conditions using 
AND or OR operators.
Here are some examples showing different LIKE operators with '%' and '_' wildcards:
The table below shows the complete "Customers" table from the Northwind sample database:
The following SQL statement selects all customers with a CustomerName starting with 
"a":
The following SQL statement selects all customers with a CustomerName ending with "a":
The following SQL statement selects all customers with a CustomerName that 
have "or" in any position:
The following SQL statement selects all customers with a CustomerName that 
have "r" in the second position:
The following SQL statement selects all customers with a CustomerName that 
starts with "a" and are at least 3 characters in length:
The following SQL statement selects all customers with a ContactName that 
starts with "a" and ends with "o":
The following SQL statement selects all customers with a CustomerName that 
does 
NOT start with "a":
Select all records where the value of the City column starts with the letter "a".
SELECT * FROM Customers
;

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to get the table name of the current ResultSet using JDBC?

You can get the name of the table in the current ResultSet object using the getTableName() method of the ResultSetMetaData interface. This method accepts an integer value representing the index of a column and, returns a String value representing the name of the table that contains the given column.
Let us create a table with name MyPlayers in MySQL database using CREATE statement as shown below −
CREATE TABLE MyPlayers(
   ID INT,
   First_Name VARCHAR(255),
   Last_Name VARCHAR(255),
   Date_Of_Birth date,
   Place_Of_Birth VARCHAR(255),
   Country VARCHAR(255),
   PRIMARY KEY (ID)
);
Now, we will insert 7 records in MyPlayers table using INSERT statements −
insert into MyPlayers values(1, 'Shikhar', 'Dhawan', DATE('1981-12-05'), 'Delhi', 'India');
insert into MyPlayers values(2, 'Jonathan', 'Trott', DATE('1981-04-22'), 'CapeTown', 'SouthAfrica');
insert into MyPlayers values(3, 'Kumara', 'Sangakkara', DATE('1977-10-27'), 'Matale', 'Srilanka');
insert into MyPlayers values(4, 'Virat', 'Kohli', DATE('1988-11-05'), 'Delhi', 'India');
insert into MyPlayers values(5, 'Rohit', 'Sharma', DATE('1987-04-30'), 'Nagpur', 'India');
insert into MyPlayers values(6, 'Ravindra', 'Jadeja', DATE('1988-12-06'), 'Nagpur', 'India');
insert into MyPlayers values(7, 'James', 'Anderson', DATE('1982-06-30'), 'Burnley', 'England');
Following JDBC program establishes connection with MySQL database, retrieves and displays the name of the table.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
public class ResultSetMetaData_getTableName {
   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();
      //Query to retrieve records
      String query = "Select * from MyPlayers";
      //Executing the query
      ResultSet rs = stmt.executeQuery(query);
      //retrieving the ResultSetMetaData object
      ResultSetMetaData resultSetMetaData = rs.getMetaData();
      //Retrieving the column name
      String tableName = resultSetMetaData.getTableName(4);
      System.out.println("Name of the table : "+ tableName);
   }
}
Connection established......
Name of the table: myplayers
Python program to read input from console

Suppose we have to take firstname and lastname from console and write a prompt like "Hello <firstname> <lastname>, you are welcome!". To get the result we can use the format() class.We can placeholder into the string using {}, then pass arguments into format() function.
So, if the input is like Ashish Dutta, then the output will be "Hello Ashish Dutta, you are welcome!"
To solve this, we will follow these steps −
fn := take first input from the console
fn := take first input from the console
ln := take second input from the console
ln := take second input from the console
ret := "Hello a {} {}, you are welcome!" then call format with this string like format(fn, ln)
ret := "Hello a {} {}, you are welcome!" then call format with this string like format(fn, ln)
return ret
return ret
Let us see the following implementation to get better understanding
def solve():
   fn = input()
   ln = input()
   ret = "Hello {} {}, you are welcome!".format(fn, ln)
   return ret

print(solve())
Ashish
Dutta
Hello Ashish Dutta, you are welcome!
How to get the value in a particular cell inside the worksheet in Selenium with python?

We can get the value in a particular cell inside the worksheet in Selenium.
Excel is a spreadsheet which is saved with the .xlsx extension. An excel workbook
has multiple sheets and each sheet consists of rows and columns.
Out of all the worksheets, while we are accessing a particular sheet that is called as
an active sheet. Each cell inside a sheet has a unique address which is a combination
of row and column numbers.
The column number starts from alphabetic character A and row number starts from
the number 1. A cell can contain numerous types of values and they are the main
component of a worksheet.
To work with excel in Selenium with python, we need to take help of OpenPyXL
library. This library is responsible for reading and writing operations on Excel,
having the extensions like xlsx, xlsm, xltm, xltx.
To install OpenPyXL library, we have to execute the command pip install openpyxl.
This is because OpenPyXL does not come by default with python. After this we should import openpyxl in our code and then we should be ready to interact with excel.
To get the value inside the worksheet, first of all we need to load the entire
workbook by specifying the path where it is located. This is achieved with
load_workbook() method. Next we need to identify the active sheet among all the
worksheets with the help of active method.
To access a cell inside the active worksheet, we need the help of row and column
number and the cell method which accepts the row and column number as
arguments. For example, to point to the cell corresponding to row 2 and column 3,
we need to mention sheet.cell(row=2,column=3).
After identification of the cell, we need to use a value method to extract the value
out of our required cell.
wrkbk = load_workbook("C:\\work\\SeleniumPython.xlsx")
# to identify the active sheet
sh = wrkbk.active
# get the value of row 2 and column 3
c=sh.cell(row=2,column=3)
Coding Implementation to get the value of a particular cell.
import openpyxl
# load excel with its path
wrkbk = load_workbook("C:\\work\\SeleniumPython.xlsx")
# to get the active work sheet
sh = wrkbk.active
# get the value of row 2 and column 3
c=sh.cell(row=2,column=3
# to print the value in console
print(" The value is ", c.value)
How to display JTextArea in the form of a table with GridLayout in Java?

Display a component in the form of rows and columns using the GridLayout. Here, we have set a panel, within which we will create a layout with 3 rows and 5 columns −
JPanel panel = new JPanel(new GridLayout(3, 5, 5, 5));
Now, loop through and display JTextArea from 1 to 15 i.e. 3 rows and 5 columns −
for (int i = 1; i <= 15; i++) {
   panel.add(new JTextArea("Displaying TextArea "+String.valueOf(i)));
}
The following is an example to display text area in the form of a table with GridLayout -
package my;
import java.awt.GridLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class SwingDemo {
   public static void main(String[] args) {
      JFrame frame = new JFrame("GridLayout Demo");
      JPanel panel = new JPanel(new GridLayout(3, 5, 5, 5));
      for (int i = 1; i <= 15; i++) {
         panel.add(new JTextArea("Displaying TextArea "+String.valueOf(i)));
      }
      frame.add(panel);
      frame.setSize(650, 300);
      frame.setVisible(true);
   }
}
Valid Parenthesis String in C++

Suppose we have an expression. The expression has some parentheses; we have to check the parentheses are balanced or not. The order of the parentheses are (), {} and []. Suppose there are two strings. “()[(){()}]” this is valid, but “{[}]” is invalid.
To solve this, we will follow these steps −
Traverse through the expression until it has exhaustedif the current character is opening bracket like (, { or [, then push into stackif the current character is closing bracket like ), } or ], then pop from stack, andcheck whether the popped bracket is corresponding starting bracket of thecurrent character, then it is fine, otherwise, that is not balanced.
if the current character is opening bracket like (, { or [, then push into stack
if the current character is closing bracket like ), } or ], then pop from stack, and
check whether the popped bracket is corresponding starting bracket of the
current character, then it is fine, otherwise, that is not balanced.
After the string is exhausted, if there are some starting bracket left into the stack, then the string is not balanced.
Let us see the following implementation to get better understanding −
 Live Demo
#include <iostream>
#include <stack>
using namespace std;
bool isBalancedExp(string exp) {
   stack<char> stk;
   char x;
   for (int i=0; i<exp.length(); i++) {
      if (exp[i]=='('||exp[i]=='['||exp[i]=='{') {
         stk.push(exp[i]);
         continue;
      }
      if (stk.empty())
         return false;
      switch (exp[i]) {
      case ')':
         x = stk.top();
         stk.pop();
         if (x=='{' || x=='[')
            return false;
         break;
      case '}':
         x = stk.top();
         stk.pop();
         if (x=='(' || x=='[')
            return false;
         break;
      case ']':
         x = stk.top();
         stk.pop();
         if (x =='(' || x == '{')
            return false;
         break;
      }
   }
   return (stk.empty());
}
int main() {
   string expresion = "()[(){()}]";
   if (isBalancedExp(expresion))
      cout << "This is Balanced Expression";
   else
      cout << "This is Not Balanced Expression";
}
"()[(){()}]"
This is Balanced Expression
How to create bulk users in the active directory using PowerShell?

To create bulk users in the AD using PowerShell, there are multiple methods. For example, let say if you want to create 50 sample users for the lab environment without considering the other required properties, then you can use the below command,
$pass = Read-Host "Enter Account Password " -AsSecureString 1..50 | foreach{ New-ADUser -Name "TempUser$_" -AccountPassword $pass -Path "OU=LabUsers,DC=labdomain,DC=local" -ChangePasswordAtLogon $true -Enabled $true -PasThru}
The above command will create 50 Temp users in the OU named LABUSERS and one time we need to enter the password while running the script and when users log in with the same password, they need to change password at logon individually.
Another way to create bulk users in the active directory is using the text files containing AD users. For example,
$pass = Read-Host "Enter Account Password " foreach($ADAccount in (Get-Content c:\temp\ADAccounts.txt)){ New-ADUser -Name $ADAccount -AccountPassword $pass - Path "OU=LabUsers,DC=labdomain,DC=local" -ChangePasswordAtLogon $true -Enabled $true }
In the above example, a list of AD Accounts in the text file called ADAccounts.txt is placed at c:\temp.
This is the best way to create multiple users account with multiple properties as a CSV file. We can store the data into the CSV file and can jump on each line to create the user account with that specific properties.
Suppose we have a CSV file stored in the folder C:\temp and the file name called NewUsers.CSV. The content of the file is as below.
Code is as below.
$pass = Read-Host "Enter AD user password " foreach($account in (Import-Csv C:\Temp\NewUsers.csv)){
New-ADUser -Name $account.Name ` -DisplayName $account.FirstName `
-Surname $account.Surname `
-EmployeeID $account.EMPNumber ` -Country $account.Country `
-Path "OU=LabUsers,DC=labdomain,DC=local" ` -Enabled $true `
-AccountPassword $pass ` -ChangePasswordAtLogon $true `
-PassThru }
Data Structure and Algorithms Linear Search

Linear search is a very simple search algorithm. In this type of search, a sequential search is made over all items one by one. Every item is checked and if a match is found then that particular item is returned, otherwise the search continues till the end of the data collection.
Linear Search ( Array A, Value x)

Step 1: Set i to 1
Step 2: if i > n then go to step 7
Step 3: if A[i] = x then go to step 6
Step 4: Set i to i + 1
Step 5: Go to Step 2
Step 6: Print Element x Found at index i and go to step 8
Step 7: Print element not found
Step 8: Exit

procedure linear_search (list, value)

   for each item in the list
      if match item == value
         return the item's location
      end if
   end for

end procedure
To know about linear search implementation in C programming language, please click-here.

    42 Lectures 
     1.5 hours 

 Ravi Kiran

    141 Lectures 
     13 hours 

 Arnab Chakraborty

    26 Lectures 
     8.5 hours 

 Parth Panjabi

    65 Lectures 
     6 hours 

 Arnab Chakraborty

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    64 Lectures 
     10.5 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
How to write a case insensitive Python regular expression without re.compile?

We can pass re.IGNORECASE to the flags parameter of search, match, or sub −
import re
print (re.search('bush', 'BuSh', re.IGNORECASE))
print (re.match('bush', 'BuSh', re.IGNORECASE))
print (re.sub('bush', 'xxxx', 'Bushmeat', flags=re.IGNORECASE))
<_sre.SRE_Match object at 0x0000000005316648>
<_sre.SRE_Match object at 0x0000000005316648>
xxxxmeat
Convert from float to String in Java

To convert float to string, use the toString() method. It represents a value in a string.
Let’s say the following is our float.
float f = 0.9F;
Converting the float value to string.
String s = Float.toString(f);
Let us see the complete example to convert float to String in Java with output.
 Live Demo
public class Demo {
   public static void main(String args[]) {
      float f = 0.9F;
      String s = Float.toString(f);
      System.out.println(s);
   }
}
0.9
How to search a string in backwards direction in Python?

Python has a rfind() method which searches from the end of a string for the occurrence of a substring. It returns the index of the last occurrence if found, else -1. You can use it as follows:
>>> "CocacolaPepsi".rfind('cola')
4
>>> 'CocacolaPepsi'.rfind('coke')
-1
How to Execute C# Program on cmd (command-line)? - GeeksforGeeks

30 Jan, 2020
C# is a general-purpose, modern and object-oriented programming language pronounced as “C sharp”. C# is among the languages for Common Language Infrastructure and the current version of C# is version 8.0. C# is a lot similar to Java syntactically and is easy for the users who know C, C++ or Java.
Since the C# is a lot similar to other widely used languages syntactically, it is easier to code and learn in C#.Programs can be written in C# in any of the widely used text editors like Notepad++, gedit, etc. or on any of the compilers. After writing the program save the file with the extension .cs. There are various online IDEs such as GeeksforGeeks ide, CodeChef ide, etc. which can be used to run C# programs without installing. One can also use command-line options to run a C# program.
Sample C# Program to execute on Command-Line:
// C# program to print Hello World!using System;  // namespace declarationnamespace HelloWorldApp {  // Class declarationclass Geeks {      // Main Method    static void Main(string[] args)    {          // statement        // printing Hello World!        Console.WriteLine("Hello World!");          // To prevents the screen from        // running and closing quickly        Console.ReadKey();    }}}
Step 1: Go to Control Panel -> System and Security -> System. Under Advanced System Setting option click on Environment Variables as shown below:
 
Step 2: Now, we have to alter the “Path” variable under System variables so that it also contains the path to the .NET Framework environment. Select the “Path” variable and click on the Edit button as shown below:
 
Step 3: We will see a list of different paths, click on the New button and then add the path where .NET Framework is installed.
 
Step 4: Click on OK, Save the settings and it is done !! Now to check whether the environment setup is done correctly, open command prompt and type csc.
 
Step 1: Open the text editor like Notepad or Notepad++, and write the code that you want to execute. Now save the file with .cs extension.
 
Step 2: Compile your C# source code with the use of command:
csc File_name.cs
If your program has no error then it will create a filename.exe file in the same directory where you have saved your program. Suppose you saved the above program as Hello.cs. So you will write csc Hello.cs on cmd. This will create a Hello.exe file.
 
Step 3: Now there are two ways to execute the Hello.exe. First, you have to simply type the filename i.e Hello on the cmd and it will give the output. Second, you can go to the directory where you saved your program and there you find filename.exe. You have to simply double-click that file and it will give the output.
Using Command:
Using .exe file:
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# Dictionary with examples
C# | Delegates
C# | Abstract Classes
Difference between Ref and Out keywords in C#
Extension Method in C#
C# | String.IndexOf( ) Method | Set - 1
C# | Replace() Method
Introduction to .NET Framework
C# | Arrays
HashSet in C# with Examples
RustScan - Faster Nmap Scanning with Rust - GeeksforGeeks

23 Sep, 2021
Port Scanning is the process of detection of active ports on the Web Server. In some cases, if there is an unfamiliar port running on the server, this can lead to breaches. We can perform use various automated tools like Nmap, Masscan, etc for port detection. RustScan is the tool that assures the fastest result retrieving tool as compares to Nmap. RustScan is a tool that turns a 17 minutes Nmap scan into 19 seconds. RustScan tool is developed in the Rust language and valid on the GitHub platform. RustScan tool is an open-source and free-to-use tool. RustScan tool can scan 65k ports in almost 7-8 seconds which is much faster than other tools. RustScan tool has support to IPv6 Version IP.
Step 1: Download the .deb file from the below links to your Kali Linux operating system.
https://github.com/RustScan/RustScan/releases/download/2.0.1/rustscan_2.0.1_amd64.deb
Step 2: Run the command dpkg -i on the file to install the tool.
sudp dpkg -i rustscan_2.0.1_amd64.deb
Step 3: Now use the following command to run the tool and check the help section.
rustscan -h
Example 1: Host Scanning
rustscan -a www.geeksforgeeks.org
In this example, we will be performing a simple port scan on the geeksforgeeks.org domain.
Example 2: Individual Port Scanning
rustscan -a www.geeksforgeeks.org -p 443
In this example, we will be performing specific single port detection rather than scanning all the ports.
Example 3: Multiple selected port scanning
rustscan -a www.geeksforgeeks.org -p 443,80,121,65535
In this example, we will be performing multiple port scans or specific lists of ports rather than scanning all the ports.
Example 4: Ranges of ports
rustscan -a www.geeksforgeeks.org --range 1-1000
In this example, we will be performing detection of ports from the range of 1-1000 on the geeksforgeeks.org domain.
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
Docker - COPY Instruction
mv command in Linux with examples
SED command in Linux | Set 2
chown command in Linux with Examples
nohup Command in Linux with Examples
Named Pipe or FIFO with example C program
Thread functions in C/C++
uniq Command in LINUX with examples
Start/Stop/Restart Services Using Systemctl in Linux
Get UTC timestamp in Python - GeeksforGeeks

17 Mar, 2021
Datetime module supplies classes to work with date and time. These classes provide a number of functions to deal with dates, times and time intervals. Date and datetime are an object in Python, so when you manipulate them, you are actually manipulating objects and not string or timestamps.
Note: For more information, refer to Python datetime module with examples
Example:
# Python program to demonstrate#  datetime module  import datetime    dt = datetime.date(2020, 1, 26)# prints the date as date# objectprint(dt)  # prints the current dateprint(datetime.date.today())  # prints the date and timedt = datetime.datetime(1999, 12, 12, 12, 12, 12, 342380) print(dt)   # prints the current date # and timeprint(datetime.datetime.now())
Output:
2020-01-26
2020-02-04
1999-12-12 12:12:12.342380
2020-02-04 07:46:29.315237

Use the datetime.datetime.now() to get the current date and time. Then use tzinfo class to convert our datetime to UTC. Lastly, use the timestamp() to convert the datetime object, in UTC, to get the UTC timestamp.
Example:
from datetime import timezoneimport datetime    # Getting the current date# and timedt = datetime.datetime.now(timezone.utc)  utc_time = dt.replace(tzinfo=timezone.utc)utc_timestamp = utc_time.timestamp()  print(utc_timestamp)
Output:
1615975803.787904

Python-datetime
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Matplotlib.pyplot.subplot() function in Python

20 May, 2022
Prerequisites: matplotlib
subplot() function adds subplot to a current figure at the specified grid position.  It is similar to the subplots() function however unlike subplots() it adds one subplot at a time. So to create multiple plots you will need several lines of code with the subplot() function. Another drawback of the subplot function is that it deletes the preexisting plot on your figure. Refer to example 1.
It is a wrapper of Figure.add_subplot.
Syntax:
subplot(nrows, ncols, index, **kwargs)
subplot(pos, **kwargs) 
subplot(ax)
Parameters : 
args:  Either a 3-digit integer or three separate integers describing the position of the subplot.
pos is a three-digit integer where the first, second, and third integer are nrows,ncols, index.
projection : [{None, ’aitoff’, ’hammer’, ’lambert’, ’mollweide’, ’polar’, ’rectilinear’, str}, optional]. The projection-type of the subplot (Axes). The default None results in a ’rectilinear’ projection.
label : [str] A label for the returned axes.
**kwargs: This method also takes the keyword arguments for the returned axes base class;except for the figure argument, for e.g facecolor.
Returns :  An axes.SubplotBase subclass of Axes or a subclass of Axes. The returned axes base class depends on the projection used.
Implementation of the function is given below:
Example 1: subplot() will delete the pre-existing plot.
Python3
# importing the moduleimport matplotlib.pyplot as plt # Data to display on plotx = [1, 2, 3, 4, 5]y = [1, 2, 1, 2, 1] # plot() will create new figure and will add axes object (plot) of above dataplt.plot(x, y, marker="x", color="green") # subplot() will add plot to current figure deleting existing plotplt.subplot(121)
Output: We can see that the first plot got set aside by the subplot() function. 
subplot_gfg
If you want to see the first plot comment out plt.subplot() line and you will see the following plot
plot_gfg
Example 2:
Python3
import matplotlib.pyplot as plt# data to display on plots x = [3, 1, 3]y = [3, 2, 1]z = [1, 3, 1] # Creating figure objectplt.figure() # adding first subplotplt.subplot(121)plt.plot(x, y, color="orange", marker="*") # adding second subplotplt.subplot(122)plt.plot(z, y, color="yellow", marker="*")
Output :
multiple_subplots
sumitgumber28
surinderdawra388
Matplotlib Pyplot-class
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Python | datetime.timedelta() function
SQRT() Function in SQL Server

30 Dec, 2020
SQRT() function :This function in SQL Server is used to return the square root of a specified positive number. For example, if the specified number is 81, this function will return 9.
Features :
This function is used to find the square root of a given number.
This function accepts only positive numbers.
This function also accepts fraction numbers.
This function always returns positive number.
This function use the formula ”(a)1/2 = Returned value“, where a is the specified number.
Syntax :
SQRT(number)
Parameter :This method accepts a parameter as given below :
number : Specified positive number whose square root is going to be returned.
Returns :It returns the square root of a specified positive number.
Example-1 :Getting the square root of the specified number 4.
SELECT SQRT(4);
Output :
2.0
Example-2 :Getting the square root of the specified number 0.
SELECT SQRT(0);
Output :
0.0
Example-3 :Using SQRT() function with a variable and getting the square root of the specified number 1.
DECLARE @Parameter_Value INT;
SET @Parameter_Value = 1;
SELECT SQRT(@Parameter_Value);
Output :
1.0
Example-4 :Getting the square root of 16 which is the result of “64/4”.
SELECT SQRT(64/4);
Output :
4.0
Example-5 :Using SQRT() function with a variable and getting the square root of float value “4.7”.
DECLARE @Parameter_Value FLOAT;
SET @Parameter_Value = 4.7;
SELECT SQRT(@Parameter_Value);

Output :
2.16794833886788
Application :This function is used to return the square root of a specified positive number.
DBMS-SQL
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
CTE in SQL
How to Update Multiple Columns in Single Update Statement in SQL?
SQL Interview Questions
SQL | Views
Difference between DELETE, DROP and TRUNCATE
Difference between SQL and NoSQL
MySQL | Group_CONCAT() Function
Difference between DDL and DML in DBMS
Window functions in SQL
SQL Correlated Subqueries
What does “dereferencing” a pointer mean in C/C++?

Dereferencing is used to access or manipulate data contained in memory location pointed to by a pointer. *(asterisk) is used with pointer variable when dereferencing the pointer variable, it refers to variable being pointed, so this is called dereferencing of pointers.
int main() {
   int a = 7, b ;
   int *p; // Un-initialized Pointer
   p = &a; // Stores address of a in ptr
   b = *p; // Put Value at ptr in b
}
Here, address in p is basically address of a variable.
Compile 32-bit program on 64-bit gcc in C and C++

Nowadays the compiler comes with default 64-bit version. Sometimes we need to compile and execute a code into some 32bit system. In that time, we have to use thisS feature.
At first, we Shave to check the current target version of the gcc compiler. To check this, we have to type this command.
gcc –v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
...........
...........
...........
Here it is showing that Target is x86_64. So we are using the 64-bit version of gcc. Now to use the 32-bit system, we have to write the following command.
gcc –m32 program_name.c
Sometimes this command may generate some error like below. This indicates that the standard library of gcc is missing. In that situation we have to install them.
In file included from test_c.c:1:0:
/usr/include/stdio.h:27:10: fatal error: bits/libc-header-start.h: No such file
or directory
#include <bits/libc-header-start.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Now, to install the standard library for gcc, we have to write the following commands.
sudo apt-get install gcc-multilib
sudo apt-get install g++-multilib
Now by using this code we will see the differences of executing in 32-bit system and the 64-bit system.
#include<stdio.h>
main() {
   printf("The Size is: %lu\n", sizeof(long));
}
$ gcc test_c.c
test_c.c:3:1: warning: return type defaults to ‘int’ [-Wimplicit-int] main(){
^~~~
$ ./a.out
The Size is: 8
$ gcc -m32 test_c.c
test_c.c:3:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
main(){
^~~~
test_c.c: In function ‘main’:
test_c.c:4:28: warning: format ‘%lu’ expects argument of type ‘long unsigned
int’, but argument 2 has type ‘unsigned int’ [-Wformat=]
printf("The Size is: %lu\n", sizeof(long));
~~^
%u
$ ./a.out
The Size is: 4
Variable Length Arrays in C and C++

Here we will discuss about the variable length arrays in C++. Using this we can allocate an auto array of variable size. In C, it supports variable sized arrays from C99 standard. The following format supports this concept −
void make_arr(int n){
   int array[n];
}
int main(){
   make_arr(10);
}
But, in C++ standard (till C++11) there was no concept of variable length array. According to the C++11 standard, array size is mentioned as a constant-expression. So, the above block of code may not be a valid C++11 or below. In C++14 mentions array size as a simple expression (not constant-expression).
Let us see the following implementation to get better understanding −
 Live Demo
#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;
class employee {
   public:
      int id;
      int name_length;
      int struct_size;
      char emp_name[0];
};
employee *make_emp(struct employee *e, int id, char arr[]) {
   e = new employee();
   e->id = id;
   e->name_length = strlen(arr);
   strcpy(e->emp_name, arr);
   e->struct_size=( sizeof(*e) + sizeof(char)*strlen(e->emp_name) );
   return e;
}
void disp_emp(struct employee *e) {
   cout << "Emp Id:" << e->id << endl;
   cout << "Emp Name:" << e->emp_name << endl;
   cout << "Name Length:" << e->name_length << endl;
   cout << "Allocated:" << e->struct_size << endl;
   cout <<"---------------------------------------" << endl;
}
int main() {
   employee *e1, *e2;
   e1=make_emp(e1, 101, "Jayanta Das");
   e2=make_emp(e2, 201, "Tushar Dey");
   disp_emp(e1);
   disp_emp(e2);
   cout << "Size of student: " << sizeof(employee) << endl;
   cout << "Size of student pointer: " << sizeof(e1);
}
Emp Id:101
Emp Name:Jayanta Das
Name Length:11
Allocated:23
---------------------------------------
Emp Id:201
Emp Name:Tushar Dey
Name Length:10
Allocated:22
---------------------------------------
Size of student: 12
Size of student pointer: 8
Bootstrap 4 .float-left class

Use the float-left class in Bootstrap to float an element to the left.
To place it on the left −
<h1 class="float-left">
  I am on the left.
</h1>

<p class="float-left">
  I am on the left.
</p>
You can try to run the following code to implement the float-left class −
Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>

<body>

<div class="container">
  <h2>Text</h2>
  <p>The following text is on the left:</p>
  <div class="clearfix">
    <p class="float-left">I am on the left.</p>
  </div>
</div>

</body>
</html>
Customize the tooltip font, color , background and foreground color in Java

To customize the tooltip font, color and background, use UIManager.
UIManager.put("ToolTip.background", Color.ORANGE);
UIManager.put("ToolTip.foreground", Color.BLACK);
UIManager.put("ToolTip.font", new Font("Arial", Font.BOLD, 14));
Above, we have set the font with −
Tooltip.font
We have set the foreground and background color with the following above −
ToolTip.foreground
ToolTip.background
The following is an example to customize tooltip −
package my;
import java.awt.Color;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.GridLayout;
import java.awt.Point;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
public class SwingDemo {
   public static void main(String[] args) throws Exception {
      JFrame.setDefaultLookAndFeelDecorated(true);
      JFrame frame = new JFrame("Register!");
      JLabel label1, label2, label3;
      frame.setLayout(new GridLayout(2, 2));
      label1 = new JLabel("Id", SwingConstants.CENTER);
      label1.setToolTipText("<html>" + "Add the id given to you" + "<br>" + "in the
      beginning!" + "</html>");
      UIManager.put("ToolTip.background", Color.ORANGE);
      UIManager.put("ToolTip.foreground", Color.BLACK);
      UIManager.put("ToolTip.font", new Font("Arial", Font.BOLD, 14));
      label2 = new JLabel("Rank", SwingConstants.CENTER);
      label2.setToolTipText("Enter rank");
      label3 = new JLabel("Password", SwingConstants.CENTER);
      label3.setToolTipText("Enter Password");
      JTextField emailId = new JTextField(20);
      JTextField rank = new JTextField(20);
      JPasswordField passwd = new JPasswordField();
      passwd.setEchoChar('*');
      frame.add(label1);
      frame.add(label2);
      frame.add(label3);
      frame.add(emailId);
      frame.add(rank);
      frame.add(passwd);
      Point center =
      GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
      int width = 500;
      int height = 200;
      frame.setBounds(center.x - width / 2, center.y - height / 2, width, height);
      frame.setVisible(true);
}
}
SQL Query to Convert Rows to Columns in SQL Server - GeeksforGeeks

16 Dec, 2021
In this article we will see, how to convert Rows to Column in SQL Server. In a table where many columns have the have same data for many entries in the table, it is advisable to convert the rows to column. This will help to reduce the table and make the table more readable.
For example, Suppose we have a table given below:
It is better if we store the data of this table as:
We can convert rows into column using PIVOT function in SQL.
Syntax:
SELECT (ColumnNames)  
FROM (TableName)  
PIVOT
(  
  AggregateFunction(ColumnToBeAggregated)
  FOR PivotColumn IN (PivotColumnValues)
) AS (Alias);                                   
 //Alias is a temporary name for a table
  
For the purpose of the demonstration, we will be creating a demo_table in a database called “geeks“.
Step 1: Creating the Database
Use the below SQL statement to create a database called geeks.
Query:
CREATE DATABASE geeks;
Step 2: Using the Database
Use the below SQL statement to switch the database context to geeks.
Query:
USE geeks;
Step 3: Table definition
We have the following demo_table in our geek’s database.
Query:
CREATE TABLE demo_table(
NAME varchar(30),
COLLEGE varchar(30),
EXAM_DATE DATE,
SUBJECTS varchar(30),
MARKS int);
Step 4: Insert data into the table
Query:
INSERT INTO demo_table VALUES ('ROMY', 'BVCOE', 
'12-OCT-2021', 'DBMS', 90),
('ROMY', 'BVCOE', '12-OCT-2021', 'NETWORKING', 90),
('ROMY', 'BVCOE', '12-OCT-2021', 'GRAPHICS', 100),
('ROMY', 'BVCOE', '12-OCT-2021', 'CHEMISTRY', 98),
('ROMY', 'BVCOE', '12-OCT-2021', 'MATHEMATICS', 78),
('PUSHKAR', 'MSIT', '14-OCT-2021', 'NETWORKING' , 97),
('PUSHKAR', 'MSIT', '14-OCT-2021', 'GRAPHICS', 98),
('PUSHKAR', 'MSIT', '14-OCT-2021', 'CHEMISTRY', 79),
('PUSHKAR', 'MSIT', '14-OCT-2021', 'MATHEMATICS', 79),
('PUSHKAR', 'MSIT', '14-OCT-2021', 'DBMS', 79);
Step 5: See the content of the table
Use the below command to see the content of the demo_table:
Query:
SELECT * FROM demo_table;
Output:
Step 6: Using pivot function in order to convert row into column.
Query:
SELECT * FROM demo_table  
 PIVOT
(AVG(MARKS) FOR SUBJECTS IN (DBMS,NETWORKING, 
GRAPHICS, CHEMISTRY, MATHEMATICS)) AS PivotTable;
We have used AVERAGE aggregate function because average of one value is the value itself.
Output:
 We can see that rows get transformed to column. 
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
How to Update Multiple Columns in Single Update Statement in SQL?
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL using Python
SQL | Subquery
How to Write a SQL Query For a Specific Date Range and Date Time?
SQL Query to Convert VARCHAR to INT
SQL Query to Delete Duplicate Rows
SQL Query to Compare Two Dates
Window functions in SQL
What is JDBC SQL Escape Syntax Explain?

The escape syntax gives you the flexibility to use database specific features unavailable to you by using standard JDBC methods and properties.
The general SQL escape syntax format is as follow:
{keyword 'parameters'}
Following are various escape syntaxes in JDBC:
d, t, ts Keywords: They help identify date, time, and timestamp literals. As you know, no two DBMSs represent time and date the same way. This escape syntax tells the driver to render the date or time in the target database's format
{d 'yyyy-mm-dd'}
Where yyyy = year, mm = month; dd = date. Using this syntax {d '2009-09-03'} is March 9, 2009.
//Create a Statement object
stmt = conn.createStatement();
//Insert data ==> ID, First Name, Last Name, DOB
String sql="INSERT INTO STUDENTS VALUES" + "(100,'Zara','Ali', {d '2001-12-16'})";
stmt.executeUpdate(sql);
This keyword identifies the escape character used in LIKE clauses. Useful when using the SQL wildcard %, which matches zero or more characters. For example −
String sql = "SELECT symbol FROM MathSymbols WHERE symbol LIKE '\%' {escape '\'}";
stmt.execute(sql);
If you use the backslash character (\) as the escape character, you also have to use two backslash characters in your Java String literal, because the backslash is also a Java escape character.
This keyword represents scalar functions used in a DBMS. For example, you can use SQL function length to get the length of a string −
{fn length('Hello World')}
This returns 11, the length of the character string 'Hello World'. call Keyword
This keyword is used to call the stored procedures. For example, for a stored procedure requiring an IN parameter, use the following syntax −
{call my_procedure(?)};
For a stored procedure requiring an IN parameter and returning an OUT parameter, use the following syntax −
{? = call my_procedure(?)};
This keyword is used to signify outer joins. The syntax is as follows −
{oj outer-join}
Where outer-join = table {LEFT|RIGHT|FULL} OUTERJOIN {table | outer-join} on search-condition.
String sql = "SELECT Employees FROM {oj ThisTable RIGHT OUTER JOIN ThatTable on id = '100'}";
stmt.execute(sql);
Program to find wealth of richest customer in Python

Suppose we have a matrix of order m x n called accounts where accounts[i][j] is the amount of money of ith customer present in jth bank. We have to find the wealth that the richest customer has. A customer is richest when he/she has maximum amount considering all banks.
So, if the input is like
then the output will be 55 as the money of second person is 30+5+20 = 55, which is maximum.
To solve this, we will follow these steps −
max_balue := 0
max_balue := 0
ind_value := 0
ind_value := 0
for i in range 0 to row count of accounts - 1, doind_value := sum of all values in accounts[i]if ind_value > max_balue, thenmax_balue := ind_value
for i in range 0 to row count of accounts - 1, do
ind_value := sum of all values in accounts[i]
ind_value := sum of all values in accounts[i]
if ind_value > max_balue, thenmax_balue := ind_value
if ind_value > max_balue, then
max_balue := ind_value
max_balue := ind_value
return max_balue
return max_balue
Let us see the following implementation to get better understanding −
 Live Demo
def solve(accounts):
   max_balue = 0
   ind_value = 0
   for i in range(len(accounts)):
      ind_value = sum(accounts[i])
      if ind_value > max_balue:
         max_balue = ind_value
   return max_balue

accounts = [[10,20,15],
   [30,5,20],
   [10,5,12],
   [15,12,3]]
print(solve(accounts ))
[[10,20,15],
[30,5,20],
[10,5,12],
[15,12,3]]
55
Python Number log() Method

Python number  method log() returns natural logarithm of x, for x > 0.
Following is the syntax for log() method −
import math

math.log( x )
Note − This function is not accessible directly, so we need to import math module and then we need to call this function using math static object.
x − This is a numeric expression.
x − This is a numeric expression.
This method returns natural logarithm of x, for x > 0.
The following example shows the usage of log() method.
#!/usr/bin/python
import math   # This will import math module

print "math.log(100.12) : ", math.log(100.12)
print "math.log(100.72) : ", math.log(100.72)
print "math.log(119L) : ", math.log(119L)
print "math.log(math.pi) : ", math.log(math.pi)
When we run above program, it produces following result −
math.log(100.12) :  4.60636946656
math.log(100.72) :  4.61234438974
math.log(119L) :  4.77912349311
math.log(math.pi) :  1.14472988585


    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
Find average of a list in Java

To find average of a list in Java, the code is as follows -
 Live Demo
import java.util.*;
public class Demo {
   public static void main(String []args){
      List<Integer> list = Arrays.asList(10, 20, 50, 100, 130, 150, 200, 250, 500);
      IntSummaryStatistics summaryStats = list.stream()
      .mapToInt((a) -> a)
      .summaryStatistics();
      System.out.println("Average of a List = "+summaryStats.getAverage());
   }
}
Average of a List = 156.66666666666666
Let us now see another example -
 Live Demo
import java.util.*;
public class Demo {
   public static void main(String []args){
      List<Integer> list = Arrays.asList(10, 20, 50, 100, 130, 150, 200, 250, 500);
      int sum = 0;
      for (int i : list) {
         sum+=i;
      }
      if(list.isEmpty()){
         System.out.println("Empty list!");
      } else {
         System.out.println("Average = " + sum/(float)list.size());
      }
   }
}
Average = 156.66667