code-rag-bench/online-tutorials huggingface dataset:
How to Update Multiple Columns in Single Update Statement in SQL?

28 Oct, 2021
In this article, we will see, how to update multiple columns in a single statement in SQL. We can update multiple columns by specifying multiple columns after the SET command in the UPDATE statement. The UPDATE statement is always followed by the SET command, it specifies the column where the update is required.
UPDATE for multiple columns
Syntax:
UPDATE table_name
SET column_name1= value1, column_name2= value2
WHERE condition;
Now, for the demonstration follow the below steps:
Step 1: Create a database
we can use the following command to create a database called geeks.
Query:
CREATE DATABASE geeks;
Step 2: Use database
Use the below SQL statement to switch the database context to geeks:
Query:
USE geeks;
Step 3: Table definition
We have the following demo_table in our geek’s database.
Query:
CREATE TABLE demo_table(
NAME VARCHAR(20),
AGE INT,
CITY VARCHAR(20) );
Step 4: Insert data into a table
Query:
INSERT INTO demo_table VALUES
('ROMY KUMARI', 22, 'NEW DELHI'),
('PUSHKAR JHA',23, 'NEW DELHI'),
('AKANKSHA GUPTA',22, 'PUNJAB'),
('SUJATA JHA', 30,'PATNA'),
('PREETI GIRI', 26,'BANGLORE'),
('PREM GUPTA',31,'PUNE'),
('RAM KAPOOR', 34,'PUNE'),
('SHEETAL AWASTHI',32, 'RAJASTHAN');
Step 5: View data of the table
Query:
SELECT * FROM demo_table;
Output:
Step 6: Update multiple columns
For the purpose of demonstration let’s update AGE value to be 30 and CITY value to be PUNJAB where CITY value is ‘NEW DELHI’.
Query:
UPDATE demo_table
SET AGE=30, CITY='PUNJAB'
WHERE CITY='NEW DELHI';
Output:
view content of table demo_table
We can see that the table is updated now with the desired value.
Picked
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
p5.Table getRowCount() Method

08 Jul, 2020
The getRowCount() method of p5.Table in p5.js is used to return the total number of rows in a table object.
Syntax:
getRowCount()
Parameters: This function does not accept any parameters.
Return Value: It returns an integer value which specifies the number of rows in the table.
Below example illustrates the getRowCount() method in p5.js:
Example:
let rowCount = 1;  function setup() {  createCanvas(500, 400);  textSize(16);    addRowBtn = createButton("Add Row");  addRowBtn.position(30, 50);  addRowBtn.mouseClicked(addOneRow);    removeRowBtn =    createButton("Clear Last Row");  removeRowBtn.position(160, 50);  removeRowBtn.mouseClicked(clearLastRow);    // Create the table  table = new p5.Table();    // Add columns  table.addColumn("book");  table.addColumn("price");    // Display the table  showTable();}  function addOneRow() {  let newRow = table.addRow();  newRow.set('book', "Book " + rowCount);  newRow.set('price', "Price " +    (rowCount * random(1, 10)).toFixed(1));    rowCount++;    showTable();}  function clearLastRow() {  let lastRow = table.getRowCount() - 1;  if (lastRow >= 0)     table.removeRow(lastRow);    showTable();}  function showTable() {  clear();  text("Click on the buttons to change" +       " the number of rows in the table",       20, 20);    // Get the number of rows in the table  let rowCount = table.getRowCount();    // Display the total rows  // present in the table  text("There are " + rowCount +       " rows in the table", 20, 100);    // Show all the rows currently  // present in the table  for (let r = 0; r < rowCount; r++) {    let currRow = table.rows[r].arr.toString();    currRow = currRow.split(", ").join("  ");      text(currRow, 30, 140 + r * 20);  }}
Output:
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.Table/getRowCount
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to Open URL in New Tab using JavaScript ?
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
How to add text on an image using pillow in Python ?

17 Dec, 2020
Prerequisites: PIL
In this article we’ll see how we can add text on an image using the pillow library in Python. Python Imaging Library (PIL) is the de facto image processing package for Python language. It incorporates lightweight image processing tools that aids in editing, creating and saving images. Pillow supports numerous image file formats including BMP, PNG, JPEG, and TIFF. 
Syntax:
ImageDraw.Draw.text((x, y),"Text",(r,g,b))
Import module
Import image
Add text 
Save image
Image in use:
Example 1:
Python3
from PIL import Imagefrom PIL import ImageFontfrom PIL import ImageDraw  # importing the imageimg = Image.open("gfg.png")draw = ImageDraw.Draw(img)  # specifying coordinates and colour of textdraw.text((50, 90), "Sample Text", (255, 255, 255))  # saving the imageimg.save('sample.jpg')
Output:
Example 2: Writing text in a specific font
To write the text in a specific font, we need to download the font file for the required font. In the example given below we have used Comic Sans and it can be downloaded from : https://www.wfonts.com/font/comic-sans-ms
Python3
from PIL import Imagefrom PIL import ImageFontfrom PIL import ImageDraw  # importing the imageimg = Image.open("gfg.png")draw = ImageDraw.Draw(img)  # loading the font and providing the sizefont = ImageFont.truetype("ComicSansMS3.ttf", 30)  # specifying coordinates and colour of textdraw.text((50, 90), "Hello World!", (255, 255, 255), font=font)  # saving the imageimg.save('sample.jpg')
Output:
Picked
Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
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
Software Engineering | Control Flow Graph (CFG)

15 May, 2019
A Control Flow Graph (CFG) is the graphical representation of control flow or computation during the execution of programs or applications. Control flow graphs are mostly used in static analysis as well as compiler applications, as they can accurately represent the flow inside of a program unit. The control flow graph was originally developed by Frances E. Allen.
Characteristics of Control Flow Graph:
Control flow graph is process oriented.
Control flow graph shows all the paths that can be traversed during a program execution.
Control flow graph is a directed graph.
Edges in CFG portray control flow paths and the nodes in CFG portray basic blocks.
There exist 2 designated blocks in Control Flow Graph:
Entry Block:Entry block allows the control to enter into the control flow graph.Exit Block:Control flow leaves through the exit block.
Entry Block:Entry block allows the control to enter into the control flow graph.
Exit Block:Control flow leaves through the exit block.
Hence, the control flow graph is comprised of all the building blocks involved in a flow diagram such as the start node, end node and flows between the nodes.
General Control Flow Graphs:Control Flow Graph is represented differently for all statements and loops. Following images describe it:
1. If-else:
2. while:
3. do-while:
4. for:
Example:
if  A = 10 then
  if B > C
     A = B
  else A = C
  endif
  endif
print A, B, C 
Flowchart of above example will be:
Control Flow Graph of above example will be:
Advantage of CFG:There are many advantages of a control flow graph. It can easily encapsulate the information per each basic block. It can easily locate inaccessible codes of a program and syntactic structures such as loops are easy to find in a control flow graph.
Software Engineering
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PyQt5 – How to change style and size of text Progress Bar ?

22 Apr, 2020
In this article we will see how to change the font style and the size of data which is inside the progress bar. We can set the text in progress bar using setFormat method. In order to change the font and the size we will use setFont method which take QFont object as argument and font and size will be changes.
Syntax : bar.setFont(QFont(font_name, size))
Argument : It takes QFont object as argument.
Action performed : This will change the font and size of the text.
Below is the implementation.
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):        # creating progress bar        bar1 = QProgressBar(self)          # setting geometry to progress bar        bar1.setGeometry(200, 100, 200, 30)          # setting the value        bar1.setValue(70)          # setting alignment to center        bar1.setAlignment(Qt.AlignCenter)          # setting font and the size        bar1.setFont(QFont('Arial', 15))          # creating progress bar        bar2 = QProgressBar(self)          # setting geometry to progress bar        bar2.setGeometry(200, 200, 200, 30)          # setting the value        bar2.setValue(20)          # adding text using setFormat        bar2.setFormat("Hello Geeks")          # setting alignment to center        bar2.setAlignment(Qt.AlignCenter)          # setting font and the size        bar2.setFont(QFont('Times', 7))    App = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python-gui
Python-PyQt
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
re.fullmatch() function in Python

16 Mar, 2021
re.fullmatch() returns a match object if and only if the entire string matches the pattern. Otherwise, it will return None. The flag at the end is optional and can be used to ignore cases etc. 
Syntax: re.fullmatch(pattern, string, flags=0)
Parameters:
pattern: the regular expression pattern that you want to match.
string: the string which you want to search for the pattern.
flags (optional argument): a more advanced modifier that allows you to customize the behavior of the function. 
Example 1:
Python3
import re    string = 'geeks'pattern = 'g...s'  print(re.fullmatch(pattern, string))
<_sre.SRE_Match object; span=(0, 5), match='geeks'>
re.fullmatch() and re.match() both are functions of re module in python. These functions are very efficient and fast for searching in strings. Both functions attempt to match at the beginning of the string.  But the difference between re.match() and re.fullmatch() is that re.match() matches only at the beginning but re.fullmatch() tries to match at the end as well.
Example:
Python3
import re    string = "Geeks for geeks"pattern = "Geeks"  print(re.match(pattern, string))print(re.fullmatch(pattern, string))
<_sre.SRE_Match object; span=(0, 5), match='Geeks'>
None
python-regex
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
Introduction To PYTHON
Python OOPs Concepts
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Create a directory in Python
Special Keys in Selenium Python

23 Aug, 2021
Selenium’s Python Module is built to perform automated testing with Python. Special Keys is an exclusive feature of Selenium in python, that allows pressing keys through keyboard such as ctrl+f, or shift+c+v, etc. class selenium.webdriver.common.keys.Keys handles all Keys in Selenium Python. It contains huge number of key methods one can use in Selenium Python. 
To demonstrate, Special Keys, let’s use key_up method of Action Chains in Selenium Python. This bot visits https://www.geeksforgeeks.org/ and press ctrl+f to open search bar.Program –  
Python3
# import webdriverfrom selenium import webdriver # import Action chainsfrom selenium.webdriver.common.action_chains import ActionChains # import KEYSfrom selenium.webdriver.common.keys import Keys # create webdriver objectdriver = webdriver.Firefox() # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/") # create action chain objectaction = ActionChains(driver) # perform the operationaction.key_down(Keys.CONTROL).send_keys('F').key_up(Keys.CONTROL).perform()
Output –  
 
Various keys that can be used in Selenium Python are –  
 
varshagumber28
surinderdawra388
surindertarika1234
Python-selenium
selenium
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
How to Install PIP on Windows ?
Python String | replace()
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to copy files into a directory in C#?

To Copy a file, C# provides a method File. Copy
File. Copy has 2 overloads
Copy(String, String) -Copies an existing file to a new file. Overwriting a file of the same name is not allowed.
Copy(String, String, Boolean) Copies an existing file to a new file. Overwriting a file of the same name is allowed.
Directory.GetFiles returns the names of all the files (including their paths) that match the specified search pattern, and optionally searches subdirectories.
static void Main (string[] args) {
   string rootPath = @"C:\Users\Koushik\Desktop\TestFolder\TestFolderMain1";

   var searchSourceFolder = Directory.GetFiles(rootPath, "*.*", SearchOption.TopDirectoryOnly);
   Console.WriteLine("-------------Source Folder-------------");
   foreach (string file in searchSourceFolder){
      Console.WriteLine(file);
   }

   string destinationFolder = @"C:\Users\Koushik\Desktop\TestFolder\TestFolderMain2\";

   var destinationFolderFiles = Directory.GetFiles(destinationFolder, "*.*",    SearchOption.TopDirectoryOnly);
   Console.WriteLine("-------------Destination Folder Before Copying-------------");
   foreach (string file in destinationFolderFiles){
      Console.WriteLine(file);
   }

   string[] files = Directory.GetFiles(rootPath);

   foreach (string file in files){
      File.Copy(file, $"{destinationFolder}{ Path.GetFileName(file) }");
   }
   Console.WriteLine("-------------After Copying-------------");

   var destinationFolderAfterCopyingFiles = Directory.GetFiles(destinationFolder, "*.*",    SearchOption.TopDirectoryOnly);

   foreach (string file in destinationFolderAfterCopyingFiles){
      Console.WriteLine(file);
   }
   Console.ReadLine ();
}
-------------Source Folder-------------
C:\Users\Koushik\Desktop\TestFolder\TestFolderMain1\TestFolderMain1.txt
-------------Destination Folder Before Copying-------------
C:\Users\Koushik\Desktop\TestFolder\TestFolderMain2\TestFolderMain2.txt
-------------After Copying-------------
C:\Users\Koushik\Desktop\TestFolder\TestFolderMain2\TestFolderMain1.txt
C:\Users\Koushik\Desktop\TestFolder\TestFolderMain2\TestFolderMain2.txt
Why is colspan not a known native attribute in Angular 2?

26 Jun, 2020
In order to understand it, we need to have a clear in-depth knowledge between Document Object Model(DOM) and HyperText Markup Language(HTML).Basically, DOM is a model of objects and is a logical tree representation of the document whereas HTML is a markup language that we used to build web-pages.Every HTML attributes have one to one mapping to properties of DOM objects.
Example: First Name
<label for="fname">First Name </label><input type="text" id="fname" name="fname" disabled >
So, The above example contains two tags label and input. As we can observe, there is an attribute defined inside the input tag which is “disabled”.Similarly, if you talk about DOM properties, disabled is also present inside the input object.But they are cases where some attributes of HTML tags are not available inside the DOM. Example: colspan. Like colspan, So when you try to use them for attribute binding in Angular 2+, you will get an error which says “can’t bind to colspan since it isn’t a known property of ‘td’ “.Similarly, we have some properties which are defined in DOM but are not present in HTML.
Example:
<h2 [textContent]="title"></h1>
Solution:In order to use them for attribute binding you need to use the following syntax “[attr.colspan]”.
import {Component} from '@angular/core';    @Component({  selector:'app-colspan',template:`<h4> Colspan Usage </h4><table>  <tr>   <td [attr.colspan]="colSpan">First Item </td>  </tr>  <tr>   <td>Second Item</td>   <td>Third Item </td>  </tr></table>`,styles:[`  table, tr, td{border: 1px solid black;border-collapse:collapse;}`]})    export class ColSpanComponent{  colSpan="2"  }
Output:
AngularJS-Misc
Picked
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Auth Guards in Angular 9/10/11
Routing in Angular 9/10
How to bundle an Angular app for production?
What is AOT and JIT Compiler in Angular ?
Angular PrimeNG Dropdown Component
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
sympy.integrals.transforms.fourier_transform() in python

10 Jul, 2020
With the help of fourier_transform() method, we can compute the Fourier transformation and it will return the transformed function.
Fourier transformation function
Syntax : fourier_transform(f, x, k, **hints)
Return : Return the transformed function.
Example #1 :
In this example we can see that by using fourier_transform() method, we are able to compute the Fourier transformation and return the transeformed function.
Python3
# import fourier_transformfrom sympy import fourier_transform, expfrom sympy.abc import x, k  # Using fourier_transform() methodgfg = fourier_transform(exp(-x**2), x, k)  print(gfg)
Output :
sqrt(pi)*exp(-pi**2*k**2)
Example #2 :
Python3
# import fourier_transformfrom sympy import fourier_transform, expfrom sympy.abc import x, k  # Using fourier_transform() methodgfg = fourier_transform(exp(-x**2), x, 4)  print(gfg)
Output :
sqrt(pi)*exp(-16*pi**2)
Python SymPy-Stats
SymPy
Programming Language
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Introduction of Object Oriented Programming
Difference between for and while loop in C, C++, Java
Which Programming Language Should I Choose as a Beginner?
Learn C++ Programming Step by Step - A 20 Day Curriculum!
7 Highest Paying Programming Languages For Freelancers in 2022
Read JSON file using Python
Python map() function
Adding new column to existing DataFrame in Pandas
Python Dictionary
How to get column names in Pandas dataframe
How to create shapes using CSS ?

21 Jun, 2021
In this article, we will design some different types of shapes using CSS. CSS is capable of making all types of shapes.  
Creating a square:  
html
<!-- Write HTML code here --><!DOCTYPE html><html> <head>    <style>        .square {            height: 50px;            width: 50px;            background-color: green;        }    </style></head> <body>    <div class="square"></div></body> </html>
Output:  
Creating Triangle Upward:  
Upward:  
html
<!-- Write HTML code here --><!DOCTYPE html><html> <head>    <style>        .triangle {            width: 0;            height: 0;            border-left: 25px solid transparent;            border-right: 25px solid transparent;            border-bottom: 50px solid green;        }    </style></head> <body>    <div class="triangle"></div></body> </html>
Output:  
Downward:  
html
<!-- Write HTML code here --><!DOCTYPE html><html> <head>    <style>        .triangle {            width: 0;            height: 0;            border-left: 25px solid transparent;            border-right: 25px solid transparent;            border-top: 50px solid green;        }    </style></head> <body>    <div class="triangle"></div></body> </html>
Output:  
Creating a circle:  
html
<!-- Write HTML code here --><!DOCTYPE html><html> <head>    <style>        .circle {            height: 70px;            width: 70px;            background-color: green;            border-radius: 50%;        }    </style></head> <body>    <div class="circle"></div></body> </html>
Output:  
Creating a rectangle:  
html
<!-- Write HTML code here --><!DOCTYPE html><html> <head>    <style>        .rectangle {            height: 50px;            width: 80px;            background-color: green;        }    </style></head> <body>    <div class="rectangle"></div></body> </html>
Output: 
 
Creating a parallelogram:  
html
<!-- Write HTML code here --><!DOCTYPE html><html> <head>    <style>        .parallelogram {            width: 120px;            height: 60px;            transform: skew(24deg);            background: green;        }    </style></head> <body>    <div class="parallelogram"></div></body> </html>
Output:  
Creating oval:
HTML
<!-- Write HTML code here --><!DOCTYPE html><html> <head>    <style>        .oval {            height: 200px;            width: 400px;          border-radius: 50%;            background-color: green;        }    </style></head> <body>    <div class="oval"></div></body> </html>
Output:
imsushant12
CoderSaty
CSS-Misc
CSS
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
CSS to put icon inside an input element in a form
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
REST API (Introduction)
Hide or show elements in HTML using display property
GATE | GATE CS 1996 | Question 63

30 Jul, 2019
Insert the characters of the string K R P C S N Y T J M into a hash table of size 10.Use the hash function
h(x) = ( ord(x) – ord("a") + 1 ) mod10
If linear probing is used to resolve collisions, then the following insertion causes collision(A) Y(B) C(C) M(D) PAnswer: (C)Explanation:(a) The hash table with size 10 will have index from 0 to 9.hash function = h(x) = ((ord(x) – ord(A) + 1)) mod 10So for string K R P C S N Y T J M:K will be inserted at index : (11-1+1) mod 10 = 1R at index: (18-1+1) mod 10 = 8P at index: (16-1+1) mod 10 = 6C at index: (3-1+1) mod 10 = 3S at index: (19-1+1) mod 10 = 9N at index: (14-1+1) mod 10 = 4Y at index (25-1+1) mod 10 = 5T at index (20-1+1) mod 10 = 0J at index (10-1+1) mod 10 = 0 // first collision occurs.M at index (13-1+1) mod 10 = 3 //second collision occurs.
Only J and M are causing the collision.
(b) Final Hash table will be:
0    T
1    K
2    J
3    C
4    N
5    Y
6    P
7    M
8    R
9    S
Quiz of this Question
GATE CS 1996
GATE-GATE CS 1996
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2014-(Set-3) | Question 20
GATE | GATE CS 2008 | Question 46
GATE | GATE CS 2008 | Question 40
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2014-(Set-1) | Question 51
GATE | GATE CS 2011 | Question 49
GATE | GATE-CS-2004 | Question 31
GATE | GATE CS 1996 | Question 38
Python map() function

07 Jul, 2022
map() function returns a map object(which is an iterator) of the results after applying the given function to each item of a given iterable (list, tuple etc.)
Syntax :
map(fun, iter)

Parameters :
fun : It is a function to which map passes each element of given iterable.iter : It is a iterable which is to be mapped.
NOTE : You can pass one or more iterable to the map() function.
Returns :
Returns a list of the results after applying the given function  
to each item of a given iterable (list, tuple etc.) 

 NOTE : The returned value from map() (map object) then can be passed to functions like list() (to create a list), set() (to create a set) . CODE 1
# Python program to demonstrate working# of map.  # Return double of ndef addition(n):    return n + n  # We double all numbers using map()numbers = (1, 2, 3, 4)result = map(addition, numbers)print(list(result))
Output :
[2, 4, 6, 8]

 CODE 2We can also use lambda expressions with map to achieve above result.
# Double all numbers using map and lambda  numbers = (1, 2, 3, 4)result = map(lambda x: x + x, numbers)print(list(result))
Output :
[2, 4, 6, 8]

 CODE 3
# Add two lists using map and lambda  numbers1 = [1, 2, 3]numbers2 = [4, 5, 6]  result = map(lambda x, y: x + y, numbers1, numbers2)print(list(result))
Output :
[5, 7, 9]

 CODE 4
# List of stringsl = ['sat', 'bat', 'cat', 'mat']  # map() can listify the list of strings individuallytest = list(map(list, l))print(test)
Output :
[['s', 'a', 't'], ['b', 'a', 't'], ['c', 'a', 't'], ['m', 'a', 't']]
link111
piyushkhanna30
python-list
python-list-functions
python-map
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Convert integer to string in Python
Python | os.path.join() method
Create a Pandas DataFrame from Lists
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Try/catch/finally/throw keywords in C#

Exception handling is based on the following keywords and its usage −
try − A try block identifies a block of code for which particular exceptions is activated. It is followed by one or more catch blocks.
try − A try block identifies a block of code for which particular exceptions is activated. It is followed by one or more catch blocks.
catch − A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception.
catch − A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception.
finally − The finally block is used to execute a given set of statements, whether an exception is thrown or not thrown. For example, if you open a file, it must be closed whether an exception is raised or not.
finally − The finally block is used to execute a given set of statements, whether an exception is thrown or not thrown. For example, if you open a file, it must be closed whether an exception is raised or not.
throw − A program throws an exception when a problem shows up. This is done using a throw keyword.
throw − A program throws an exception when a problem shows up. This is done using a throw keyword.
To handle exceptions, you need to set them like the following syntax in C# −
try {
   // statements causing exception
} catch( ExceptionName e1 ) {
   // error handling code
} catch( ExceptionName e2 ) {
   // error handling code
} catch( ExceptionName eN ) {
   // error handling code
} finally {
   // statements to be executed
}
Tryit Editor v3.7

Background Image Repeat
Tryit: Using no-repeat
Python - Tkinter Frame

The Frame widget is very important for the process of grouping and organizing other widgets in a somehow friendly way. It works like a container, which is responsible for arranging the position of other widgets.
It uses rectangular areas in the screen to organize the layout and to provide padding of these widgets. A frame can also be used as a foundation class to implement complex widgets.
Here is the simple syntax to create this widget −
w = Frame ( master, option, ... )

master − This represents the parent window.
master − This represents the parent window.
options − Here is the list of most commonly used options for this widget. These options can be used as key-value pairs separated by commas.
options − Here is the list of most commonly used options for this widget. These options can be used as key-value pairs separated by commas.
bg
The normal background color displayed behind the label and indicator.
bd
The size of the border around the indicator. Default is 2 pixels.
cursor
If you set this option to a cursor name (arrow, dot etc.), the mouse cursor will change to that pattern when it is over the checkbutton.
height
The vertical dimension of the new frame. 
highlightbackground
Color of the focus highlight when the frame does not have focus.
highlightcolor
Color shown in the focus highlight when the frame has the focus.
highlightthickness
Thickness of the focus highlight.
relief
With the default value, relief=FLAT, the checkbutton does not stand out from its background. You may set this option to any of the other styles
width
The default width of a checkbutton is determined by the size of the displayed image or text. You can set this option to a number of characters and the checkbutton will always have room for that many characters.
Try the following example yourself −
from Tkinter import *

root = Tk()
frame = Frame(root)
frame.pack()

bottomframe = Frame(root)
bottomframe.pack( side = BOTTOM )

redbutton = Button(frame, text="Red", fg="red")
redbutton.pack( side = LEFT)

greenbutton = Button(frame, text="Brown", fg="brown")
greenbutton.pack( side = LEFT )

bluebutton = Button(frame, text="Blue", fg="blue")
bluebutton.pack( side = LEFT )

blackbutton = Button(bottomframe, text="Black", fg="black")
blackbutton.pack( side = BOTTOM)

root.mainloop()
When the above code is  executed, it produces the following result −

    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
File opening modes(r versus r+) in C++

File handling in programming languages is very important for the interaction of programming with the memory for accessing files and fetching data in it.
Using a program, you can read data from a file as well as write data to the file and do a lot more functions.
Here, we will see reading of data from a file.
In programming, before performing any operation you need to open the file. And there are multiple modes to open a file in the programming language. The access to the file is based on the mode it is opened with.
Here we will learn about the difference between two modes of opening file for reading files, these are r and r+.
Both are used for reading files in the program.
Syntax for opening a file : 
          FILE *fp;
          fp = fopen( “filename.fileextension” , “mode” )
r mode for opening a file: 
The r mode for opening file, opens files for reading only. If the file does not exist NULL character is returned.
Program to illustrate the opening of file:
#include <stdio.h>
#include <iostream>
using namespace std;

int main() {
   
   FILE* readFile;
   char ch;
   readFile = fopen("file.txt", "r");
   while (1) {
      ch = fgetc(readFile);
      if (ch == EOF)
         break;
      cout<<ch;
   }
   fclose(readFile);
}

Tutorials Point
r+ mode for opening a file:
The r+ mode for opening a file is similar to r mode but has some added features. It opens the file in both read and write mode. If the file does not exist with w+, the program creates new files to work on it.
Program to illustrate the opening of file in r+ mode:
#include <stdio.h>
#include <iostream>
using namespace std;

int main() {
   
   FILE* readFile;
   char ch;
   readFile = fopen("file.txt", "r+");
   while (1) {
      ch = fgetc(readFile);
      if (ch == EOF)
         break;
      cout<<ch;
   }
   fclose(readFile);
}
Tutorials Point
Tryit Editor v3.7

Tryit: HTML table - border bottom
How to check if a document is ready in JavaScript?

Following is the code to check if a document is ready in JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 18px;
      font-weight: 500;
      color: blueviolet;
   }
</style>
</head>
<body>
<h1>Check if a document is ready</h1>
<div class="result"></div>
<button class="Btn">Check</button>
<h3>Click on the above button to see document state</h3>
<script>
   let resEle = document.querySelector(".result");
   let BtnEle = document.querySelector(".Btn");
   resEle.innerHTML = document.readyState + "<br><br>";
   BtnEle.addEventListener("click", () => {
      if (document.readyState === "complete") {
         resEle.innerHTML = "The page has finished loading completely";
      } else {
         resEle.innerHTML = "The page is still loading";
      }
   });
</script>
</body>
</html>
On clicking the ‘Check’ button −
submit() element method - Selenium Python - GeeksforGeeks

27 Apr, 2020
Selenium’s Python Module is built to perform automated testing with Python. Selenium Python bindings provides a simple API to write functional/acceptance tests using Selenium WebDriver. To open a webpage using Selenium Python, checkout – Navigating links using get method – Selenium Python. Just being able to go to places isn’t terribly useful. What we’d really like to do is to interact with the pages, or, more specifically, the HTML elements within a page. There are multiple strategies to find an element using Selenium, checkout – Locating Strategies
This article revolves around how to use submit method in Selenium. submit method is used to submit a form after you have sent data to a form.
element.submit()
Example –
<input type="text" name="passwd" id="passwd-id" />
To find an element one needs to use one of the locating strategies, For example,
element = driver.find_element_by_id("passwd-id")
element = driver.find_element_by_name("passwd")
element = driver.find_element_by_xpath("//input[@id='passwd-id']")
Also, to find multiple elements, we can use –
elements = driver.find_elements_by_name("passwd")
To enter text into a field, for example,
element.send_keys("some text")
Now one can submit this search with
element.submit()
Let’s try to enter text in search field on geeksforgeeks and then submit its contents.Program –
# import webdriverfrom selenium import webdriver  # create webdriver objectdriver = webdriver.Firefox()  # get geeksforgeeks.orgdriver.get("https://www.geeksforgeeks.org/")  # get element element = driver.find_element_by_id("gsc-i-id2")  # send keys element.send_keys("Arrays")  # submit contentselement.submit()
Output-
Python-selenium
selenium
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Using Threads in Rust Programming

We know that a process is a program in a running state. The Operating System maintains and manages multiple processes at once. These processes are run on independent parts and these independent parts are known as threads.
Rust provides an implementation of 1:1 threading. It provides different APIs that
handles the case of thread creation, joining, and many such methods.
To create a new thread in Rust, we call the thread::spawn function and then pass it a closure, which in turn contains the code that we want to run in the new thread.
Consider the example shown below:
use std::thread;
use std::time::Duration;

fn main() {
   thread::spawn(|| {
      for i in 1..10 {
         println!("hey number {} from the spawned thread!", i);
         thread::sleep(Duration::from_millis(1));
      }
   });

   for i in 1..3 {
      println!("hey number {} from the main thread!", i);
      thread::sleep(Duration::from_millis(1));
   }
}
hey number 1 from the main thread!
hey number 1 from the spawned thread!
hey number 2 from the main thread!
hey number 2 from the spawned thread!
There are chances that a spawned thread might not run, and to handle that case, we store the value returned from thread::spawn in a variable. The return type of thread::spawn is JoinHandle.
A JoinHandle is an owned value that, when we call the join method on it, will wait for its thread to finish
Let’s modify the example shown above just slightly, like this:
use std::thread;
use std::time::Duration;

fn main() {
   let handle = thread::spawn(|| {
      for i in 1..10 {
         println!("hey number {} from the spawned thread!", i);
         thread::sleep(Duration::from_millis(1));
      }
   });
   handle.join().unwrap();
   for i in 1..5 {
      println!("hey number {} from the main thread!", i);
      thread::sleep(Duration::from_millis(1));
   }
}
hey number 1 from the spawned thread!
hey number 2 from the spawned thread!
hey number 3 from the spawned thread!
hey number 4 from the spawned thread!
hey number 5 from the spawned thread!
hey number 6 from the spawned thread!
hey number 7 from the spawned thread!
hey number 8 from the spawned thread!
hey number 9 from the spawned thread!
hey number 1 from the main thread!
hey number 2 from the main thread!
Tryit Editor v3.7

Tryit: Different HSLA colors
Converting ArrayList to HashMap in Java 8 using a Lambda Expression - GeeksforGeeks

17 Aug, 2021
A lambda expression is one or more line of code which works like function or method. It takes a parameter and returns the value. Lambda expression can be used to convert ArrayList to HashMap.
Syntax:
(parms1, parms2) -> expression
Examples:
Input : List : [1="1", 2="2", 3="3"]
Output: Map  : {1=1, 2=2, 3=3, 4=4, 5=5}

Input : List : [1="I", 2="love", 3="Geeks" , 4="for" , 5="Geeks"]
Output: Map  : {1=I, 2=Love, 3=Geeks, 4=For, 5=Geeks}
Approach:
Get the List to be converted into MapCreate an empty MapPut the list values to the map using Lambda ExpressionReturn the formed Map
Get the List to be converted into Map
Create an empty Map
Put the list values to the map using Lambda Expression
Return the formed Map
Below is the implementation of the above approach.
Java
// Converting ArrayList to HashMap// in Java 8 using a Lambda Expressionimport java.util.*;import java.util.ArrayList;import java.util.Scanner; // here we are making a class , and we will makeclass ListItems {     // key will act as an id of the value    private Integer key;     // value will be the value of the above key    private String value;     // create constructor for reference    public ListItems(Integer id, String name)    {         // assigning the value of key and value        this.key = id;        this.value = name;    }     // return private variable key    public Integer getkey() { return key; }     // return private variable name    public String getvalue() { return value; }}class Main {    public static void main(String[] args)    {        // Write your code here         // Creating a List of type ListItems using ArrayList        List<ListItems> list = new ArrayList<ListItems>();         // add the member of list        list.add(new ListItems(1, "I"));        list.add(new ListItems(2, "Love"));        list.add(new ListItems(3, "Geeks"));        list.add(new ListItems(4, "For"));        list.add(new ListItems(5, "Geeks"));         // Map which will store the list items        Map<Integer, String> map = new HashMap<>();         // for (ListItems n : list) { map.put(n.getkey(),        // n.getvalue()); }        // the below lambda  performs the same task as the        // above given for loop will do        // put the list items in the Map        list.forEach(            (n) -> { map.put(n.getkey(), n.getvalue()); });         // Printing the given map        System.out.println("Map : " + map);    }}
Map : {1=I, 2=Love, 3=Geeks, 4=For, 5=Geeks}
Time Complexity: O(N), where N is the length of Arraylist.
 
sagartomar9927
Java 8
Java-ArrayList
Java-HashMap
java-lambda
Picked
Technical Scripter 2020
Java
Java Programs
Technical Scripter
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Functional Interfaces in Java
Stream In Java
Constructors in Java
Different ways of Reading a text file in Java
Exceptions in Java
Convert a String to Character array in Java
Java Programming Examples
Convert Double to Integer in Java
Implementing a Linked List in Java using Class
How to Iterate HashMap in Java?
MATCH Function in Excel With Examples

24 May, 2021
Excel contains many useful functions and such a function is the ‘MATCH()’ function. It is basically used to get the relative position of a specific item from a range of cells(i.e. from a row or a column or from a table). This function also supports exact and approximate match like VLOOKUP() function. Generally, MATCH() function is used with the INDEX() function.
With the help of the MATCH() function, the user can get a relative position of a specific element from a table or range of cells. Relative position means the position of the element in the row or column where the MATCH() function is searching for the element. Precisely, this function helps us to get the position of an element in an array.
Syntax:
=MATCH(lookup_value, lookup_array, [match_type])
Here, the [match_type] value denotes if the user wants an exact match or approximate match.
Arguments:
lookup_value (Required): It is the value(text or number or logical value or a cell reference that contains number, text or logical value) that the user wants to search. This argument must be provided by the user.
lookup_array (Required): This argument contains the range of cells or a reference to an array where the MATCH() function will try to find out the lookup_value. Again this argument must be provided by the user.
[match_type] (Optional): This is an optional argument. This value maybe 1, 0 or -1. If the value is 0 the user wants an exact match.  If the value is 1 MATCH() function will return the largest value that is less than or equal to lookup_value and if it is -1 the function will return the smallest value that is greater than or equal to lookup_value.
Note: If [match_type] argument is 1 or -1 then the lookup_array must be in a sorted order(ascending for 1 and descending for -1) and if the argument is not provided by the user the value becomes 1 by default.
Return Value: This function returns a value that represents the relative position of the lookup value in a range of cells.
Examples:
The example of the MATCH() function is given below. The names used in the list are only for example purposes and these are not related to any real persons.
The above list is used for example.
Here [match_type] argument is omitted so the value is 1 and the function 
searches for an approximate match and returns the position
 of the next greater element in the list.
Here [match_type] argument is -1 and the function searches for an approximate match
 and returns the position of the next smallest element in the list.
Below is the output screenshot of the Excel sheet.
Output Screenshot
Picked
Excel
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Delete Blank Columns in Excel?
How to Normalize Data in Excel?
How to Get Length of Array in Excel VBA?
How to Find the Last Used Row and Column in Excel VBA?
How to Use Solver in Excel?
How to make a 3 Axis Graph using Excel?
Introduction to Excel Spreadsheet
Macros in Excel
How to Show Percentages in Stacked Column Chart in Excel?
How to Create a Macro in Excel?
SPACE() function in SQL Server

28 Dec, 2020
SPACE() :This function in SQL Server helps to return a string that has a specified number of spaces. This function is also available in MYSQL with the same name.
Syntax :
SPACE(number)
Parameters :This function accepts only one parameter.
number –It demotes the number of spaces.
Returns :
If the number is positive, the function will return a string that has a specified number of spaces.
If the number is negative, the function will return NULL.
Applicable in the following versions :
SQL Server 2017
SQL Server 2016
SQL Server 2014
SQL Server 2012
SQL Server 2008 R2
SQL Server 2008
SQL Server 2005
Example-1 :Basic working of SPACE() function, the function will return 5 blank spaces.
SELECT SPACE(5) 
AS Result;
Output :The function will return 5 blank spaces.
Example-2 :Concatenating 2 or more strings using SPACE() function.
Concatenating 2 strings using the SPACE() function, we take 2 strings and assign specific spaces in between.SELECT 'HI!' + SPACE(6) + 'NiceToSeeYou' 
AS Result;Output :ResultHI! NiceToSeeYou
SELECT 'HI!' + SPACE(6) + 'NiceToSeeYou' 
AS Result;
Output :
Concatenating 3 strings using SPACE() function, we take 2 strings and assign specific spaces among them.SELECT 'GEEKS' + SPACE(5) + 'FOR'+ SPACE(5) +'GEEKS' AS Result;Output :ResultGEEKS     FOR GEEKS
SELECT 'GEEKS' + SPACE(5) + 'FOR'+ SPACE(5) +'GEEKS' AS Result;
Output :
Example-3 :If the user enters a negative number as an argument, then the function will return NULL.
SELECT SPACE(-20) 
AS Result;
Output :
Example-4 :Working of SPACE() function with variable, we use variable along with SPACE() function.
DECLARE @space_Size int
SET @space_Size = 7
SELECT 'KeepChasing' + SPACE(@space_size) + 'YourDreams' 
AS Result;
Output :
DBMS-SQL
SQL-Server
Technical Scripter 2020
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
Window functions in SQL
What is Temporary Table in SQL?
SQL | Sub queries in From Clause
SQL using Python
RANK() Function in SQL Server
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL Query to Compare Two Dates
How to Write a SQL Query For a Specific Date Range and Date Time?