code-rag-bench/online-tutorials huggingface dataset:
Difference between Inner and Outer join in SQL

In Relational database tables are associated with each other and we used foreign key to maintain relationships between tables. We used join clause to retrieve data from associated tables. The join condition indicates how column in each table are matched against each other. 
There are two types of joins clause in SQL 
Inner join 
Outer join
Outer join is again divided into parts −
LEFT OUTER JOIN - It will return all data of the left table and matched  records in both table 
RIGHT OUTER JOIN - it will return all the data of the right table and matched records in both table
1
Basic 
It can be used to retrieve only matched records between both tables 
It is used to retrieve all matching records as well non matching records of the tables  
2
        Return 
It doesn't return anything when match is not found.
It return null in the column values 
3
Performance 
It is faster than outer join.
It is slower than inner join because of the larger result set
SELECT columnnameList
FROM tableA
FULL OUTER JOIN tableB
ON tableA.column_name = tableB.column_name
WHERE condition;
SELECT columnlist
FROM TableA
INNER JOIN
TableB ON join condition
PostgreSQL- CONCAT Function - GeeksforGeeks

08 Feb, 2021
In PostgreSQL, the CONCAT function is used to concatenate two or more strings into one.
Syntax: CONCAT(string_1, string_2, ...)
Let’s analyze the above syntax:
The CONCAT function accepts a list of string convertible arguments. A string in this context means any of the following data types: char, varchar, or text.
The CONCAT function is variadic meaning that the CONCAT function can accept an array as the argument. Here it is required to mark the array with the VARIADIC keyword. The CONCAT function considers every array element as an argument.
Contrary to the concatenation operator ( || ), the CONCAT function ignores NULL arguments. 
Example 1:
The below statement uses the CONCAT function to concatenate three strings into one:
SELECT
 CONCAT ('Geeks', 'for', 'geeks');
Output:
Example 2:
The following statement concatenates values in the first_name and last_name columns of the actor table in the sample database, ie, dvdrental.
SELECT
    CONCAT  (first_name, ' ', last_name) AS "Full name"
FROM
    actor;
Output:
PostgreSQL-function
PostgreSQL-String-function
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PostgreSQL - GROUP BY clause
PostgreSQL - DROP INDEX
PostgreSQL - Copy Table
PostgreSQL - Interval Data Type
PostgreSQL - LEFT JOIN
PostgreSQL - TEXT Data Type
PostgreSQL - TIME Data Type
PostgreSQL - Record type variable
PostgreSQL - CREATE PROCEDURE
PostgreSQL - ROW_NUMBER Function
Python List extend() Method

Python list method extend() appends the contents of seq to list.
Following is the syntax for extend() method −
list.extend(seq)

seq − This is the  list of elements
seq − This is the  list of elements
This method does not return any value but add the content to existing list.
The following example shows the usage of extend() method.
#!/usr/bin/python

aList = [123, 'xyz', 'zara', 'abc', 123];
bList = [2009, 'manni'];
aList.extend(bList)
print "Extended List : ", aList 
When we run above program, it produces following result −
Extended List :  [123, 'xyz', 'zara', 'abc', 123, 2009, 'manni']


    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
Lucene - Query

Query is an abstract class and contains various utility methods and is the parent of all types of queries that Lucene uses during search process.
Following is the declaration for org.apache.lucene.search.Query class −
public abstract class Query
   extends Object
      implements Serializable, Cloneable

The following table shows a class constructor −
Query()
The following table shows the different class methods −
Object clone()
Returns a clone of this query.
Query combine(Query[] queries)
Expert: Called when re-writing queries under MultiSearcher.
Weight createWeight(Searcher searcher) 
Expert: Constructs an appropriate Weight implementation for this query.
boolean equals(Object obj)
void extractTerms(Set<Term> terms)
Expert: Adds all terms occurring in this query to the terms set.
float getBoost()
Gets the boost for this clause.
Similarity getSimilarity(Searcher searcher) 
Deprecated. Instead of using "runtime" subclassing/delegation, subclass the Weight instead.
int hashCode()
static Query mergeBooleanQueries(BooleanQuery... queries)
Expert: Merges the clauses of a set of BooleanQuery's into a single BooleanQuery.
Query rewrite(IndexReader reader)
Expert: Called to re-write queries into primitive queries.
void setBoost(float b)
Sets the boost for this query clause to b.
String toString()
Prints a query to a string.
abstract String toString(String field) 
Prints a query to a string, with field assumed to be the default field and omitted.
Weight weight(Searcher searcher)
Deprecated. Never ever use this method in Weight implementations. Subclasses of Query should use createWeight(org.apache.lucene.search.Searcher), instead.
This class inherits methods from the following classes −
java.lang.Object
 Print
 Add Notes
 Bookmark this page
Python - Successive Characters Frequency - GeeksforGeeks

03 Jul, 2020
Sometimes, while working with Python strings, we can have a problem in which we need to find the frequency of next character of a particular word in string. This is quite unique problem and has the potential for application in day-day programming and web development. Let’s discuss certain ways in which this task can be performed.
Input : test_str = ‘geeks are for geeksforgeeks’, que_word = “geek”Output : {‘s’: 3}
Input : test_str = ‘geek’, que_word = “geek”Output : {}
Method #1 : Using loop + count() + re.findall()The combination of above methods constitute the brute force method to perform this task. In this, we perform the task of counting using count(), and character is searched using findall().
# Python3 code to demonstrate working of # Successive Characters Frequency# Using count() + loop + re.findall()import re      # initializing stringtest_str = 'geeksforgeeks is best for geeks. A geek should take interest.'  # printing original stringprint("The original string is : " + str(test_str))  # initializing word que_word = "geek"  # Successive Characters Frequency# Using count() + loop + re.findall()temp = []for sub in re.findall(que_word + '.', test_str):    temp.append(sub[-1])  res = {que_word : temp.count(que_word) for que_word in temp}  # printing result print("The Characters Frequency is : " + str(res))
The original string is : geeksforgeeks is best for geeks. A geek should take interest.
The Characters Frequency is : {'s': 3, ' ': 1}

 
Method #2 : Using Counter() + list comprehension + re.findall()The combination of above functions is used to perform the following task. In this, we use Counter() instead of count() to solve this problem. Works with newer versions of Python.
# Python3 code to demonstrate working of # Successive Characters Frequency# Using Counter() + list comprehension + re.findall()from collections import Counterimport re  # initializing stringtest_str = 'geeksforgeeks is best for geeks. A geek should take interest.'  # printing original stringprint("The original string is : " + str(test_str))  # initializing word que_word = "geek"  # Successive Characters Frequency# Using Counter() + list comprehension + re.findall()res = dict(Counter(re.findall(f'{que_word}(.)', test_str,                                     flags=re.IGNORECASE)))  # printing result print("The Characters Frequency is : " + str(res))
The original string is : geeksforgeeks is best for geeks. A geek should take interest.
The Characters Frequency is : {'s': 3, ' ': 1}

Python string-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
Set active state for Bootstrap Buttons

To set the active state for Bootstrap Buttons, use the .active class.
The button will appear pressed as in the following code
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <p>The following are some buttons:</p>
      <button type = "button" class = "btn btn-default btn-lg ">
         Default Button
      </button>
      <button type = "button" class = "btn btn-default btn-lg active">
         Active Button
      </button>
   </body>
</html>
How to read a Pandas CSV file with no header?

To read a CSV file with no header, we can use headers in read_csv() method.
Initialize a variable file_path, i,e., CSV file path.
Use read_csv method to get the DataFrame with tab separator and with headers.
Print the DataFrame with headers.
Use read_csv method to get the DataFrame with tab separator and without headers. To read without headers, use header=0.
Print the DataFrame without headers.
import pandas as pd

file_path = 'test.csv'

// With Headers
df = pd.read_csv(file_path, sep='\t', names=['x', 'y', 'z'])
print "With headers, the DataFrame is: \n", df

// Without Headers
df = pd.read_csv(file_path, sep='\t', header=0, names=['x', 'y', 'z'])
print "Without headers, the DataFrame is: \n", df
The CSV file "test.csv" contains the following data
   x  y  z
0  5  4  4
1  2  1  1
2  1  5  5
3  9 10  0
With headers, the DataFrame is:

     x  y  z
NaN  x  y  z
0.0  5  4  4
1.0  2  1  1
2.0  1  5  5
3.0  9 10  0

Without headers, the DataFrame is:
   x  y  z
0  5  4  4
1  2  1  1
2  1  5  5
3  9 10  0
Python – Opening links using Selenium

27 Feb, 2020
Selenium is a powerful tool for controlling the web browser through the program. It is functional for all browsers, works on all major OS and its scripts are written in various languages i.e Python, Java, C#, etc, we will be working with Python.
Selenium Python bindings provide a convenient API to access Selenium WebDrivers like Firefox, Ie, Chrome, Remote, etc. The currently supported Python versions are 2.7, 3.5 and above.
Selenium: To install this module type the below command in the terminal.pip install selenium
pip install selenium
Web Drivers: Selenium requires a web driver to interface with the chosen browser.Web drivers is a package to interact with web browser. It interacts with the web browser or a remote web server through a wire protocol which is common to all. You can check out and install the web drivers of your browser choice.Chrome: https://sites.google.com/a/chromium.org/chromedriver/downloadsFirefox: https://github.com/mozilla/geckodriver/releasesSafari: https://webkit.org/blog/6900/webdriver-support-in-safari-10/
Chrome: https://sites.google.com/a/chromium.org/chromedriver/downloadsFirefox: https://github.com/mozilla/geckodriver/releasesSafari: https://webkit.org/blog/6900/webdriver-support-in-safari-10/
This method is used to launch a new browser and will open the given URL in the browser.
Syntax:
driver.get(url) 

Parameters used:The function accept only one argument which is the desired link to be opened as showed in above syntax.
Example:
#importing webdriver from seleniumfrom selenium import webdriver   #selecting Firefox as the browser#in order to select Chrome # webdriver.Chrome() will be useddriver = webdriver.Firefox(executable_path = '/path/to/geckodriver')   #URL of the website url = "https://www.geeksforgeeks.org/"   #opening link in the browserdriver.get(url)
Output:
python-modules
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Convert integer to string in Python
Python | os.path.join() method
Python OOPs Concepts
Introduction To PYTHON
Collectors toList() method in Java with Examples

06 Dec, 2018
The toList() method of Collectors Class is a static (class) method. It returns a Collector Interface that gathers the input data onto a new list. This method never guarantees type, mutability, serializability, or thread-safety of the returned list but for more control toCollection(Supplier) method can be used. This is an un-ordered collector.
Syntax:
public static  Collector<T, ?, R> toList()
where:
T: The type of the input elements.
Interface Collector<T, A, R>: A mutable reduction operation that accumulates input elements into a mutable result container, optionally transforming the accumulated result into a final representation after all input elements have been processed. Reduction operations can be performed either sequentially or in parallel.T: The type of input elements to the reduction operation.A: The mutable accumulation type of the reduction operation.R: The result type of the reduction operation.
T: The type of input elements to the reduction operation.
A: The mutable accumulation type of the reduction operation.
R: The result type of the reduction operation.
toList():- Static method of Collectors class and returns a Collector interface object used to store a group of data onto a list. The Collectors class is under the java.util.streams package.
Return Value: This method returns a Collector which collects all the input elements into a List, in encounter order
Below are the examples to illustrate toList() method in Java:
Example 1:
// Java code to show the implementation of// Collectors toList() function  import java.util.List;import java.util.stream.Collectors;import java.util.stream.Stream;  class GFG {      // Driver code    public static void main(String[] args)    {        // creating a Stream of strings        Stream<String> s = Stream.of("Geeks",                                     "for",                                     "GeeksforGeeks",                                     "Geeks Classes");          // using Collectors toList() function        List<String> myList = s.collect(Collectors.toList());          // printing the elements        System.out.println(myList);    }}
[Geeks, for, GeeksforGeeks, Geeks Classes]

Example 2:
// Java code to show the implementation of// Collectors toList() function  import java.util.List;import java.util.stream.Collectors;import java.util.stream.Stream;  class GFG {      // Driver code    public static void main(String[] args)    {          // creating a Stream of strings        Stream<String> s = Stream.of("1", "2", "3", "4");          // using Collectors toList() function        List<String> myList = s.collect(Collectors.toList());          // printing the elements        System.out.println(myList);    }}
[1, 2, 3, 4]

Java - util package
Java-Collections
Java-Collectors
Java-Functions
java-stream
Java-Stream-Collectors
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Sort and store files with same extension

29 Dec, 2020
Have you ever wanted to find any particular file in a folder, but then completely freak out when you find that folder to be a hell of a mess? Well, Python is a rescue here.Using Python OS-module and shutil module, we can organize the files with same extensions and store in separate folders.
Look at the image shown below –
This folder is fully unorganized. If you are told to find a particular file in this folder (or maybe an even larger folder with thousands of files), you will be stuck and become completely dumbstruck. It might be very tough (even impossible) to find a file from this ocean of mess. This problem can be solved using Python with a few lines of code. Let’s see how can we do this.
Below is the Python implementation –
import osimport shutil   # Write the name of the directory here,# that needs to get sortedpath = '/path/to/directory'    # This will create a properly organized # list with all the filename that is# there in the directorylist_ = os.listdir(path)   # This will go through each and every filefor file_ in list_:    name, ext = os.path.splitext(file_)      # This is going to store the extension type    ext = ext[1:]      # This forces the next iteration,    # if it is the directory    if ext == '':        continue      # This will move the file to the directory    # where the name 'ext' already exists    if os.path.exists(path+'/'+ext):       shutil.move(path+'/'+file_, path+'/'+ext+'/'+file_)      # This will create a new directory,    # if the directory does not already exist    else:        os.makedirs(path+'/'+ext)        shutil.move(path+'/'+file_, path+'/'+ext+'/'+file_)
Output:
Python file-handling-programs
python-file-handling
Python-sort
python-utility
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python Program for Fibonacci numbers
CSS border Property - GeeksforGeeks

02 Nov, 2021
The border property in CSS is used to style the border of an element. This property is a combination of three other properties border-width, border-style, and border-color as can be used as a shorthand notation for these three properties. It sets or returns the border-width, border-style, border-color Properties. Syntax:  
border = "width style color|initial|inherit"
Default Value : Its default value is initial.
Property Values:  
width: This value specifies the weight or the width of the border.
style: This value specifies a style for the border, that is whether the border will be dotted, dashed, solid etc.
color: This value specifies the color of the border.
Below code illustrate the border property in CSS: Example:  
html
<!DOCTYPE html><html> <head>    <title>        CSS | border Property    </title>    <style>        h1 {            color: green;        }                 #gfg {            border: 4px solid blue;            width: 60%;        }    </style></head> <body>    <center>        <h1>GeeksForGeeks</h1>         <h2>DOM Style border Property</h2>         <!-- Element whose border will be styled -->        <div id="gfg">            GeeksForGeeks.            It is a computer science portal for geeks.        </div>    </center></body> </html>              
Output:  
Supported Browsers: The browser supported by CSS border property are listed below:  
Google Chrome 1.0
Internet Explorer 4.0
Firefox 1.0
Opera 3.5
Apple Safari 1.0
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
hritikbhatnagar2182
CSS-Properties
CSS
HTML
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to create footer to stay at the bottom of a Web page?
How to apply style to parent if it has child with CSS?
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
Hide or show elements in HTML using display property
ascii() in Python - GeeksforGeeks

13 Sep, 2021
Python ascii() function returns a string containing a printable representation of an object and escapes the non-ASCII characters in the string using \x, \u or \U escapes. 
Syntax: ascii(object)
The method can take only one parameter, an object that can be a list, strings, etc. As already discussed, it returns a printable representation of an object.  
Input : ascii("¥")
Output : '\xa5'

Input : ascii("μ")
Output : '\xb5'

Input : ascii("Ë")
Output : '\xcb'
We see that in these examples, all the non-ASCII characters have been escaped, i.e, their encoded code gets displayed by using the ascii() method.
Example 1:
In this example, str contains not-ASCII character and our task is to display its ASCII value from the given string.
Python3
# Python program to illustrate ascii()str = "G ë ê k s f ? r G ? e k s"print (ascii(str))
Output: 
'G \xeb \xea k s f ? r G ? e k s'
Example 2:
Here we take variable with multiline string and pass it into the ascii() and it returns “\n”, the value of new line is “\n”.
Python3
str = '''Geeksforgeeks'''print(ascii(str))
Output:
'Geeks\nfor\ngeeks'
Here we will see the difference between ascii() function and the print() function. For this, we have taken variables with multiline string and try to display them with both functions. After code execution, you will get different output, because ascii() function escapes the non-ASCII character while the print function print does not escape this value.
Python3
str = '''Geeksforgeeks'''print("Display with ascii function : ",ascii(str))print("Display with print function : ",str)
Output:
Display with ascii function :  'Geeks\nfor\ngeeks'
Display with print function :  Geeks
for
geeks
This article is contributed by Chinmoy Lenka. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to review-team@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
code_24x7
kumar_satyam
ASCII
Python-Built-in-functions
Python-Library
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
sum() function in Python
How to Get a Total Number of Days in a Month using built in Functions in C#? - GeeksforGeeks

28 May, 2020
Given a year Y and month M, the task is to get a total number of days in a month in C#.
Examples:
Input: Y = 2020 N = 02
Output: 29
  
Input: Y = 1996 N = 06
Output: 30

Method 1: Using DateTime.DaysInMonth(year, month) Method: This method is used to get the number of days in the specified month and year.
Step 1: Get the year and month.
Step 2: The DateTime.DaysInMonth() is used to get the number of days in a month
int days = DateTime.DaysInMonth(year, month);;

Step 3: This integer value is the number of days in the month.
Below is the implementation of the above approach:
C#
// C# program to Get a Total Number// of Days in a Monthusing System;     public class GFG{           // function to get the full month name     static int getdays(int year, int month)      {         int days = DateTime.DaysInMonth(year, month);                  return days;    }           static public void Main ()     {          int Y = 2020; // year        int M = 02; // month                  Console.WriteLine("Total days in ("        + Y + "/" + M + ") : "+ getdays(Y, M));     }  }
Output:
Total days in (2020/2) : 29

Method 2: Using CultureInfo.CurrentCulture.Calendar.GetDaysInMonth(year,month) Method: This method is used to get the number of days in the specified month and year. You need to use  System.Globalization namespace.
Step 1: Get the year and month.
Step 2: The CultureInfo.CurrentCulture.Calendar.GetDaysInMonth() is used to get the number of days in a month
int days = CultureInfo.CurrentCulture.Calendar.GetDaysInMonth(year, month);;

Step 3: This integer value is the number of days in the month.
Below is the implementation of the above approach:
C#
// C# program to Get a Total Number// of Days in a Monthusing System; using System.Globalization;    public class GFG{           // function to get the full month name     static int getdays(int year, int month)      {         int days = CultureInfo.CurrentCulture.        Calendar.GetDaysInMonth(year, month);                  return days;    }           static public void Main ()     {          int Y = 2020; // year        int M = 02; // month                  Console.WriteLine("Total days in ("        + Y + "/" + M + ") : "+ getdays(Y, M)        + " days");     }  }
Output:
Total days in (2020/2) : 29 days

C#
C# Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C# | Delegates
C# | Abstract Classes
Extension Method in C#
Introduction to .NET Framework
C# | String.IndexOf( ) Method | Set - 1
Convert String to Character Array in C#
Program to Print a New Line in C#
Getting a Month Name Using Month Number in C#
Socket Programming in C#
C# Program for Dijkstra's shortest path algorithm | Greedy Algo-7
Python | Pandas DatetimeIndex.inferred_freq - GeeksforGeeks

24 Dec, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas DatetimeIndex.inferred_freq attribute tries to return a string representing a frequency guess, generated by infer_freq. For those cases in which the function is not able to auto detect the frequency of the DatetimeIndex it returns None.
Syntax: DatetimeIndex.inferred_freq
Return: freq
Example #1: Use DatetimeIndex.inferred_freq attribute to auto detect the frequency of the given DatetimeIndex object.
# importing pandas as pdimport pandas as pd  # Create the DatetimeIndexdidx = pd.date_range("2008-12-30", periods = 5, freq ='Q')  # Print the DatetimeIndexprint(didx)
Output :
Now we want the function to auto detect the frequency of the given DatetimeIndex object.
# find the frequency of the object.didx.inferred_freq
Output :
As we can see in the output, the function has tried to auto detect the frequency of the given DatetimeIndex object and has returned a quarter type frequency starting from the month of December. Example #2: Use DatetimeIndex.inferred_freq attribute to auto detect the frequency of the given DatetimeIndex object.
# importing pandas as pdimport pandas as pd  # Create the DatetimeIndexdidx = pd.DatetimeIndex(start ='2000-01-31 06:30', freq ='BM',                            periods = 5, tz ='Asia/Calcutta')  # Print the DatetimeIndexprint(didx)
Output :
Now we want the function to auto detect the frequency of the given DatetimeIndex object.
# find the frequency of the object.didx.inferred_freq
Output :As we can see in the output, the function has tried to auto detect the frequency of the given DatetimeIndex object and has returned ‘BM’ (Business Month end) frequency.
Python pandas-datetimeIndex
Python-pandas
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
How to get a variable name as a string in Python?

This isn't really something you do in Python as variables are actually name mappings to objects. The only objects in Python that have canonical names are modules, functions, and classes, and of course there is no guarantee that this canonical name has any meaning in any namespace after the function or class has been defined or the module imported. These names can also be modified after the objects are created so they may not always be particularly trustworthy.
There are still ways to get the name of a variable as string. You need to know the string of the variable name to extract it though. Also this is a reverse search for the variable name. Soif you have 2 variables having the same value, it might return either of them. The iteritems returns the list of all variables in the scope with their values. For example,
>>> my_var = 5
>>> my_var_name = [ k for k,v in locals().iteritems() if v == my_var][0]
>>> my_var_name
'my_var'
HTML DOM Input Password maxLength Property

The HTML DOM Input Password maxlength property is used for setting or returning the maxlength attribute of the input password field. The maxLength property specifies the maximum number of characters you can type in a password field.
Following is the syntax for −
Setting the maxLength property −
passwordObject.maxLength = integer
Here, integer specifies the maximum number of characters that can be typed in the password field.
Let us look at an example for the maxLength form property −
Live Demo
<!DOCTYPE html>
<html>
<body>
<h1>Input Password maxLength Property</h1>
Password: <input type="password" id="PASS" maxLength="5">
<p>Increase the maximum number of characters to be entered for the above field by clicking below button</p>
<button onclick="changeMax()">CHANGE LENGTH</button>
<p id="Sample"></p>
<script>
   function changeMax() {
      document.getElementById("PASS").maxLength = "15";
      document.getElementById("Sample").innerHTML = "Maximum number of characters are now increased to 15";
   }
</script>
</body>
</html>
This will produce the following output −
On clicking the CHANGE LENGTH and entering more characters −
In the above example
We have first created an input password field with id “PASS” and having its maxLength attribute value set to 5. This means only 5 characters can be entered in this field.
Password: <input type="password" id="PASS" maxLength=”5”>
We have then created a button CHANGE LENGTH that will execute the changeMax() method when clicked by the user −
<button type="button" onclick="changeMax()">CHANGE LENGTH</button>
The changeMax() method uses the getElementById() method to get the input field with type password and sets it maxLength property to 15. We then show this change by displaying a message in the paragraph with id “Sample” using its innerHTML property −
function changeMax() {
   document.getElementById("PASS").maxLength = "15";
   document.getElementById("Sample").innerHTML = "Maximum number of characters are now increased to 15";
}
C++17 If statement with initializer

C++17 has extended existing if statement’s syntax. Now it is possible to provide initial condition within if statement itself. This new syntax is called "if statement with initializer". This enhancement simplifies common code patterns and helps users keep scopes tight. Which in turn avoids variable leaking outside the scope.
Let us suppose we want to check whether given number is even or odd. Before C++17 our code used to look like this −
 Live Demo
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
   srand(time(NULL));
   int random_num = rand();
   if (random_num % 2 == 0) {
      cout << random_num << " is an even number\n";
   } else {
      cout << random_num << " is an odd number\n";
   }
   return 0;
}
When you compile and execute the above code it will generate output something like this −
1555814729 is an odd number
In the above example, we can see that variable "random_num" is leaked outside the if-else scope. We can easily avoid this with new "if statement with initializer" syntax.
Below is the syntax of "if statement with initializer" −
if (init; condition) {
   // Do stuff when Boolean condition is true
} else {
   // Do stuff when Boolean condition is false
}
Now let us write same code using this new if statement with initializer −
 Live Demo
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
   srand(time(NULL));
   // C++17 if statement with initializer
   if (int random_num = rand(); random_num % 2 == 0) {
      cout << random_num << " is an even number\n";
   } else {
      cout << random_num << " is an odd number\n";
   }
   return 0;
}
In above example, scope of variable "random_num" is limited to if-else block. Hence this variable won't be accessible outside this block. Surprisingly it keeps variables scope tight without affecting actual output.
When you compile and execute above code it will generate output something like this −
943513352 is an even number
NOTE − As we are generating random number each time output will vary for each run even on same machine.
Firebase - Write Data

In this chapter, we will show you how to save your data to Firebase.
The set method will write or replace data on a specified path. Let us create a reference to the player’s collection and set two players.
var playersRef = firebase.database().ref("players/");

playersRef.set ({
   John: {
      number: 1,
      age: 30
   },
	
   Amanda: {
      number: 2,
      age: 20
   }
});
We will see the following result.
We can update the Firebase data in a similar fashion. Notice how we are using the players/john path.
var johnRef = firebase.database().ref("players/John");

johnRef.update ({
   "number": 10
});
When we refresh our app, we can see that the Firebase data is updating.

    60 Lectures 
     5 hours 

 University Code

    28 Lectures 
     2.5 hours 

 Appeteria

    85 Lectures 
     14.5 hours 

 Appeteria

    46 Lectures 
     2.5 hours 

 Gautham Vijayan

    13 Lectures 
     1.5 hours 

 Nishant Kumar

    85 Lectures 
     16.5 hours 

 Rahul Agarwal
 Print
 Add Notes
 Bookmark this page
How to get server_id in MySQL?

To get the server_id, use the system defined variable @@server_id. You cannot use only a single @ as user defined variable for server_id.
The syntax is as follows
SELECT@@ server_id
As an alternate, you can use SHOW VARIABLES command.
The syntax is as follows
SHOW VARIABLES LIKE ‘server_id’;
Case 1The query is as follows
mysql> SELECT @@server_id as SERVER_ID;
The following is the output
+-----------+
| SERVER_ID |
+-----------+
|         1 |
+-----------+
1 row in set (0.00 sec)
Case 2The query is as follows
mysql> show variables like 'server_id';
The following is the output
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id     | 1     |
+---------------+-------+
1 row in set (0.01 sec)
Network Programming Python - HTTP Clients - GeeksforGeeks

25 Oct, 2020
The request from the client in HTTP protocol reaches the server and fetches some data assuming it to be a valid request. This response from the server can be analyzed by using various methods provided by the requests module. Some of the ways below provide information about the response sent from the server to the Python program running on the client-side :
The get() method is used to get the basic information of the resources used at the server-side. This function fetches the data from the server and returns as a response object which can be printed in a simple text format.
Python3
# Import librariesimport requests  # Sending Requestreq = requests.get('https://www.geeksforgeeks.org/')  # Show resultsprint(req.text[:2000])
Output:
The session() method returns the session object which provides certain parameters to manipulate the requests. It can also manipulate cookies for all the requests initiated from the session object. If a large amount of requests are made to a single host then, the associated TCP connection is recalled.
Python3
# Import Librariesimport requests  # Creating Sessions = requests.Session()s.get('http://httpbin.org/cookies/set/sessioncookie/419735271')  # Getting Responser = s.get('http://httpbin.org/cookies')  # Show Responseprint(r.text)
Output:
{
  "cookies": {
    "sessioncookie": "419735271"
  }
}

If some error is raised in processing the request to the server, the exception is raised by the program which can be handled using the timeout attribute, which defines the time value until the program waits and after that, it raises the timeout error.
Python3
# Import Librariesimport requests  # Error Handlingtry:          # Creating Request    req = requests.get('https://www.geeksforgeeks.org/', timeout=0.000001)      except requests.exceptions.RequestException as e:          # Raising Error    raise SystemExit(e)
Output:
HTTPSConnectionPool(host=’www.geeksforgeeks.org’, port=443): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000018CFDAD83C8>, ‘Connection to www.geeksforgeeks.org timed out. (connect timeout=1e-06)’))
Python-Networking
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python OOPs Concepts
How to Install PIP on Windows ?
Bar Plot in Matplotlib
Defaultdict in Python
Python Classes and Objects
Deque in Python
Check if element exists in list in Python
How to drop one or multiple columns in Pandas Dataframe
Python - Ways to remove duplicates from list
Class method vs Static method in Python
Python program to find the length of the largest consecutive 1's in Binary Representation of a given string.

Given the number, find length of the longest consecutive 1's in its binary representation.
Input: n = 15
Output: 4
The binary representation of 14 is 1111.

Step 1: input the number.
Step 2: use one counter variable c=0.
Step 3: Count the number of iterations to reach i = 0.
Step 4: This operation reduces length of every sequence of 1s by one.

# Python program to find
# length of the longest
# consecutive 1s in
# binary representation of a number.
def maxlength(n):
   # Initialize result
   c = 0
   # Count the number of iterations to
   # reach x = 0.
   while (n!=0):
      # This operation reduces length
      # of every sequence of 1s by one.
      n = (n & (n << 1))
      c=c+1
   return c
# Driver code
n=int(input("Enter The Number ::>"))
print("Maximum Length of 1's ::>",maxlength(n))
Enter The Number ::>15
Maximum Length of 1's ::>4
Aptitude | GATE CS 1998 | Question 49 - GeeksforGeeks

12 Oct, 2017
Let A be a two dimensional array declared as follows:
A: array [1 ... 10] [1 ... 15] of integer;
Assuming that each integer takes one memory location, the array is stored in row-major order and the first element of the array is stored at location 100, what is the address of the element a[i][j] ?(A) 15i+ j+ 84(B) 15j+ i+ 84(C) 10i+ j+ 89(D) 10j+ i+ 89Answer: (A)Explanation:Quiz of this QuestionPlease comment below if you find anything wrong in the above post
Aptitude
Aptitude-GATE CS 1998
GATE CS 1998
Aptitude
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Puzzle | How much money did the man have before entering the bank?
Order and Ranking Questions & Answers
7 Best Tips to Prepare for Aptitude Test For Campus Placements
Puzzle | Splitting a Cake with a Missing Piece in two equal portion
Geometry and Co-ordinates
Aptitude | Arithmetic Aptitude 5 | Question 1
Aptitude | Arithmetic Aptitude | Question 4
Aptitude | Arithmetic Aptitude | Question 1
Average of Cubes of first N natural numbers
C | C Quiz - 113 | Question 1
Add top rounded corners to an element in Bootstrap 4

To add top rounded corners to an element, use the rounded-top class in Bootstrap 4.
I have taken div as the element −
<div class="new rounded-top"></div>
Let us learn how to add top rounded corners to an element −
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>
    <style>
    .new {
      width: 80px;
      height: 80px;
      background-color: #EE6D1E;
      margin: 20px;
    }
    </style>
  </head>
<body>
  <div class="container">
    <h2>Rounded Corner</h2>
    <p>We have a rectangle with top rounded corner:</p>
    <div class="new rounded-top"></div>
  </div>

</body>
</html>
Circuit Rank

Let 'G' be a connected graph with 'n' vertices and 'm' edges. A spanning tree 'T' of G contains (n-1) edges.
Therefore, the number of edges you need to delete from 'G' in order to get a spanning tree = m-(n-1), which is called the circuit rank of G.
This formula is true, because in a spanning tree you need to have 'n-1' edges. Out of 'm' edges, you need to keep 'n–1' edges in the graph.
Hence, deleting 'n–1' edges from 'm' gives the edges to be removed from the graph in order to get a spanning tree, which should not form a cycle.
Take a look at the following graph −
For the graph given in the above example, you have m=7 edges and n=5 vertices.
Then the circuit rank is
G = m – (n – 1)
= 7 – (5 – 1)
= 3
Let 'G' be a connected graph with six vertices and the degree of each vertex is three. Find the circuit rank of 'G'.
By the sum of degree of vertices theorem,
6 × 3 = 2|E|
|E| = 9
Circuit rank = |E| – (|V| – 1)
= 9 – (6 – 1) = 4
How to find the row-wise frequency of zeros in an R data frame?

In data analysis, we need to be very cautious about repeated values because they might be inputted purposely to create bias in the data and this value could be a zero as well. It happens in situations when we have missing data and the data collector replaces missing values with zeros which is a wrong practice. To find the row-wise frequency of zeros in an R data frame, we can use rowSums function for zero values by using the syntax −
rowSums(“data_frame_name”==0)
Consider the below data frame −
 Live Demo
set.seed(189)
x1<-sample(0:1,20,replace=TRUE)
x2<-sample(0:5,20,replace=TRUE)
x3<-sample(0:2,20,replace=TRUE)
x4<-sample(0:1,20,replace=TRUE)
x5<-sample(0:5,20,replace=TRUE)
x6<-sample(0:10,20,replace=TRUE)
df1<-data.frame(x1,x2,x3,x4,x5,x6) df1
  x1 x2  x3 x4 x5 x6
1  1  5  2   1  3  1
2  1  3  0   0  5  2
3  1  2  2  1  2   5
4  1  4  0  0  0   7
5  0  0  2  0  5   0
6  0  5  1  1  2   5
7  0  5  1  1  1   6
8  0  4  1  0  3   1
9  0  4  1  1  3   4
10 0  1  2  0  4   5
11 1 1  2  0   4   0
12 1  2  0  0  5   1
13 1  3  0  0  1   5
14 1  0  0  0  5   1
15 0 3  0  1  5   10
16 0 3  2  1  3    2
17 1 3  0  1  1    7
18 0 3  1  1  2    9
19 1 3  2  0 3     5
20 1 4  0  1 2     1
Counting number of zeros in each row −
df1$Zeros<-rowSums(df1==0)
df1
x1 x2 x3 x4 x5 x6 Zeros
1 0 1 1 0 4 3 2
2 0 4 2 1 4 10 1
3 0 3 2 0 0 3 3
4 0 5 0 0 4 4 3
5 1 1 1 0 3 6 1
6 1 2 1 1 4 5 0
7 1 0 2 0 0 4 3
8 1 0 0 1 3 2 2
9 0 2 0 0 5 1 3
10 0 4 1 1 4 2 1
11 0 3 0 0 1 3 3
12 0 0 0 0 1 5 4
13 1 2 0 1 5 8 1
14 1 1 2 1 1 10 0
15 1 3 0 1 4 6 1
16 1 5 2 0 0 8 2
17 0 1 2 0 0 4 3
18 0 5 2 1 3 1 1
19 1 2 2 0 0 2 2
20 1 3 2 1 3 4 0
Let’s have a look at another example −
 Live Demo
y1<-sample(0:2,20,replace=TRUE)
y2<-sample(0:1,20,replace=TRUE)
y3<-sample(0:5,20,replace=TRUE)
y4<-sample(0:4,20,replace=TRUE)
y5<-sample(0:1,20,replace=TRUE)
y6<-sample(0:5,20,replace=TRUE)
y7<-sample(0:10,20,replace=TRUE)
df2<-data.frame(y1,y2,y3,y4,y5,y6)
df2
y1 y2 y3 y4 y5 y6
1 2 1 1 1 0 1
2 0 1 3 1 0 3
3 0 1 5 0 1 1
4 2 1 5 2 1 4
5 0 0 5 0 0 0
6 0 0 1 0 1 4
7 1 0 0 4 1 2
8 0 1 3 1 0 1
9 1 0 4 2 0 1
10 0 0 2 3 0 5
11 2 1 3 2 0 5
12 1 1 5 4 0 2
13 2 0 2 1 0 2
14 2 0 2 4 1 0
15 0 1 3 3 0 1
16 0 1 4 0 1 0
17 1 0 5 2 1 4
18 1 1 3 1 1 0
19 1 1 4 4 1 2
20 2 0 1 1 0 3
Counting number of zeros in each row −
df2$No_of_Zeros <-rowSums(df2==0) df2
  y1 y2 y3 y4 y5 y6    No_of_Zeros
1  1  0  2   0  1 5 2
2  1  1  0   3 1 2  1
3  1  1 3    4 1 5 0
4  0  1  0   1 0 0 4
5  1  0  2   1 1 2 1
6  1  1  0   4 1 0 2
7  2  1  0   2 0 3 2
8  1  1  3   2 0 1 1
9  2  0  2   0 0 4 3
10 2  1  1   2 0 5 1
11 0  0  1   4 1 3 2
12 2  1  4   3 0 1 1
13 1  1  3   3 0 1 1
14 1  0  3   2 0 0 3
15 0  1  1   0 0 2 3
16 1  0  5   0 1 5 2
17 0  1 0    3 1 5 2
18 2  1 0    3 1 0 2
19 2  0 0    0 0 5 4
20 1  1 5    4 1 4 0
Group MySQL rows in an array by column value?

To group rows in an array, use GROUP_CONCAT() along with the ORDER BY clause. Let us first create a table −
mysql> create table DemoTable
   -> (
   -> Id int,
   -> FirstName varchar(20)
   -> );
Query OK, 0 rows affected (0.78 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(101,'John');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values(102,'Bob');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable values(101,'David');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable values(101,'Adam');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable values(102,'Chris');
Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+------+-----------+
| Id   | FirstName |
+------+-----------+
|  101 | John      |
|  102 | Bob       |
|  101 | David     |
|  101 | Adam      |
|  102 | Chris     |
+------+-----------+
5 rows in set (0.00 sec)
Here is the query to group MySQL rows in an array by column value −
mysql> select Id,group_concat(FirstName separator ',') from DemoTable
   -> group by Id
   -> order by count(Id);
This will produce the following output −
+------+---------------------------------------+
| Id   | group_concat(FirstName separator ',') |
+------+---------------------------------------+
|  102 | Bob,Chris                             |
|  101 | John,David,Adam                       |
+------+---------------------------------------+
2 rows in set (0.00 sec)
Convert.ToBoolean(String, IFormatProvider) Method in C#

The Convert.ToBoolean() method in C# is used to convert a specified value to an equivalent Boolean value.
Following is the syntax −
public static bool ToBoolean (string val, IFormatProvider provider);
Above, Val is a string that contains the value of either TrueString or FalseString, whereas the provider is an object that supplies culture-specific formatting information.
Let us now see an example to implement the Convert.ToBoolean() method −
using System;
using System.Globalization;
public class Demo {
   public static void Main(){
      CultureInfo cultures = new CultureInfo("en-US");
      String str = "true";
      Console.WriteLine("Converted bool value...");
      bool res = Convert.ToBoolean(str, cultures);
      Console.Write("{0}", res);
   }
}
This will produce the following output −
Converted bool value...
True
How to find records with a null value in a set of columns with MySQL

For this, use the concept of GREATEST(). Let us first create a table −
mysql> create table DemoTable1862
     (
     Value1 int,
     Value2 int,
     Value3 int,
     Value4 int
     );
Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1862 values(43,34,56,42);
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1862 values(NULL,78,65,NULL);
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1862 values(110,NULL,78,NULL);
Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1862;
This will produce the following output −
+--------+--------+--------+--------+
| Value1 | Value2 | Value3 | Value4 |
+--------+--------+--------+--------+
|     43 |     34 |     56 |     42 |
|   NULL |     78 |     65 |   NULL |
|    110 |   NULL |     78 |   NULL |
+--------+--------+--------+--------+
3 rows in set (0.00 sec)
Here is the query to find records with a null value in a set of columns −
mysql> select * from DemoTable1862 where greatest(Value1,Value2,Value3,Value4) IS NULL;
This will produce the following output −
+--------+--------+--------+--------+
| Value1 | Value2 | Value3 | Value4 |
+--------+--------+--------+--------+
|   NULL |     78 |     65 |   NULL |
|    110 |   NULL |     78 |   NULL |
+--------+--------+--------+--------+
2 rows in set (0.00 sec)