code-rag-bench/online-tutorials huggingface dataset:
Python | Measure similarity between two sentences using cosine similarity

10 Jul, 2020
Cosine similarity is a measure of similarity between two non-zero vectors of an inner product space that measures the cosine of the angle between them.Similarity = (A.B) / (||A||.||B||) where A and B are vectors.
Cosine similarity and nltk toolkit module are used in this program. To execute this program nltk must be installed in your system. In order to install nltk module follow the steps below –
1. Open terminal(Linux).
2. sudo pip3 install nltk
3. python3
4. import nltk
5. nltk.download(‘all’)
Functions used:
nltk.tokenize: It is used for tokenization. Tokenization is the process by which big quantity of text is divided into smaller parts called tokens. word_tokenize(X) split the given sentence X into words and return list.
nltk.corpus: In this program, it is used to get a list of stopwords. A stop word is a commonly used word (such as “the”, “a”, “an”, “in”).
# Program to measure the similarity between # two sentences using cosine similarity.from nltk.corpus import stopwordsfrom nltk.tokenize import word_tokenize  # X = input("Enter first string: ").lower()# Y = input("Enter second string: ").lower()X ="I love horror movies"Y ="Lights out is a horror movie"  # tokenizationX_list = word_tokenize(X) Y_list = word_tokenize(Y)  # sw contains the list of stopwordssw = stopwords.words('english') l1 =[];l2 =[]  # remove stop words from the stringX_set = {w for w in X_list if not w in sw} Y_set = {w for w in Y_list if not w in sw}  # form a set containing keywords of both strings rvector = X_set.union(Y_set) for w in rvector:    if w in X_set: l1.append(1) # create a vector    else: l1.append(0)    if w in Y_set: l2.append(1)    else: l2.append(0)c = 0  # cosine formula for i in range(len(rvector)):        c+= l1[i]*l2[i]cosine = c / float((sum(l1)*sum(l2))**0.5)print("similarity: ", cosine)
Output:
similarity:  0.2886751345948129

Natural-language-processing
Python-nltk
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ML | Linear Regression
Reinforcement learning
Supervised and Unsupervised learning
Decision Tree Introduction with example
Search Algorithms in AI
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
numpy.roots() function – Python

11 Jun, 2020
numpy.roots() function return the roots of a polynomial with coefficients given in p. The values in the rank-1 array p are coefficients of a polynomial. If the length of p is n+1 then the polynomial is described by: p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]
Syntax : numpy.roots(p)
Parameters :p : [array_like] Rank-1 array of polynomial coefficients.
Return : [ndarray] An array containing the roots of the polynomial.
Code #1 :
# Python program explaining# numpy.roots() function      # importing numpy as geek import numpy as geek   p = [1, 2, 3]  gfg = geek.roots(p)  print (gfg)
Output :
[-1.+1.41421356j -1.-1.41421356j]

 Code #2 :
# Python program explaining# numpy.roots() function       # importing numpy as geek import numpy as geek    p = [3.2, 2, 1]   gfg = geek.roots(p)   print (gfg)
Output :
[-0.3125+0.46351241j -0.3125-0.46351241j]

Python-numpy
Python
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
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Iterate over a list in Python
Convert integer to string in Python
Get n-smallest values from a particular column in Pandas DataFrame

18 Dec, 2018
Pandas DataFrame is two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns).
Let’s see how can we can get n-smallest values from a particular column in Pandas DataFrame.
Observe this dataset first. We’ll use ‘Age’, ‘Weight’ and ‘Salary’ columns of this data in order to get n-smallest values from a particular column in Pandas DataFrame.
# importing pandas module import pandas as pd     # making data frame df = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv")   df.head(10)
Code #1: Getting 5 smallest Age
# importing pandas module import pandas as pd     # making data frame df = pd.read_csv("nba.csv")     df.nsmallest(5, ['Age'])
Output: 
Code #2: Getting 10 minimum weights
# importing pandas module import pandas as pd     # making data frame df = pd.read_csv("nba.csv")     df.nsmallest(10, ['Weight'])
Output: 
Code #3: Getting 10 minimum salary
# importing pandas module import pandas as pd     # making data frame df = pd.read_csv("nba.csv")     df.nsmallest(5, ['Salary'])
Output:
pandas-dataframe-program
Python pandas-dataFrame
Python-pandas
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 | os.path.join() method
Python OOPs Concepts
How to drop one or multiple columns in Pandas Dataframe
Introduction To PYTHON
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
Ruby | Array size() operation

06 Dec, 2019
Array#size() : size() is a Array class method which returns the length of elements in the array.
Syntax: Array.size()
Parameter: Array
Return: the length of elements in the array.
Example #1 :
# Ruby code for size() method  # declaring arraya = [18, 22, 33, nil, 5, 6]  # declaring arrayb = [1, 4, 1, 1, 88, 9]  # declaring arrayc = [18, 22, 50, 6]  # size method exampleputs "size() method form : #{a.size()}\n\n"  puts "size() method form : #{b.size()}\n\n"  puts "size() method form : #{c.size()}\n\n"
Output :
size() method form : 6

size() method form : 6

size() method form : 4


Example #2 :
# Ruby code for size() method  # declaring arraya = ["abc", "nil", "dog"]  # declaring arrayc = ["cat", nil]  # declaring arrayb = ["cow", nil, "dog"]    # size method exampleputs "size() method form : #{a.size()}\n\n"  puts "size() method form : #{b.size()}\n\n"  puts "size() method form : #{c.size()}\n\n"
Output :
size() method form : 3

size() method form : 3

size() method form : 2


Ruby Array-class
Ruby-Methods
Ruby
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Parameter-Ordered Updates

The UPDATE query of raw SQL has SET clause. It is rendered by the update() construct using the column ordering given in the originating Table object. Therefore, a particular UPDATE statement with particular columns will be rendered the same each time. Since the parameters themselves are passed to the Update.values() method as Python dictionary keys, there is no other fixed ordering available.
In some cases, the order of parameters rendered in the SET clause are significant. In MySQL, providing updates to column values is based on that of other column values.
Following statement’s result −
UPDATE table1 SET x = y + 10, y = 20
will have a different result than −
UPDATE table1 SET y = 20, x = y + 10
SET clause in MySQL is evaluated on a per-value basis and not on per-row basis. For this purpose, the preserve_parameter_order is used. Python list of 2-tuples is given as argument to the Update.values() method −
stmt = table1.update(preserve_parameter_order = True).\
   values([(table1.c.y, 20), (table1.c.x, table1.c.y + 10)])
The List object is similar to dictionary except that it is ordered. This ensures that the “y” column’s SET clause will render first, then the “x” column’s SET clause.
p5.js | loadImage() Function

17 Jan, 2020
The loadImage() function is used to load an image from the given path and create a p5.Image object with the image.
It is advised to load an image in the preload() function as the loaded image may not be available for use immediately. The image is preferably loaded from a relative path as some browsers may prevent loading from other remote locations due to the browser’s security features.
Syntax:
loadImage(path, successCallback, failureCallback)
Parameters: This function accepts three parameter as mentioned above and described below.
path: This is the path from where the image is to be loaded.
successCallback: This is a function which is called if the image successfully loads and it is an optional parameter.
failureCallback: This is a function which is called if the image does not load due to any error and it is an optional parameter.
Below examples illustrates the loadImage() function in p5.js:
Example 1: This example shows the loading of image in preload().
let img;  function preload() {  img = loadImage('sample-image.png');}  function setup() {  createCanvas(300, 200);    text("The image would be loaded below:", 20, 20);  image(img, 20, 40, 100, 100);}
Output:
Example 2: This example shows loading an image from a URL and both callbacks that may take place.
let img;let url = 'https://media.geeksforgeeks.org/wp-content/uploads/20190314004249/sample-image.png';  function setup() {  createCanvas(400, 200);    textSize(18)  text("The image would be loaded below:", 20, 20);    loadImage(url, img => {    image(img, 20, 40, 100, 100);  },    (event) => {      fill("red")      text("Error: The image could not be loaded.", 20, 40);      console.log(event);    }  );}
Output:
Image successfully loads
Image does not load
Online editor: https://editor.p5js.org/Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/
Reference: https://p5js.org/reference/#/p5/loadImage
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Shading confidence intervals manually with ggplot2 in R

30 Jun, 2021
In this article, we will see how to generate Shading confidence intervals manually with ggplot2 in R Programming language. 
Let us first draw a regular curve and then add confidence intervals to it.
Example:
R
# Load Packageslibrary("ggplot2")   # Create a DataFrame for PlottingDF <- data.frame(X = rnorm(10),                                                    Y = rnorm(10))  # Plot the ggplot2 plotggplot(DF, aes(X, Y)) +                                       geom_line(color = "dark green", size = 2)
Output:
LineGraph using ggplot2
To add shading confidence intervals, geom_ribbon() function is used. Which displays a Y interval defined by ymin and ymax. It has aesthetic mappings of ymin and ymax. Other than that it also has some more parameters which are not necessary. 
Syntax : geom_ribbon(mapping, color, fill, linetype, alpha, ...)
Parameters :
mapping : aesthetic created by aes() to define ymin and ymax.
color : Specifies the color of border of the Shading interval.
fill : Specifies the color of Shading Confidence Interval.
linetype : Specifies the linetype of the border of Confidence Interval.
alpha : Specifies the Opacity of the Shading Interval.
... : geom_ribbon also has other parameters such as data, stat, position, show.legend, etc. You can use them as per your requirements but in general case they are not useful as much.
Return : Y interval with the specified range.
Example:
R
# Load Packageslibrary("ggplot2")   # Create DataFrame for PlottingDF <- data.frame(X = rnorm(10),                                                    Y = rnorm(10))  # ggplot2 LineGraph with Shading Confidence Intervalggplot(DF, aes(X, Y)) +                                       geom_line(color = "dark green", size = 2) +  geom_ribbon(aes(ymin=Y+0.5, ymax=Y-0.5), alpha=0.1, fill = "green",               color = "black", linetype = "dotted")
Output:
LineGraph with shading confidence intervals
Picked
R-ggplot
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Split Column Into Multiple Columns in R DataFrame?
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
R - if statement
How to filter R DataFrame by values in a column?
Logistic Regression in R Programming
Replace Specific Characters in String in R
How to import an Excel File into R ?
Joining of Dataframes in R Programming
PLSQL | MOD Function

18 Oct, 2019
The MOD function is an inbuilt function in PLSQL which is used to return the remainder when a is divided by b. Its formula is .
Syntax:
MOD(a, b)
Parameters Used:This function accepts two parameters a and b. This function gives remainder as the output when the input number a is divided by b.
Return Value:This function returns the remainder when a is divided by b.
Supported Versions of Oracle/PLSQL is given below:
Oracle 12cOracle 11gOracle 10gOracle 9iOracle 8i
Oracle 12c
Oracle 11g
Oracle 10g
Oracle 9i
Oracle 8i
Let’s see some examples which illustrate the MOD function:
Example-1:
DECLARE 
   Test_Number number1 := 15;
   Test_Number number2 := 4;
   
BEGIN 
   dbms_output.put_line(MOD(Test_Number number1, 
                            Test_Number number2)); 
   
END;  
Output:
3
In the above example, when the numeric value 15 is divided by 4 then it returns the remainder of 3 as output.
Example-2:
DECLARE 
   Test_Number number1 := 15;
   Test_Number number2 := 0;
   
BEGIN 
   dbms_output.put_line(MOD(Test_Number number1, 
                            Test_Number number2)); 
   
END; 
Output:
15
In the above example, when the numeric value 15 is divided by 0 then it returns the remainder of 15 as output.
Example-3:
DECLARE 
   Test_Number number1 := 11.6;
   Test_Number number2 := 2.1;
   
BEGIN 
   dbms_output.put_line(MOD(Test_Number number1, 
                            Test_Number number2)); 
   
END; 
Output:
1.1
In the above example, when the numeric value 11.6 is divided by 2.1 then it returns the remainder of 1.1 as output.
Advantage:This function is used to find the remainder when a is divided by b.
SQL-PL/SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
CTE in SQL
SQL Trigger | Student Database
SQL Interview Questions
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Views
Difference between DELETE, DROP and TRUNCATE
Window functions in SQL
Difference between DELETE and TRUNCATE
Difference between DDL and DML in DBMS
MySQL | Group_CONCAT() Function
Sum and average of three numbers in PL/SQL

12 Jul, 2018
Prerequisite – PL/SQL introductionIn PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations.
Given three numbers and the task is to find out the sum and average of three numbers.Examples:
Input: a = 12, b = 15, c = 32
Output: sum = 59 avg = 19.66

Input: a = 34, b = 45, c = 11
Output: sum = 90 avg = 30

Approach is to take three numbers and find their sum and average using the formula given below-Sum: Average: Where a,b,c are the three numbers.
Below is the required implementation:
--To find sum and avg of three numbers DECLARE       -- Assigning 12 into a     a     NUMBER := 12;           -- Assigning 14 into b     b     NUMBER := 14;           -- Assigning 20 into c     c     NUMBER := 20;           -- Declare variable for sum      -- Of Three number (a, b, c)     sumOf3 NUMBER;           -- Declare variable for average     avgOf3 NUMBER;       --Start Block BEGIN       -- Assigning sum of a, b and c into sumOf3     sumOf3 := a + b + c;       -- Assigning average  of a, b and c into avgOf3     avgOf3 := sumOf3 / 3;       --print Result  sum of a, b, c number     dbms_output.Put_line('Sum = '                          ||sumOf3);       --print Average  sum of a, b, c number     dbms_output.Put_line('Average = '                          ||avgOf3); END;   --End Program 
Output:
Sum = 46
Average = 15.33

SQL-PL/SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between DELETE, DROP and TRUNCATE
CTE in SQL
Difference between SQL and NoSQL
SQL using Python
Difference between DELETE and TRUNCATE
SQL | DDL, DML, TCL and DCL
Window functions in SQL
How to use SQLMAP to test a website for SQL Injection vulnerability
Introduction to NoSQL
SQL | USING Clause
How to place a button at any position in Tkinter?

24 Jan, 2021
Prerequisite: Creating a button in Tkinter
Tkinter is the most commonly used library for developing GUI (Graphical User Interface) in Python. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with tkinter is the fastest and easiest way to create GUI applications. Creating a GUI using tkinter is an easy task.
Approach:
Import the tkinter module 
Create the main window 
Add a button to the window.
Place the button.
The button in the tkinter module can be placed or move to any position in two ways:
By using the place() method.
And by using the pack() method.
Method 1: Using the place() method
This method is used to place a button at an absolute defined position.
Syntax : button1.place(x=some_value, y=some_value)
Parameters :
x : It defines the x-coordinate of the button’s position.
y : It defines the y-coordinate of the button’s position.
Below is the implementation of the approach shown above:
Python3
# Importing tkinter module from tkinter import *          # Creating a tkinter windowroot = Tk()   # Initialize tkinter window with dimensions 300 x 250             root.geometry('300x250')       # Creating a Buttonbtn = Button(root, text = 'Click me !', command = root.destroy)  # Set the position of button to coordinate (100, 20)btn.place(x=100, y=20)  root.mainloop()
Output:
Method 2: Using the pack() method
This method is used to place a button at a relative position.
Syntax : button1.pack(side=some_side, padx=some_value, pady=some_value)
Parameters :
side : It defines the side where the button will be placed.
padx : It defines the padding on x-axis from the defined side.
pady : It defines the padding on y-axis from tht defines side.
Below is the implementation of the approach shown above:
Python3
# Importing tkinter module from tkinter import *          # Creating a tkinter windowroot = Tk()   # Initialize tkinter window with dimensions 300 x 250             root.geometry('300x250')       # Creating a Buttonbtn = Button(root, text = 'Click me !', command = root.destroy)  # Set a relative position of buttonbtn.pack(side=RIGHT, padx=15, pady=20)  root.mainloop()
Output:
Python-tkinter
Technical Scripter 2020
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
numpy.isinf() in Python

28 Mar, 2022
The numpy.isinf() function tests element-wise whether it is +ve or -ve infinity or not return the result as a boolean array. 
Syntax: numpy.isinf(array [, out])
Parameters :  
array : [array_like]Input array or object whose 
         elements, we need to test for  infinity
out   : [ndarray, optional]Output array placed 
        with result. Its type is preserved and
        it  must be of the right shape to hold 
         the output.
Return :  
boolean array containing the result. For scalar 
input, the result is a new boolean with value
True if the input is positive or negative infinity; 
otherwise the value is False. For array input, the 
result is a boolean array with the same shape as 
the input and the values are True where the 
corresponding element of the input is positive
or negative infinity; elsewhere the values are False.
Code 1 :  
Python
# Python Program illustrating# numpy.isinf() method  import numpy as geek print("Finite : ", geek.isinf(1), "\n") print("Finite : ", geek.isinf(0), "\n") # not a numberprint("Finite : ", geek.isinf(geek.nan), "\n") #  infinityprint("Finite : ", geek.isinf(geek.inf), "\n") print("Finite : ", geek.isinf(geek.NINF), "\n") x = geek.array([-geek.inf, 0., geek.inf])y = geek.array([2, 2, 2])print("Checking for infinity : ", geek.isinf(x, y))
Output : 
Finite :  False 

Finite :  False 

Finite :  False 

Finite :  True 

Finite :  True 

Checking for infinity :  [1 0 1]
Code 2 : 
Python
# Python Program illustrating# numpy.isinf() method   import numpy as geek  # Returns True/False value for each elementb = geek.arange(8).reshape(2, 4)                print("\n",b)print("\nIs Infinity : \n", geek.isinf(b)) # geek.inf  : Positive Infinity# geek.NINF : negative Infinityb = [[geek.inf],     [geek.NINF]]print("\nIs Infinity : \n", geek.isinf(b))
Output : 
 [[0 1 2 3]
 [4 5 6 7]]

Is Infinity : 
 [[False False False False]
 [False False False False]]

Is Infinity : 
 [[ True]
 [ True]]
References : https://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.isinf.html#numpy.isinf
Note : These codes won’t run on online IDE’s. So please, run them on your systems to explore the working. This article is contributed by Mohit Gupta_OMG . 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. 
akshaysingh98088
vinayedula
Python numpy-Logic Functions
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Find keys with duplicate values in dictionary

07 Aug, 2019
Given a dictionary, the task is to find keys with duplicate values. Let’s discuss a few methods for the same.
Method #1: Using Naive approachIn this method first, we convert dictionary values to keys with the inverse mapping and then find the duplicate keys
# Python code to demonstrate # finding duplicate values from a dictionary  # initialising dictionaryini_dict = {'a':1, 'b':2, 'c':3, 'd':2}  # printing initial_dictionaryprint("initial_dictionary", str(ini_dict))  # finding duplicate values# from dictionary# using a naive approachrev_dict = {}  for key, value in ini_dict.items():    rev_dict.setdefault(value, set()).add(key)      result = [key for key, values in rev_dict.items()                              if len(values) > 1]  # printing resultprint("duplicate values", str(result))
initial_dictionary {'c': 3, 'b': 2, 'd': 2, 'a': 1}
duplicate values [2]

 Method #2: Using flipping dictionary
# Python code to demonstrate # finding duplicate values from dictionary  # initialising dictionaryini_dict = {'a':1, 'b':2, 'c':3, 'd':2}  # printing initial_dictionaryprint("initial_dictionary", str(ini_dict))  # finding duplicate values# from dictionary using flipflipped = {}  for key, value in ini_dict.items():    if value not in flipped:        flipped[value] = [key]    else:        flipped[value].append(key)  # printing resultprint("final_dictionary", str(flipped))
initial_dictionary {'a': 1, 'c': 3, 'd': 2, 'b': 2}
final_dictionary {1: ['a'], 2: ['d', 'b'], 3: ['c']}

 Method #3: Using chain and set
Suppose you need to find keys having duplicate values.
# Python code to demonstrate # finding duplicate values from dictionaryfrom itertools import chain  # initialising dictionaryini_dict = {'a':1, 'b':2, 'c':3, 'd':2}  # printing initial_dictionaryprint("initial_dictionary", str(ini_dict))  # finding duplicate values# from dictionary using setrev_dict = {}for key, value in ini_dict.items():    rev_dict.setdefault(value, set()).add(key)    result = set(chain.from_iterable(         values for key, values in rev_dict.items()         if len(values) > 1))  # printing resultprint("resultant key", str(result))
initial_dictionary {'b': 2, 'd': 2, 'c': 3, 'a': 1}
resultant key {'d', 'b'}

Instead of
result = set(chain.from_iterable(         values for key, values in rev_dict.items()         if len(values) > 1))
Use this:
result = filter(lambda x: len(x)>1, rev_dict.values())print(list(result))
AyeshaBhatnagar
Python dictionary-programs
python-dict
Python
Python Programs
python-dict
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 | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
HTML dt Tag - GeeksforGeeks

17 Mar, 2022
The <dt> tag in HTML is used to specify the description list. It is used inside the <dl> element. It is usually followed by a <dd> tag. The subsequent <dd> elements provides some related text associated with the term specified using <dt>. 
Syntax: 
<dt> Content... </dt>
Example:  
HTML
<!DOCTYPE html> <html>     <body>         <h1>GeeksforGeeks</h1>        <h2><dt> Tag</h2>        <dl>            <!-- HTML dt tag -->            <dt>Geeks Classes</dt>            <dd>It is an extensive classroom programme for            enhancing DS and Algo concepts.</dd><br>             <!-- HTML dt tag -->            <dt>Fork Python</dt>            <dd>It is a course designed for beginners in            python.</dd><br>                       <!-- HTML dt tag -->            <dt>Interview Preparation</dt>            <dd>It is a course designed for preparation of            interviews in top product based companies.</dd>        </dl>             </body> </html>                   
Output:  
Supported Browsers:   
Google Chrome
Internet Explorer
Firefox
Opera
Safari
 
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
shubhamyadav4
HTML-Tags
Picked
HTML
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to update Node.js and NPM to next version ?
How to set the default value for an HTML <select> element ?
How to set input type date in dd-mm-yyyy format using HTML ?
Hide or show elements in HTML using display property
How to Insert Form Data into Database using PHP ?
REST API (Introduction)
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
React Native - Status Bar

In this chapter, we will show you how to control the status bar appearance in React Native.
The Status bar is easy to use and all you need to do is set properties to change it.
The hidden property can be used to hide the status bar. In our example it is set to false. This is default value.
The barStyle can have three values – dark-content, light-content and default.
This component has several other properties that can be used. Some of them are Android or IOS specific. You can check it in official documentation.
import React, { Component } from 'react';
import { StatusBar } from 'react-native'

const App = () => {
   return (
      <StatusBar barStyle = "dark-content" hidden = {false} backgroundColor = "#00BCD4" translucent = {true}/>
   )
}
export default App
If we run the app, the status bar will be visible and content will have dark color.

    20 Lectures 
     1.5 hours 

 Anadi Sharma

    61 Lectures 
     6.5 hours 

 A To Z Mentor

    40 Lectures 
     4.5 hours 

 Eduonix Learning Solutions

    56 Lectures 
     12.5 hours 

 Eduonix Learning Solutions

    62 Lectures 
     4.5 hours 

 Senol Atac

    67 Lectures 
     4.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
While Statement Implementation

There is no direct while statement available in Batch Script but we can do an implementation of this loop very easily by using the if statement and labels.
The following diagram shows the diagrammatic explanation of this loop.
The first part of the while implementation is to set the counters which will be used to control the evaluation of the ‘if’ condition. We then define our label which will be used to embody the entire code for the while loop implementation. The ‘if’ condition evaluates an expression. If the expression evaluates to true, the code block is executed. If the condition evaluates to false then the loop is exited. When the code block is executed, it will return back to the label statement for execution again.
Following is the syntax of the general implementation of the while statement.
Set counters
:label
If (expression) (
   Do_something
   Increment counter
   Go back to :label
)

The entire code for the while implementation is placed inside of a label.
The entire code for the while implementation is placed inside of a label.
The counter variables must be set or initialized before the while loop implementation starts.
The counter variables must be set or initialized before the while loop implementation starts.
The expression for the while condition is done using the ‘if’ statement. If the expression evaluates to true then the relevant code inside the ‘if’ loop is executed.
The expression for the while condition is done using the ‘if’ statement. If the expression evaluates to true then the relevant code inside the ‘if’ loop is executed.
A counter needs to be properly incremented inside of ‘if’ statement so that the while implementation can terminate at some point in time.
A counter needs to be properly incremented inside of ‘if’ statement so that the while implementation can terminate at some point in time.
Finally, we will go back to our label so that we can evaluate our ‘if’ statement again.
Finally, we will go back to our label so that we can evaluate our ‘if’ statement again.
Following is an example of a while loop statement.
@echo off
SET /A "index = 1"
SET /A "count = 5"
:while
if %index% leq %count% (
   echo The value of index is %index%
   SET /A "index = index + 1"
   goto :while
)
In the above example, we are first initializing the value of an index integer variable to 1. Then our condition in the ‘if’ loop is that we are evaluating the condition of the expression to be that index should it be less than the value of the count variable. Till the value of index is less than 5, we will print the value of index and then increment the value of index.
The above command produces the following output.
The value of index is 1
The value of index is 2
The value of index is 3
The value of index is 4
The value of index is 5

 Print
 Add Notes
 Bookmark this page
Cordova - Environment Setup

In this chapter, we will understand the Environment Setup of Cordova. To begin with the setup, we need to first install a few components. The components are listed in the following table.
NodeJS and NPM
NodeJS is the platform needed for Cordova development. Check out our NodeJS Environment Setup for more details.
Android SDK
For Android platform, you need to have Android SDK installed on your machine. Check out Android Environment Setup for more details.
XCode
For iOS platform, you need to have xCode installed on your machine. Check out iOS Environment Setup for more details
Before we start, you need to know that we will use Windows command prompt in our tutorial.
Even if you don't use git, it should be installed since Cordova is using it for some background processes. You can download git here. After you install git, open your environment variable.
Right-Click on Computer
Properties
Advanced System settings
Environment Variables
System Variables
Edit
Copy the following at the end of the variable value field. This is default path of the git installation. If you installed it on a different path you should use that instead of our example code below.
;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd

Now you can type git in your command prompt to test if the installation is successful.
This step will download and install Cordova module globally. Open the command prompt and run the following −
C:\Users\username>npm install -g cordova 

You can check the installed version by running −
C:\Users\username>cordova -v 

This is everything you need to start developing the Cordova apps on Windows operating system. In our next tutorial, we will show you how to create first application.

    45 Lectures 
     2 hours 

 Skillbakerystudios

    16 Lectures 
     1 hours 

 Nilay Mehta
 Print
 Add Notes
 Bookmark this page
What is Pre-Request Script in Postman?

The Pre-Request Script is used to run a JavaScript prior to the execution of a request. By incorporating a Pre-Request Script for a Collection, request or a folder, we can execute precondition steps like defining a variable, Parameters, Headers, Response, or logging console output.
We can include a Pre-Request Script to set the order of execution of requests within a Collection. A Pre-Request Script can also handle a scenario in which a value yielded from the request one has to be fed to the next request or the value yielded from the request one has to be processed before moving to the next request.
A Pre-Request can also be utilized to set a value from the Response field to a variable linked to a script in the Tests tab. These scripts are defined in the Pre-request Script tab in Postman.
Add the below JavaScript in the Pre-Request Script tab −
console.log("This is a Postman Tutorial in Tutorialspoint")
Select a GET request and enter an endpoint then click on Send.
Postman Console Output:
Step1 − Click on the three dots beside a Collection in the sidebar. Then click on Edit.
Step2 − EDIT COLLECTION pop-up comes up. Click on the Pre-Request Scripts tab to add a pre-condition script. Then click on Update.
Update a MySQL table with Java MySQL

For this, you need to use PreparedStatement in Java for update. Let us first create a table −
mysql> create table DemoTable(
   Id int,
   FirstName varchar(40)
);
Query OK, 0 rows affected (0.62 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(100,'Chris');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values(111,'Mike');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable values(121,'Sam');
Query OK, 1 row affected (0.09 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable;
This will produce the following output −
+------+-----------+
| Id   | FirstName |
+------+-----------+
| 100  | Chris     |
| 111  | Mike      |
| 121  | Sam       |
+------+-----------+
3 rows in set (0.00 sec)
The Java code is as follows to update −
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class UpdateFromJava {
   public static void main(String[] args) {
      Connection con = null;
      PreparedStatement ps = null;
      try {
         con = DriverManager.getConnection("jdbc :mysql ://localhost :3306/web?" +
         "useSSL=false", "root", "123456");
         String query = "update DemoTable set FirstName=? where Id=? ";
         ps = con.prepareStatement(query);
         ps.setString(1, "Tom");
         ps.setInt(2, 100);
         ps.executeUpdate();
         System.out.println("Record is updated successfully......");
         } catch (Exception e) {
            e.printStackTrace();
      }
   }
}
Following the output of Java code −
Record is updated successfully......
The screenshot of the output is as follows −
Let us now check the FirstName column name value has been updated to ‘Tom’ or not with ID 100.
Following is the query to check records and display them again −
mysql> select * from DemoTable;
This will produce the following output −
+------+-----------+
| Id   | FirstName |
+------+-----------+
| 100  |       Tom |
| 111  |      Mike |
| 121  |       Sam |
+------+-----------+
3 rows in set (0.00 sec)
The snapshot of the output is as follows. The FirstName column updated successfully with Java-MySQL −
Anshuman's Favourite Number | Practice | GeeksforGeeks

You are given an integer input N and you have to find whether it is the sum or the difference of the integer 5. (5+5, 5+5+5, 5-5,5-5-5+5+5.....)
 
Example 1:
Input:
N = 10
Output:
YES
Explanation:
Because 10 can be 
written as a sum of 5+5.
 
 
Example 2:
Input:
N = 9
Output:
NO
Explanation:
9 can not be written
in the above form.
 
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function isValid() which takes an integer N and returns "YES" or "NO".
 
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
 
Constraints:
-109<=N<=109
0
sonkambaleujjawal2 months ago
One Line Answerer C++
return N%5==0 ? "YES" : "NO";
+2
aadeshabhigyan093 months ago
class Solution{   public:   string isValid(long long N){       // code here        if(N%5 == 0)       {         return "YES";         }      // No need to be confused by the pattern here as any number got on adding or subtracting       // 5 will be a multiple of 5       return "NO";   }};
0
amiransarimy3 months ago
One Line Python Solutions
 
class Solution:
   def isValid (self,N):
       return "YES" if N%5 == 0 else "NO"
0
poulamibera5193 months ago
class Solution{   public:   string isValid(long long N){       // code here        if(N%5==0)           return "YES";       else           return "NO";          }};
0
mayank20214 months ago
#C++
class Solution{   public:   string isValid(long long N){               string S= (N%5==0) ?  "YES" :  "NO";        return S;          }};
0
shruti038btmae206 months ago
C++ SOLUTION:-
 // code here               if(N%5==0)       {           return "YES";       }       else         return "NO";
0
Anjali Jaiswal9 months ago
Anjali Jaiswal
 string isValid(long long N){        // code here         if(N%5==0)        return "YES";        return "NO";    }
0
Akash Gupta10 months ago
Akash Gupta
Execution Time 0.01
 if(N%5==0)        {            cout<<"YES";        }        else         {             cout<<"NO";        }    }
0
Manav Saxena11 months ago
Manav Saxena
class Solution{   public:    string isValid(long long N){         string s1="YES";         string s2="NO";         if(N%5==0){             return s1;         }else{             return s2;         }    }};
-1
Gurucharan Rajput1 year ago
Gurucharan Rajput
java solution  return N%5==0 ?"YES":"NO";
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code. On submission, your code is tested against multiple test cases consisting of all possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as the final solution code.
You can view the solutions submitted by other users from the submission tab.
Pycharm - Improving and Writing Code

PyCharm includes various standards for writing code with proper indentations valid for Python. This makes it interesting to improve the code standards and writing the complete code in PyCharm editor.
Code completion in PyCharm is really unique. You can enhance it further using many other features. Note that the editor provides start and end of the code block. Consider a file named demo.py with the following code −
message = 'GIEWIVrGMTLIVrHIQS' #encrypted message
LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

for key in range(len(LETTERS)):
   translated = ''
	
   for symbol in message:
      if symbol in LETTERS:
         num = LETTERS.find(symbol)
         num = num - key
         if num < 0:
            num = num + len(LETTERS)
         translated = translated + LETTERS[num]
      else:
         translated = translated + symbol
   print('Hacking key #%s: %s' % (key, translated))
The code is completed using the following construct −
If you press Ctrl + spacebar while this popup is on the screen, you can see more code completion options −
PyCharm includes intent specific actions and the shortcut key for the same is Alt+Enter. The most important example of intentions at work is using language injection in strings.
The screenshot given below shows the working of intention actions −
Note that we can insert many different languages of intention actions in PyCharm Editor.

    19 Lectures 
     59 mins

 Mustafa Mahmoud

    19 Lectures 
     49 mins

 Pedro Planas
 Print
 Add Notes
 Bookmark this page
response.encoding – Python requests

01 Mar, 2020
Python requests are generally used to fetch the content from a particular resource URI. Whenever we make a request to a specified URI through Python, it returns a response object. Now, this response object would be used to access certain features such as content, headers, etc. This article revolves around how to check the response.encoding out of a response object. response.encoding returns the encoding used to decode response.content. Check more about encoding here – Python Strings encode() method
To illustrate use of response.encoding, let’s ping API of Github. To run this script, you need to have Python and requests installed on your PC.
Download and Install Python 3 Latest Version
How to install requests in Python – For windows, linux, mac
# import requests moduleimport requests  # Making a get requestresponse = requests.get('https://api.github.com')  # print responseprint(response)  # print encoding of responseprint(response.encoding)
Save above file as request.py and run using
Python request.py

Check that utf-8 at the start of the output, it shows that string is encoded and decoded using “utf-8”.
There are many libraries to make an HTTP request in Python, which are httplib, urllib, httplib2, treq, etc., but requests is the one of the best with cool features. If any attribute of requests shows NULL, check the status code using below attribute.
requests.status_code
If status_code doesn’t lie in range of 200-29. You probably need to check method begin used for making a request + the url you are requesting for resources.
Python-requests
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Convert List of lists to list of Strings

22 Jun, 2022
Interconversion of data is very popular nowadays and has many applications. In this scenario, we can have a problem in which we need to convert a list of lists, i.e matrix into list of strings. Let’s discuss certain ways in which this task can be performed. 
Method #1 : Using list comprehension + join() 
The combination of above functionalities can be used to perform this task. In this, we perform the task of iteration using list comprehension and join() is used to perform task of joining string to list of strings. 
Python3
# Python3 code to demonstrate working of# Convert List of lists to list of Strings# using list comprehension + join() # initialize listtest_list = [["g", "f", "g"], ["i", "s"], ["b", "e", "s", "t"]] # printing original listprint("The original list : " + str(test_list)) # Convert List of lists to list of Strings# using list comprehension + join()res = [''.join(ele) for ele in test_list] # printing resultprint("The String of list is : " + str(res))
The original list : [['g', 'f', 'g'], ['i', 's'], ['b', 'e', 's', 't']]
The String of list is : ['gfg', 'is', 'best']
  Method #2: Using map() + join() 
The task above can also be performed using combination of above methods. In this, we perform the task of conversion using join and iteration using map(). 
Python3
# Python3 code to demonstrate working of# Convert List of lists to list of Strings# using map() + join() # initialize listtest_list = [["g", "f", "g"], ["i", "s"], ["b", "e", "s", "t"]] # printing original listprint("The original list : " + str(test_list)) # Convert List of lists to list of Strings# using map() + join()res = list(map(''.join, test_list)) # printing resultprint("The String of list is : " + str(res))
The original list : [['g', 'f', 'g'], ['i', 's'], ['b', 'e', 's', 't']]
The String of list is : ['gfg', 'is', 'best']
vinayedula
Python list-programs
Python string-programs
Python-list-of-lists
Python
Python Programs
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
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
Golismero – Scan Website, Vulnerability Scanning, WEB Server in Kali Linux

17 Jun, 2021
Golismero is a free and open-source tool available on GitHub. Golismero is an Open Source Intelligence and Information Gathering Tool based on (OSINT). Golismero is capable of doing everything almost you need for reconnaissance as per your need it can perform reconnaissance easily. Golismero works as an open-source tool intelligence tool. It integrates with just about every data source available and utilizes a range of methods for data analysis. Golismero is written in python language. You must have python language installed in your Kali Linux system in order to use Gasmask tool. This too is used to get various information about our target. This information includes Real platform independence. This also includes Tested on Windows, Linux, *BSD, and OS X. Golismero Integrates with standards: CWE, 
Step 1: Open your Kali Linux and then Open your Terminal. 
sudo bash
apt-get install python2.7 python2.7-dev python-pipn docutils git perl map sslscan
Step 2: Now install the tool using the following command. 
git clone https://github.com/golismero/golismero.git
cd golismero
pip install -r requirements.txt
Step 3: The tool has been downloaded and running successfully now use the following command to run the tool.
./golismero.py
Example 1: Use the golismero tool to scan www.google.com
./golismero.py scan http://www.google.com 
Example 2: Use the golismero tool to scan www.geeksforgeeks.org
./golismero.py scan https://www.geeksforgeeks.org
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Docker - COPY Instruction
scp command in Linux with Examples
chown command in Linux with Examples
SED command in Linux | Set 2
mv command in Linux with examples
chmod command in Linux with examples
nohup Command in Linux with Examples
Introduction to Linux Operating System
Array Basics in Shell Scripting | Set 1
Basic Operators in Shell Scripting