code-rag-bench/online-tutorials huggingface dataset:
Python | Iterating two lists at once

27 Aug, 2019
Sometimes, while working with Python list, we can have a problem in which we have to iterate over two list elements. Iterating one after another is an option, but it’s more cumbersome and a one-two liner is always recommended over that. Let’s discuss certain ways in which this task can be performed.
Method #1 : Using loop + “+” operatorThe combination of above functionalities can make our task easier. But the drawback here is that we might have to concatenate the list and hence would consume more memory than desired.
# Python3 code to demonstrate working of# Iterating two lists at once# using loop + "+" operator  # initializing liststest_list1 = [4, 5, 3, 6, 2]test_list2 = [7, 9, 10, 0]  # printing original listsprint("The original list 1 is : " + str(test_list1))print("The original list 2 is : " + str(test_list2))  # Iterating two lists at once# using loop + "+" operator# printing result print("The paired list contents are : ")for ele in test_list1 + test_list2:    print(ele, end =" ")
The original list 1 is : [4, 5, 3, 6, 2]
The original list 2 is : [7, 9, 10, 0]
The paired list contents are : 
4 5 3 6 2 7 9 10 0 

 
Method #2 : Using chain()This is the method similar to above one, but it’s slightly more memory efficient as the chain() is used to perform the task and creates an iterator internally.
# Python3 code to demonstrate working of# Iterating two lists at once# using chain()from itertools import chain  # initializing liststest_list1 = [4, 5, 3, 6, 2]test_list2 = [7, 9, 10, 0]  # printing original listsprint("The original list 1 is : " + str(test_list1))print("The original list 2 is : " + str(test_list2))  # Iterating two lists at once# using chain()# printing result print("The paired list contents are : ")for ele in chain(test_list1, test_list2):    print(ele, end =" ")
The original list 1 is : [4, 5, 3, 6, 2]
The original list 2 is : [7, 9, 10, 0]
The paired list contents are : 
4 5 3 6 2 7 9 10 0 

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – Extract ith column values from jth column values

10 Jul, 2020
Sometimes, while working with Python Matrix, we can have a problem in which we need to extract ith column values from comparing values from jth column. This kind of problem can occur in domains such as school programming or web development. Let’s discuss certain ways in which this task can be performed.
Input : test_list = [[4, 5, 6], [2, 5, 7], [9, 8, 2], [10, 2, 6]], search_list = [4, 9], search_idx = 0, ext_idx = 2Output : [6, 2]
Input : test_list = [[4, 5, 6], [2, 5, 7], [9, 8, 2], [10, 2, 6]], search_list = [2, 6], search_idx = 2, ext_idx = 0Output : [4, 9, 10]
Method #1 : Using loopThis is brute way to solve this problem. In this, we loop through each row and compare the jth column with list elements, if present, extract the ith element.
# Python3 code to demonstrate working of # Extract ith column values from jth column values# Using loop  # initializing listtest_list = [[4, 5, 6], [2, 5, 7], [9, 8, 2], [10, 2, 6]]  # printing original listprint("The original list is : " + str(test_list))  # initializing list search_list = [5, 2]  # initializing search index search_idx = 1  # initializing extract indexext_idx = 2  # Extract ith column values from jth column values# Using loopres = []for sub in test_list:    if sub[search_idx] in search_list:        res.append(sub[ext_idx])    # printing result print("The extracted elements : " + str(res)) 
The original list is : [[4, 5, 6], [2, 5, 7], [9, 8, 2], [10, 2, 6]]
The extracted elements : [6, 7, 6]

 
Method #2 : Using set() + list comprehensionThe combination of above functions can be used to solve this problem. In this, we perform the task of extracting elements in a similar way as above method, just using shorthand. Also, for initial data search reduction, the search list is converted to set(), to remove duplicated.
# Python3 code to demonstrate working of # Extract ith column values from jth column values# Using set() + list comprehension  # initializing listtest_list = [[4, 5, 6], [2, 5, 7], [9, 8, 2], [10, 2, 6]]  # printing original listprint("The original list is : " + str(test_list))  # initializing list search_list = [5, 2]  # initializing search index search_idx = 1  # initializing extract indexext_idx = 2  # Extract ith column values from jth column values# Using set() + list comprehensiontemp = set(search_list)res = [sub[ext_idx] for sub in test_list if sub[search_idx] in search_list]    # printing result print("The extracted elements : " + str(res)) 
The original list is : [[4, 5, 6], [2, 5, 7], [9, 8, 2], [10, 2, 6]]
The extracted elements : [6, 7, 6]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Wand text() function in Python

10 May, 2020
Text can also be added using wand.drawing object. text() function is used to add text in the Drawing object. It takes x and y coordinates and string that we wan to write on (x, y) position.
Syntax :
wand.drawing.text(x, y, body)

Parameters :
Example #1:
# Import different modules of wandfrom wand.image import Imagefrom wand.drawing import Drawingfrom wand.color import Colorimport math   with Drawing() as draw:    with Image(width = 200, height = 200, background = Color('lightgreen')) as image:          draw.font = 'wandtests/assets/League_Gothic.otf'        draw.font_size = 10        draw.text(image.width / 2, image.height / 2, 'GeeksForGeeks')        draw(image)        image.save(filename = "text.png")
Output:
Example #2:
# Import different modules of wandfrom wand.image import Imagefrom wand.drawing import Drawingfrom wand.color import Colorimport math   with Drawing() as draw:    with Image(filename = "gog.png") as image:        draw.font = 'wandtests / assets / League_Gothic.otf'        draw.font_size = 10        draw.text(image.width / 2, image.height / 2, 'GeeksForGeeks')        draw(image)        image.save(filename = "text.png")
Output :
Python-wand
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to sort a slice in Golang?

28 Aug, 2019
In Go language slice is more powerful, flexible, convenient than an array, and is a lightweight data structure. The slice is a variable-length sequence which stores elements of a similar type, you are not allowed to store different type of elements in the same slice.In Go language, you can sort a slice with the help of Slice() function. This function sorts the specified slice given the provided less function. The result of this function is not stable. So for stable sort, you can use SliceStable. And this function panics if the specified interface is not of slice type. It is defined under the sort package so, you have to import sort package in your program for accessing Slice function.
Syntax:
func Slice(a_slice interface{}, less func(p, q int) bool)
Example:
// Go program to illustrate// how to sort a slicepackage main  import (    "fmt"    "sort")  // Main functionfunc main() {      // Creating and initializing    // a structure    Author := []struct {        a_name    string        a_article int        a_id      int    }{        {"Mina", 304, 1098},        {"Cina", 634, 102},        {"Tina", 104, 105},        {"Rina", 10, 108},        {"Sina", 234, 103},        {"Vina", 237, 106},        {"Rohit", 56, 107},        {"Mohit", 300, 104},        {"Riya", 4, 101},        {"Sohit", 20, 110},    }      // Sorting Author by their name    // Using Slice() function    sort.Slice(Author, func(p, q int) bool {       return Author[p].a_name < Author[q].a_name })          fmt.Println("Sort Author according to their names:")    fmt.Println(Author)      // Sorting Author by their    // total number of articles    // Using Slice() function    sort.Slice(Author, func(p, q int) bool {        return Author[p].a_article < Author[q].a_article })          fmt.Println()    fmt.Println("Sort Author according to their"+                    " total number of articles:")          fmt.Println(Author)      // Sorting Author by their ids    // Using Slice() function    sort.Slice(Author, func(p, q int) bool {      return Author[p].a_id < Author[q].a_id })          fmt.Println()    fmt.Println("Sort Author according to the their Ids:")    fmt.Println(Author)}
Output:
Sort Author according to their names:[{Cina 634 102} {Mina 304 1098} {Mohit 300 104} {Rina 10 108} {Riya 4 101} {Rohit 56 107} {Sina 234 103} {Sohit 20 110} {Tina 104 105} {Vina 237 106}]
Sort Author according to their total number of articles:[{Riya 4 101} {Rina 10 108} {Sohit 20 110} {Rohit 56 107} {Tina 104 105} {Sina 234 103} {Vina 237 106} {Mohit 300 104} {Mina 304 1098} {Cina 634 102}]
Sort Author according to the their Ids:[{Riya 4 101} {Cina 634 102} {Sina 234 103} {Mohit 300 104} {Tina 104 105} {Vina 237 106} {Rohit 56 107} {Rina 10 108} {Sohit 20 110} {Mina 304 1098}]
Golang
Golang-Slices
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python string | isdecimal()

05 Jan, 2018
isdecimal()-It is a function in Python that returns true if all characters in a string are decimal. If all characters are not decimal then it returns false.
Syntax:
string_name.isdecimal()Here string_name is the string whose characters are to be checked
Parameters:This method does not takes any parameters .
Returns Value:
True – all characters are decimalFalse – one or more then one character is not decimal.
Below is the Python3 implementation of isdecimal() method:
# Python3 program to demonstrate the use# of isdecimal()   s = "12345"print(s.isdecimal())  # contains alphabetss = "12geeks34"print(s.isdecimal())  # contains numbers and spacess = "12 34"print(s.isdecimal())
Output:
True
False
False

python-string
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
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
Different ways to create Pandas Dataframe
Taking input in Python
Enumerate() in Python
Read a file line by line in Python
How to Install PIP on Windows ?
LocalDate toString() method in Java with Examples

17 Dec, 2018
The toString() method of a LocalDate class is used to get this date as a String, such as 2019-01-01.The output will be in the ISO-8601 format uuuu-MM-dd.
Syntax:
public String toString()

Parameters: This method does not accepts any parameters.
Return value: This method returns String which is the representation of this date, not null.
Below programs illustrate the toString() method:
Program 1:
// Java program to demonstrate// LocalDate.toString() method  import java.time.*;  public class GFG {    public static void main(String[] args)    {          // create a LocalDate object        LocalDate localD            = LocalDate.parse("2018-12-06");          // print LocalDate        System.out.println("LocalDate: "                           + localD.toString());    }}
LocalDate: 2018-12-06

Program 2:
// Java program to demonstrate// LocalDate.toString() method  import java.time.*;  public class GFG {    public static void main(String[] args)    {          // create a LocalDate object        LocalDate localD            = LocalDate.parse("2021-06-30");          // print LocalDate        System.out.println("LocalDate: "                           + localD.toString());    }}
LocalDate: 2021-06-30

Reference: https://docs.oracle.com/javase/10/docs/api/java/time/LocalDate.html#toString()
Java-Functions
Java-LocalDate
Java-time package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
HTTP headers | Vary

27 Feb, 2020
The HTTP Vary header is a response-type type header. It is used to indicate which headers it used when selecting a representation of a resource in a content negotiation algorithm and determines how to match future request headers to decide whether a cached response can be used rather than requesting a fresh one from the origin server. If you want to serve different content for the mobile users, then it can help to avoid that a cache may mistakenly serve a desktop version of your site to your mobile users. It will help search engines to discover the mobile version of a page.
Syntax:
Vary: *
OR
Vary: <header-name>
Directives: There are two directives accepted by HTTP headers Vary.
*: This wild card directive that will be used to match all future request headers to decide whether a cached response.
<header-name>: This directive holds the header name, also can hold multiple headers, that will be used to match future request headers to decide whether a cached response.
Example:
Vary: Accept-Encoding
Vary: User-Agent
To check this Vary in action go to Inspect Element -> Network check the response header for Vary like below, Vary is highlighted you can see.Supported Browsers: The browsers compatible with HTTP headers Vary are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
HTTP-headers
Picked
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
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
REST API (Introduction)
Difference Between PUT and PATCH Request
ReactJS | Router
How to float three div side by side using CSS?
Design a Tribute Page using HTML & CSS
Roadmap to Learn JavaScript For Beginners
Queue Program In C

We shall see the stack implementation in C programming language here. You can try the program by clicking on the Try-it button. To learn the theory aspect of stacks, click on visit previous page.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>

#define MAX 6

int intArray[MAX];
int front = 0;
int rear = -1;
int itemCount = 0;

int peek() {
   return intArray[front];
}

bool isEmpty() {
   return itemCount == 0;
}

bool isFull() {
   return itemCount == MAX;
}

int size() {
   return itemCount;
}  

void insert(int data) {

   if(!isFull()) {
	
      if(rear == MAX-1) {
         rear = -1;            
      }       

      intArray[++rear] = data;
      itemCount++;
   }
}

int removeData() {
   int data = intArray[front++];
	
   if(front == MAX) {
      front = 0;
   }
	
   itemCount--;
   return data;  
}

int main() {
   /* insert 5 items */
   insert(3);
   insert(5);
   insert(9);
   insert(1);
   insert(12);

   // front : 0
   // rear  : 4
   // ------------------
   // index : 0 1 2 3 4 
   // ------------------
   // queue : 3 5 9 1 12
   insert(15);

   // front : 0
   // rear  : 5
   // ---------------------
   // index : 0 1 2 3 4  5 
   // ---------------------
   // queue : 3 5 9 1 12 15
	
   if(isFull()) {
      printf("Queue is full!\n");   
   }

   // remove one item 
   int num = removeData();
	
   printf("Element removed: %d\n",num);
   // front : 1
   // rear  : 5
   // -------------------
   // index : 1 2 3 4  5
   // -------------------
   // queue : 5 9 1 12 15

   // insert more items
   insert(16);

   // front : 1
   // rear  : -1
   // ----------------------
   // index : 0  1 2 3 4  5
   // ----------------------
   // queue : 16 5 9 1 12 15

   // As queue is full, elements will not be inserted. 
   insert(17);
   insert(18);

   // ----------------------
   // index : 0  1 2 3 4  5
   // ----------------------
   // queue : 16 5 9 1 12 15
   printf("Element at front: %d\n",peek());

   printf("----------------------\n");
   printf("index : 5 4 3 2  1  0\n");
   printf("----------------------\n");
   printf("Queue:  ");
	
   while(!isEmpty()) {
      int n = removeData();           
      printf("%d ",n);
   }   
}
If we compile and run the above program, it will produce the following result −
Queue is full!
Element removed: 3
Element at front: 5
----------------------
index : 5 4 3 2 1 0
----------------------
Queue: 5 9 1 12 15 16


    42 Lectures 
     1.5 hours 

 Ravi Kiran

    141 Lectures 
     13 hours 

 Arnab Chakraborty

    26 Lectures 
     8.5 hours 

 Parth Panjabi

    65 Lectures 
     6 hours 

 Arnab Chakraborty

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    64 Lectures 
     10.5 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
Java program to find the LCM of two numbers

L.C.M. or Least Common Multiple of two values is the smallest positive value which the multiple of both values.
For example multiples of 3 and 4 are:
3 → 3, 6, 9, 12, 15 ...
4 → 4, 8, 12, 16, 20 ...
The smallest multiple of both is 12, hence the LCM of 3 and 4 is 12.
Initialize A and B with positive integers.
 Store maximum of A & B to the max.
 Check if max is divisible by A and B.
 If divisible, Display max as LCM.
 If not divisible then step increase max, go to step 3.
public class LCMOfTwoNumbers {
   public static void main(String args[]){
      int a, b, max, step, lcm = 0;
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter first number ::");
      a = sc.nextInt();
      System.out.println("Enter second number ::");
      b = sc.nextInt();

      if(a > b){
         max = step = a;
      }
      else{
         max = step = b;
      }

      while(a!= 0) {
         if(max % a == 0 && max % b == 0) {
            lcm = max;
            break;
         }
         max += step;
      }
      System.out.println("LCM of given numbers is :: "+lcm);
   }
}
Enter first number ::
6
Enter second number ::
10
LCM of given numbers is :: 30
JavaScript exec() Method

The exec() method executes the search for match and if the matched text is found in the specified string then it is returned otherwise null is returned.
Following is the code for the JavaScript exec() Method −
<!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;
   }
   .sample {
      font-size: 18px;
      font-weight: 500;
   }
</style>
</head>
<body>
<h1>JavaScript exec()</h1>
<div class="sample">
Lorem ipsum dolor, sit amet consectetur adipisicing.
</div>
<button class="Btn">CLICK HERE</button>
<h3>
Click on the above buttons to execute regex
</h3>
<script>
   let sampleEle = document.querySelector(".sample");
   let sampleStr = sampleEle.innerHTML;
   let pattern = new RegExp("amet");
   document.querySelector(".Btn").addEventListener("click", () => {
      let result = pattern.exec(sampleStr);
      sampleEle.innerHTML += " <br> String matched = " + result;
   });
</script>
</body>
</html>
On clicking the “CLICK HERE” button −
super keyword in Java

super variable refers immediate parent class instance.
super variable can invoke immediate parent class method.
super() acts as immediate parent class constructor and should be first line in child class constructor.
When invoking a superclass version of an overridden method the super keyword is used.
Live Demo
class Animal {
   public void move() {
      System.out.println("Animals can move");
   }
}
class Dog extends Animal {
   public void move() {
      super.move(); // invokes the super class method
      System.out.println("Dogs can walk and run");
   }
}
public class TestDog {
   public static void main(String args[]) {
      Animal b = new Dog(); // Animal reference but Dog object
      b.move(); // runs the method in Dog class
   }
}
This will produce the following result −
Animals can move
Dogs can walk and run
How to start windows service with display name in PowerShell?

To stop the service using display name, use the parameter –DisplayName.
For Example,
PS C:\> Start-Service -DisplayName "Print Spooler" -Verbose
VERBOSE: Performing the operation "Start-Service" on target "Print Spooler (Spooler)".
You can also start the service with display name using,
PS C:\> Get-Service -DisplayName "Print Spooler" | Start-Service -Verbose
break - Unix, Linux Command

break - To make exit from a for, while, until, or select loop.
break [n]
Create a Utility Class to use break.
#breaksample
for myloop in 1 2 3 4 5 
do 
  echo -n "$myloop"
  if [ "$myloop" -eq 3 ] 
   then 
   break # This line will break out of the loop
  fi
done

Run the utility
$ chmod a+x breaksample
$ ./breaksample
123


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Switch Statements in VBScript

When a user wants to execute a group of statements depending upon a value of an expression, then he can use Select Case statements. Each value is called a Case, and the variable being switched ON based on each case. Case Else statement is executed if test expression doesn't match any of the Case specified by the user.
Case Else is an optional statement within Select Case, however, it is a good programming practice to always have a Case Else statement.
The syntax of a Select Statement in VBScript is −
Select Case expression
   Case expressionlist1
      statement1
      statement2
      ....
      ....
      statement1n
   Case expressionlist2
      statement1
      statement2
      ....
      ....
   Case expressionlistn
      statement1
      statement2
      ....
      ....   
  Case Else
      elsestatement1
      elsestatement2
      ....
      ....
End Select

<!DOCTYPE html>
<html>
   <body>
      <script language = "vbscript" type = "text/vbscript">
         Dim MyVar
         MyVar = 1

         Select case MyVar
            case 1
               Document.write "The Number is the Least Composite Number"
             
            case 2
               Document.write "The Number is the only Even Prime Number"
             
            case 3
               Document.write "The Number is the Least Odd Prime Number"
             
            case else
               Document.write "Unknown Number"
         End select
      </script>
   </body>
</html>
In the above example, the value of MyVar is 1. Hence, Case 1 would be executed.
The Number is the Least Composite Number 


    63 Lectures 
     4 hours 

 Frahaan Hussain
 Print
 Add Notes
 Bookmark this page
Class and Static Variables in Java

Class variables are also known as static variables, and they are declared outside a method, with the
help of the keyword ‘static’.
Static variable is the one that is common to all the instances of the class. A single copy of the
variable is shared among all objects.
 Live Demo
public class Demo{
   static int my_count=2;
   public void increment(){
      my_count++;
   }
   public static void main(String args[]){
      Demo obj_1=new Demo();
      Demo obj_2=new Demo();
      obj_1.increment();
      obj_2.increment();
      System.out.println("The count of first object is "+obj_1.my_count);
      System.out.println("The count of second object is "+obj_2.my_count);
   }
}
The count of first object is 4
The count of second object is 4
A class named Demo defines a static variable, and a function named ‘increment’ that increments the
value of the static variable. The main function creates two instances of the class, and the increment
function is called on both the object. The count is printed on the screen. It shows that static variable
is shared between objects.
How to Install conda in Windows? - GeeksforGeeks

20 Apr, 2022
Anaconda is open-source software that contains Jupyter, spyder, etc that is used for large data processing, data analytics, heavy scientific computing. 
Conda is a package and environment management system that is available across Windows, Linux, and MacOS, similar to PIP. It helps in the installation of packages and dependencies associated with a specific language like python, C++, Java, Scala, etc. Conda is also an environment manager and helps to switch between different environments with just a few commands. 
Follow the below steps to install conda on windows:
Step 1: Visit this website and download the Anaconda installer.
Step 2:  Click on the downloaded .exe file and click on Next.
Step 3: Agree to the terms and conditions.
Step 4: Select the installation type.
Step 5: Choose the installation location.
Step 6: Now check the checkbox to add Anaconda to your environment Path and click Install.
This will start the installation.
Step 7: After the installation is complete you’ll get the following message, here click on Next.
Step 8: You’ll get the following screen once the installation is ready to be used. Here click on Finish.
Now open up the Anaconda Power Shell prompt and use the below command to check the conda version:
conda -V
If conda is installed successfully, you will get a message as shown below:
Blogathon-2021
how-to-install
Picked
Blogathon
How To
Installation Guide
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Banking Transaction System using Java
How to Connect Python with SQL Database?
How to parse JSON Data into React Table Component ?
Changing CSS styling with React onClick() Event
How to build a basic CRUD app with Node.js and ReactJS ?
How to Install PIP on Windows ?
How to Find the Wi-Fi Password Using CMD in Windows?
How to Align Text in HTML?
Java Tutorial
How to install Jupyter Notebook on Windows?
SQLAlchemy Core - Creating Table

Let us now discuss how to use the create table function.
The SQL Expression Language constructs its expressions against table columns. SQLAlchemy Column object represents a column in a database table which is in turn represented by a Tableobject. Metadata contains definitions of tables and associated objects such as index, view, triggers, etc.
Hence an object of MetaData class from SQLAlchemy Metadata is a collection of Table objects and their associated schema constructs. It holds a collection of Table objects as well as an optional binding to an Engine or Connection.
from sqlalchemy import MetaData
meta = MetaData()
Constructor of MetaData class can have bind and schema parameters which are by default None.
Next, we define our tables all within above metadata catalog, using the Table construct, which resembles regular SQL CREATE TABLE statement.
An object of Table class represents corresponding table in a database. The constructor takes the following parameters −
Column object represents a column in a database table. Constructor takes name, type and other parameters such as primary_key, autoincrement and other constraints.
SQLAlchemy matches Python data to the best possible generic column data types defined in it. Some of the generic data types are −
BigInteger
Boolean
Date
DateTime
Float
Integer
Numeric
SmallInteger
String
Text
Time
To create a students table in college database, use the following snippet −
from sqlalchemy import Table, Column, Integer, String, MetaData
meta = MetaData()

students = Table(
   'students', meta, 
   Column('id', Integer, primary_key = True), 
   Column('name', String), 
   Column('lastname', String), 
)
The create_all() function uses the engine object to create all the defined table objects and stores the information in metadata.
meta.create_all(engine)

Complete code is given below which will create a SQLite database college.db with a students table in it.
from sqlalchemy import create_engine, MetaData, Table, Column, Integer, String
engine = create_engine('sqlite:///college.db', echo = True)
meta = MetaData()

students = Table(
   'students', meta, 
   Column('id', Integer, primary_key = True), 
   Column('name', String), 
   Column('lastname', String),
)
meta.create_all(engine)
Because echo attribute of create_engine() function is set to True, the console will display the actual SQL query for table creation as follows −
CREATE TABLE students (
   id INTEGER NOT NULL,
   name VARCHAR,
   lastname VARCHAR,
   PRIMARY KEY (id)
)
The college.db will be created in current working directory. To check if the students table is created, you can open the database using any SQLite GUI tool such as SQLiteStudio.
The below image shows the students table that is created in the database −

    21 Lectures 
     1.5 hours 

 Jack Chan
 Print
 Add Notes
 Bookmark this page
VBA - Left

The Left function returns a specified number of characters from the left side of the given input string.
Left(String, Length)

String − A required parameter. Input String from which the specified number of characters to be returned from the left side.
String − A required parameter. Input String from which the specified number of characters to be returned from the left side.
Length − A required parameter. An Integer, which specifies the number of characters to be returned.
Length − A required parameter. An Integer, which specifies the number of characters to be returned.
Add a button and add the following function.
Private Sub Constant_demo_Click()
   Dim var as Variant
   
   var = "Microsoft VBScript"
   msgbox("Line 1 : " & Left(var,2))
   
   var = "MS VBSCRIPT"
   msgbox("Line 2 : " & Left(var,5))
   
   var = "microsoft"
   msgbox("Line 3 : " & Left(var,9))
End Sub
When you execute the above function, it produces the following output.
Line 1 : Mi
Line 2 : MS VB
Line 3 : microsoft


    101 Lectures 
     6 hours 

 Pavan Lalwani

    41 Lectures 
     3 hours 

 Arnold Higuit

    80 Lectures 
     5.5 hours 

 Prashant Panchal

    25 Lectures 
     2 hours 

 Prashant Panchal

    26 Lectures 
     2 hours 

 Arnold Higuit

    92 Lectures 
     10.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
What is Bitwise Left Shift Operator (<<) in JavaScript?

The left shift operator moves all the bits in its first operand to the left by the number of places specified in the second operand. New bits are filled with zeros.Shifting a value left by one position is equivalent to multiplying it by 2, shifting two positions is equivalent to multiplying by 4, and so on.
You can try to run the following code to learn how to work with Bitwise Left Shift Operator −
<html>
   <body>
      <script>
         var a = 2; // Bit presentation 10
         var b = 3; // Bit presentation 11

         document.write("(a << b) => ");
         result =(a << b);
         document.write(result);
      </script>
   </body>
</html>
How to measure elapsed time in python?

To measure time elapsed during program's execution, either use time.clock() or time.time() functions. The python docs state that this function should be used for benchmarking purposes. 
import time
t0= time.clock()
print("Hello")
t1 = time.clock() - t0
print("Time elapsed: ", t1) # CPU seconds elapsed (floating point)
This will give the output −
Time elapsed:  1.2999999999999123e-05
You can also use the time module to get proper statistical analysis of a code snippet's execution time.  It runs the snippet multiple times and then it tells you how long the shortest run took. You can use it as follows:
def f(x):

  return x * x

import timeit

timeit.repeat("for x in range(100): f(x)", "from __main__ import f", number=100000)
This will give the output −
[2.0640320777893066, 2.0876040458679199, 2.0520210266113281]
Flask â Variable Rules

It is possible to build a URL dynamically, by adding variable parts to the rule parameter. This variable part is marked as <variable-name>. It is passed as a keyword argument to the function with which the rule is associated.
In the following example, the rule parameter of route() decorator contains <name> variable part attached to URL ‘/hello’. Hence, if the http://localhost:5000/hello/TutorialsPoint is entered as a URL in the browser, ‘TutorialPoint’ will be supplied to hello() function as argument.
from flask import Flask
app = Flask(__name__)

@app.route('/hello/<name>')
def hello_name(name):
   return 'Hello %s!' % name

if __name__ == '__main__':
   app.run(debug = True)
Save the above script as hello.py and run it from Python shell. Next, open the browser and enter URL http://localhost:5000/hello/TutorialsPoint.
The following output will be displayed in the browser.
Hello TutorialsPoint!

In addition to the default string variable part, rules can be constructed using the following converters −
int
accepts integer
float
For floating point value
path
accepts slashes used as directory separator character
In the following code, all these constructors are used.
from flask import Flask
app = Flask(__name__)

@app.route('/blog/<int:postID>')
def show_blog(postID):
   return 'Blog Number %d' % postID

@app.route('/rev/<float:revNo>')
def revision(revNo):
   return 'Revision Number %f' % revNo

if __name__ == '__main__':
   app.run()
Run the above code from Python Shell. Visit the URL http://localhost:5000/blog/11 in the browser.
The given number is used as argument to the show_blog() function. The browser displays the following output −
Blog Number 11

Enter this URL in the browser − http://localhost:5000/rev/1.1
The revision() function takes up the floating point number as argument. The following result appears in the browser window −
Revision Number 1.100000

The URL rules of Flask are based on Werkzeug’s routing module. This ensures that the URLs formed are unique and based on precedents laid down by Apache.
Consider the rules defined in the following script −
from flask import Flask
app = Flask(__name__)

@app.route('/flask')
def hello_flask():
   return 'Hello Flask'

@app.route('/python/')
def hello_python():
   return 'Hello Python'

if __name__ == '__main__':
   app.run()
Both the rules appear similar but in the second rule, trailing slash (/) is used. As a result, it becomes a canonical URL. Hence, using /python or /python/ returns the same output. However, in case of the first rule, /flask/ URL results in 404 Not Found page.

    22 Lectures 
     6 hours 

 Malhar Lathkar

    21 Lectures 
     1.5 hours 

 Jack Chan

    16 Lectures 
     4 hours 

 Malhar Lathkar

    54 Lectures 
     6 hours 

 Srikanth Guskra

    88 Lectures 
     3.5 hours 

 Jorge Escobar

    80 Lectures 
     12 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
CSS | zoom Property - GeeksforGeeks

19 May, 2020
The zoom property in CSS is used to scale-up or scale-down the content. This property was implemented for Internet Explorer before the latter is supported by a few other browsers.
Syntax:
zoom: percentage | number | normal;
Property Value: This property accepts three types of values as mentioned above and described below:
percentage: This property holding the numbers with the percentage that will increased or decreased compared to the original content makes that zoom-in or out depending on the numbers like zoom:150%;. It means the content will be 150% percentage bigger than the original content.
number: This property holds the number that will be multiplied by the original content makes that zoom-in or out depending on the number like zoom:1.5;. It means the content will be 1.5 times bigger than the original content.
normal: This property holds the normal content which is not zoomed in or out, basically this property is telling the browsers zoom:1
Example: This example uses CSS zoom property to resize the image.
<!DOCTYPE html> <html>   <head>     <title>         CSS | zoom property     </title>       <style>         h1 {             color: green;         }         .left{            zoom: 1.2;        }    </style> </head>   <body>     <center>         <h1>GeeksforGeeks</h1>                   <h4>CSS | zoom property</h4>                   <div>             <img class="left" src= "https://media.geeksforgeeks.org/wp-content/uploads/20190808102629/geeks15.png"                alt="Sample image">               <img class="right" src= "https://media.geeksforgeeks.org/wp-content/uploads/20190808102629/geeks15.png"                alt="Sample image">         </div>     </center> <body>   </html>
Output:
Supported Browsers: The browsers supported by CSS zoom property are listed below:
Google Chrome
Internet Explorer
Safari
CSS-Properties
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to create footer to stay at the bottom of a Web page?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
Create a Responsive Navbar using ReactJS
Design a web page using HTML and CSS
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
Top 10 Angular Libraries For Web Developers
col command in Linux with Examples - GeeksforGeeks

15 May, 2019
col command in Linux system is used to filter out reverse line feeds such that the output looks much more in the correct order with only forward and half forward line feeds and replaces the whitespace characters with tabs wherever possible. This can be proven useful in the processing of the output of nroff and tbl. The col utility simply reads from the standard input and writes to standard output.
Syntax:
col [-bfhpx] [-l num]

Options:
col -b: This option do not show any backspaces. It will print only the last character written to each of the column position.Example:man import | col -b > readme1.txt
Example:
man import | col -b > readme1.txt
col -f: This option will forward half line feeds which are permitted (“fine” mode). Normally characters printed on a half line boundary is being printed on the following line.Example:man cat | col -f > readme2.txt
Example:
man cat | col -f > readme2.txt
-h : This option does not allow to show multiple spaces instead of tabs.Example:man cp | col -h > readme3.txt
Example:
man cp | col -h > readme3.txt
-l num : This option will buffer at least num lines in memory. By default, 128 lines is buffered.Example:man chmod | col -l 29 > readme4.txt
Example:
man chmod | col -l 29 > readme4.txt
-p : This option will force unknown control sequences to be passed through unchanged. Normally, col will filter out any of the control sequences from the input other than those recognized and interpreted by itself.Example:man wget | col -p > readme5.txt
Example:
man wget | col -p > readme5.txt
-x : This option will going to output multiple spaces instead of tabs..Example:man mount | col -x > readme6.txt
Example:
man mount | col -x > readme6.txt
linux-command
Linux-misc-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Thread functions in C/C++
Basic Operators in Shell Scripting
nohup Command in Linux with Examples
Array Basics in Shell Scripting | Set 1
Named Pipe or FIFO with example C program
chown command in Linux with Examples
mv command in Linux with examples
Docker - COPY Instruction
Start/Stop/Restart Services Using Systemctl in Linux
SED command in Linux | Set 2
Embedding small plots inside subplots in Matplotlib

To embed small plots inside subplots, we can take the following Steps −
Using subplots() method, create a figure and a set of subplots (fig, ax1).
Using subplots() method, create a figure and a set of subplots (fig, ax1).
On ax1, plot a line with color red, line width=4, label=”outer plot”.
On ax1, plot a line with color red, line width=4, label=”outer plot”.
Using add_axes(), add an axis, i.e., ax2 with l, b, h and w values.
Using add_axes(), add an axis, i.e., ax2 with l, b, h and w values.
Plot the same points (Step 2) usins the plot() method, with color green, line width=3, label=”inside plot”.
Plot the same points (Step 2) usins the plot() method, with color green, line width=3, label=”inside plot”.
Set the legend on both the plots using the legend() method.
Set the legend on both the plots using the legend() method.
To display the figure, use the show() method.
To display the figure, use the show() method.
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
fig, ax1 = plt.subplots()
ax1.plot([1, 4, 6, 2, 1, 5, 2], c="red", lw=4, label="outer plot")
l, b, h, w = .6, .75, .1, .2
ax2 = fig.add_axes([l, b, w, h])
ax2.plot([1, 4, 6, 2, 1, 5, 2], color='green', lw=3, label="inside plot")
ax1.legend(loc='upper left')
ax2.legend(loc='upper left')
plt.show()
Angular CLI - Overview

Angular command-line interface (CLI) makes it easy to start with any Angular project. It comes with commands that help us create and start on our project very fast. Let us now go through the commands available to create a project, a component and services, change the port, etc.
To work with Angular CLI, we need to have it installed on our system. Let us use the following command for the same −
npm install -g @angular/cli

To create a new project, we can run the following command in the command line and the project will be created.
ng new PROJECT-NAME
cd PROJECT-NAME
ng serve //

ng serve // will compile and you can see the output of your project in the browser −
http://localhost:4200/

4200 is the default port used when a new project is created. You can change the port with the following command −
ng serve --host 0.0.0.0 --port 4201

The following table lists down a few important commands which are required while working with the Angular 4 projects.
Component
ng g component new−component
Directive
ng g directive new−directive
Pipe
ng g pipe new−pipe
Service
ng g service new−service
Module
ng g module my−module
Whenever a new module, a component, or a service is created, the reference of the same is updated in the parent module app.module.ts.

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
java.time.Period Class

The java.time.Period class models a quantity or amount of time in terms of years, months and days.
Following is the declaration for java.time.Period class −
public final class Period
   extends Object
      implements ChronoPeriod, Serializable

Following are the fields for Java.time.Period class −
static Period ZERO − Constant for a Period of zero.
static Period ZERO − Constant for a Period of zero.
Adds this Period to the specified temporal object.
Obtains a Period consisting of the number of years, months, and days between two dates.
Checks if this Period is equal to the specified Period.
Obtains an instance of Period from a temporal amount.
Gets the value of the requested unit.
Gets the chronology of this period, which is the ISO calendar system.
Gets the amount of days of this period.
Gets the amount of months of this period.
Gets the set of units supported by this Period.
A hash code for this Period.
Checks if this Period is negative, excluding zero.
Checks if this Period is zero length.
Returns a copy of this Period with the specified Period subtracted.
Returns a copy of this period with the specified days subtracted.
Returns a copy of this period with the specified months subtracted.
Returns a copy of this period with the specified years subtracted.
Returns a copy of this Period multiplied by the scalar.
Returns a copy of this Period with the length negated.
Returns a copy of this period with the years and months normalized.
Obtains a Period representing a number of years, months and days.
Obtains a Period representing a number of days.
Obtains a Period representing a number of months.
Obtains a Period representing a number of weeks.
Obtains a Period representing a number of weeks.
Obtains a Period from a text string such as PnYnMnD.
Returns a copy of this Period with the specified Period added.
Returns a copy of this period with the specified days added.
Returns a copy of this period with the specified months added.
Returns a copy of this period with the specified years added.
Subtracts this Period from the specified temporal object.
A string representation of this Period using ISO-8601 seconds based representation, such as PT8H6M12.345S.
Gets the total number of months in this period.
Returns a copy of this period with the specified amount of days.
Returns a copy of this period with the specified amount of months.
Returns a copy of this period with the specified amount of Years.
This class inherits methods from the following classes −
Java.lang.Object
 Print
 Add Notes
 Bookmark this page
MongoDB $addToSet to add a deep nested array of object?

The addToSetoperatoraddsavaluetoanarrayunlessthevalueisalreadypresent,inwhichcaseaddToSet does nothing to that array.
Let us first create a collection with documents −
> db.demo380.insertOne({
...
...    "details" : [
...       {
...          "Name" : "Chris",
...          "details1" : [ ]
...       },
...       {
...          "Name" : "David",
...          "details1" : [ ]
...       }
...    ]
... }
... );
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e5b56e32ae06a1609a00b11")
}
Display all documents from a collection with the help of find() method −
> db.demo380.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5e5b56e32ae06a1609a00b11"),
   "details" : [
      {
         "Name" : "Chris",
         "details1" : [ ]
      },
      {
         "Name" : "David",
         "details1" : [ ]
      }
   ]
}
Following is the query to add a deep nested array of object −
> db.demo380.update({
...    "details.Name": "David"
...    }, {
...    $addToSet: {
...       "details.$.details1": {
...          'SubjectName': "MongoDB",
...          'TeacherName':"Bob"
...       }
...    }
... }, false, true);
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
Display all documents from a collection with the help of find() method −
> db.demo380.find().pretty();
This will produce the following output −
{
   "_id" : ObjectId("5e5b56e32ae06a1609a00b11"),
   "details" : [
      {
         "Name" : "Chris",
         "details1" : [ ]
      },
      {
         "Name" : "David",
         "details1" : [
            {
               "SubjectName" : "MongoDB",
               "TeacherName" : "Bob"
            }
         ]
      }
   ]
}
How to output JavaScript into a Textbox?

You can use the concept of value(). Following is the JavaScript code −
 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>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<label for="">FirstNumber </label><input type="textbox" name="input1"><br>
<label for="">SecondNumber: </label><input type="textbox" name="input2"><br>
<button onClick="add()">Add Two Nnumbers</button><br>
<label for="displayValue">The addition is: </label><input type="textbox" name="display">
<script>
   function add() {
      var f = parseInt(document.getElementsByName('input1')[0].value);`
      var s =parseInt(document.getElementsByName('input2')[0].value);
      var result = f+s;
      document.getElementsByName('display')[0].value= result;
   }
</script>
</body>
</html>
To run the above program, save the file name anyName.html(index.html) and right click on the file and select the option open with live server in VS code editor.
On clicking the button, the value will be displayed in the textbox. The snapshot is as follows −