code-rag-bench/online-tutorials huggingface dataset:
Number Guessing Game using JavaScript - GeeksforGeeks

15 Feb, 2019
Prerequisites:
Basic Knowledge of HTML
Basic Knowledge of Javascript
The game is to guess a random number generated by computer in range 1 – 10 in minimum number of Guesses.
Functions to be used:
1. document.getElementById(“id given”): document.getElementById() is used to fetch an element from the HTML page having the id as provided (specified) by the user.“.value” is used to access the value of the HTML element accessed.
2. Math.random() : The random() function is used to generate a random number between 0 (inclusive) and 1 (exclusive). This generated number is then multiplied with 10 and added 1 to generate numbers from 1 – 10.
3. Math.floor() : The floor() function is used to return the number to the nearest integer (downwards). The value will not be rounded, if the passed argument is an integer.
Implementation of the Game.
                        <!DOCTYPE html><html><head>    <meta charset="utf-8">    <title>Number Guessing Game</title>      <style>        html {    font-family: sans-serif;    }              body {    width: 50%;    max-width: 800px;    min-width: 480px;    margin: 0 auto;    }    </style></head>  <body><h1>Guess The Number</h1>  <p>We have selected a random number between 1 - 10. See if you can guess it.</p>  <div class="form">    <label for="guessField">Enter a guess: </label>    <input type = "text" id = "guessField" class = "guessField">    <input type = "submit" value = "Submit guess"            class = "guessSubmit" id = "submitguess"></div>  <script type = "text/javascript">      // random value generated    var y = Math.floor(Math.random() * 10 + 1);          // counting the number of guesses    // made for correct Guess    var guess = 1;          document.getElementById("submitguess").onclick = function(){         // number guessed by user        var x = document.getElementById("guessField").value;     if(x == y)   {           alert("CONGRATULATIONS!!! YOU GUESSED IT RIGHT IN "               + guess + " GUESS ");   }   else if(x > y) /* if guessed number is greater                   than actual number*/    {           guess++;       alert("OOPS SORRY!! TRY A SMALLER NUMBER");   }   else   {       guess++;       alert("OOPS SORRY!! TRY A GREATER NUMBER")   }}</script></body></html>                    
Output:
JavaScript-Numbers
HTML
JavaScript
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
HTML | <img> align Attribute
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
reflect.Swapper() Function in Golang with Examples - GeeksforGeeks

28 Apr, 2020
Go language provides inbuilt support implementation of run-time reflection and allowing a program to manipulate objects with arbitrary types with the help of reflect package. The reflect.Swapper() Function in Golang is used to swaps the elements in the provided slice. To access this function, one needs to imports the reflect package in the program.
Syntax:
func Swapper(slice interface{}) func(i, j int)

Parameters: This function takes one parameters of Slice type.
Return Value: This function returns the swapped slice.
Below examples illustrate the use of above method in Golang:
Example 1:
// Golang program to illustrate// reflect.Swapper() Function    package main   import (    "fmt"    "reflect")   // Main function func main() {       // Slice     src := []int{1, 2, 3, 4, 5}      fmt.Printf("Before swap: %v\n", src)           // Swapper() function is used    // to swaps the elements in     // the provided slice    swapF := reflect.Swapper(src)       swapF(2, 4)           // printing the values    fmt.Printf("After swap: %v\n", src)}
Output:
Before swap: [1 2 3 4 5]
After swap: [1 2 5 4 3]

Example 2: Reversing a slice using Swapper() function
// Golang program to illustrate// reflect.Swapper() Function    package main   import (    "fmt"    "reflect")   // Main function func main() {       // Slice     src := []int{1, 2, 3, 4, 5, 6, 7}      fmt.Printf("Original Slice: %v\n", src)           // Swapper() function is used    // to swaps the elements in     // the provided slice    swapF := reflect.Swapper(src)      for i := 0; i < len(src)/2; i++ {        swapF(i, len(src)-1-i)    }           // printing the values    fmt.Printf("Reversed Slice: %v\n", src)}
Output:
Original Slice: [1 2 3 4 5 6 7]
Reversed Slice: [7 6 5 4 3 2 1]

Example 3: Sorting of a slice using Swapper() function
// Golang program to illustrate// reflect.Swapper() Function    package main   import (    "fmt"    "reflect")   // Main function func main() {       // Slice     src := []int{1, 2, 6, 3, 8, 0, 7, 9, 5, 4, 42, 1, 3, 4, 3}      fmt.Printf("Original Slice: %v\n", src)           // Swapper() function is used    // to swaps the elements in     //the provided slice    swapF := reflect.Swapper(src)      for i := 0; i < len(src)-1; i++ {        for j := i + 1; j < len(src); j++ {            if src[i] > src[j] {                swapF(i, j)            }        }    }           //printing the values    fmt.Printf("Sorted Slice: %v\n", src)}
Output:
Original Slice: [1 2 6 3 8 0 7 9 5 4 42 1 3 4 3]
Sorted Slice: [0 1 1 2 3 3 3 4 4 5 6 7 8 9 42]

Golang-reflect
Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
6 Best Books to Learn Go Programming Language
How to Parse JSON in Golang?
Strings in Golang
Time Durations in Golang
Structures in Golang
How to iterate over an Array using for loop in Golang?
Rune in Golang
Defer Keyword in Golang
Loops in Go Language
Class and Object in Golang
What are Chrome Flags or Experiments? - GeeksforGeeks

31 Mar, 2021
Chrome Flags also called Experiments are the experimental features that are provided by the Chrome browser but are not a part of the default chrome experience. Anyone can use them by following some simple steps and transform their chrome browsing experience. Some flags eventually become a part of the default public release once they are tried and tested completely. For example, the Tab Groups feature was first introduced as a Chrome flag before it was rolled out as a default feature.
Chrome flags Warning
Flags are experimental features and are not always stable. Using them might make the browser act weird or crash as they haven’t been tested extensively.
Flags are not tested thoroughly for security as well. So you might want to use a different browser or turn them off when doing online banking or other sensitive activities.
To enable a flag, the browser needs to be relaunched. Once the browser is relaunched, all the windows and tabs will reopen while the incognito windows will be lost.
Proceed with Caution 
WARNING: EXPERIMENTAL FEATURES AHEAD! 
By enabling these features, you could lose browser data or compromise your security or privacy. 
Enabled features apply to all users of this browser.
Chrome flags can be accessed on this URL on any chrome browser be it Windows, Chromebook, MacOS, iPhones, or Android.
chrome://flags/
This will take you to the home page of Chrome Experiments where all the chrome flags are available along with their status (Default/Enabled/Disabled).
Let us consider the chrome flag Enable Tab Search. 
There are two ways to access it:
Search with the name in the search box, or 
Search for a flag
Go to the flag tag. For e.g. chrome://flags/#enable-tab-search 
URL for a flag
Then just enable it and relaunch the browser. 
Enable a flag
You can now see the Search Tabs icon on the right side of the title bar. With just a few clicks you can enable a very useful feature.
Individual flags can be reset similarly by changing their state to Default or Disabled. The Reset all button will bring everything back to the default state. In either case, chrome needs to be relaunched to apply the changes.
Here is a link to a list of some chrome flags mentioned on the Google Chrome Github page.
How To
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Align Text in HTML?
How to Install OpenCV for Python on Windows?
How to filter object array based on attributes?
Java Tutorial
How to Install FFmpeg on Windows?
Top Programming Languages for Android App Development
Docker - COPY Instruction
Setting up the environment in Java
How to Run a Python Script using Docker?
Running Python script on GPU.
GATE | GATE-CS-2015 (Set 1) | Question 65 - GeeksforGeeks

28 Jun, 2021
The height of a tree is the length of the longest root-to-leaf path in it. The maximum and minimum number of nodes in a binary tree of height 5 are(A) 63 and 6, respectively(B) 64 and 5, respectively(C) 32 and 6, respectively(D) 31 and 5, respectivelyAnswer: (A)Explanation:
Number of nodes is maximum for a perfect binary tree.
A perfect binary tree of height h has 2h+1 - 1 nodes

Number of nodes is minimum for a skewed binary tree.
A perfect binary tree of height h has h+1 nodes.

Quiz of this Question
GATE-CS-2015 (Set 1)
GATE-GATE-CS-2015 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE MOCK 2017 | Question 24
GATE | GATE-CS-2006 | Question 47
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90
Program to find the diameter, cycles and edges of a Wheel Graph in C++

In this problem, we are given a number that denotes the number of vertices of a Wheel Graph. Our task is to create a Program to find the diameter,
cycles and edges of a Wheel Graph in C++.
Problem description − Here, we need to find the number of cycles, number of edges, and the diameter of Wheel Graph with n vertices.
First, let’s understand some basics about Wheel Graph −
A wheel graph is obtained from a cycle graph Cn-1 by adding a new vertex. That new vertex is called a Hub which is connected to all the vertices of Cn.
Example of a wheel graph with 7 vertices.
Diameter of wheel Graph is the number of edges that we need to cover to go from anyone vertices to others. For the above Wheel Graph, the diameter
is 2
No. of Cycle of Wheel Graph is the total number of closed cycles that can be the given graph. For the above Wheel Graph, the no. of cycles is 31.
No. of Edge of Wheel Graph is the count of edges that connect all the vertices. For the above Wheel Graph, no of edges is 12.
To solve the problem, we will be using the direct formula that is given in the
graph theory to find the required values for a wheel graph.
The Formulas are,
Diameter of a Wheel Graph =
1, if vertices = 4, else 2.
No. of cycles of a Wheel Graph =
(No. of vertices )^2 - (3 * (No. of vertices -1) )
No. of edges of a wheel Graph =
2 * (No. of vertices - 1)
Program to illustrate the working of our solution,
 Live Demo
#include <iostream>
#include <math.h>
using namespace std;
void calcValuesWheelGraph(int V){
   // Calculating the Diameter
   if(V == 4){
      cout<<"The Diameter of the Wheel Graph is 1 "<<endl;
   }
   else {
      cout<<"The Diameter of the Wheel Graph is 2 "<<endl;
   }
   // Calculating the no. of cycles
   cout<<"The number of cycles of the Wheel Graph is "<<(pow(V, 2) - (3 * (V-1)))<<endl;
   // Calculating the no. of Edges
   cout<<"The number of Edges of the Wheel Graph is "<<(2 * (V-1))<<endl;
}
int main(){
   int V = 9;
   calcValuesWheelGraph(V);
   return 0;
}
The Diameter of the Wheel Graph is 2
The number of cycles of the Wheel Graph is 57
The number of Edges of the Wheel Graph is 16
C++ Array Library - data() Function

The C++ function std::array::data() return a pointer pointing to the first element of the array container. As array stores all elements in contigious memory location we can use this poiter to perform all valid operations on array.
Following is the declaration for std::array::data() function form std::array header.
value_type *data() noexcept;
const value_type *data() const noexcept;
None
Returns a pointer to the first element of the array. If array object is const-qualified this method returns const object otherwise it returns non-const object.
This member function never throws exception.
Constant i.e. O(1)
The following example shows the usage of std::array::data() function.
#include <iostream>
#include <array>

using namespace std;

int main(void) {

   array<char, 128> s = {"C++ standard library from tutorialspoint.com"};
   char *p, *q;

   /* pointer to the first element of character array. */
   p = s.data();

   /* print string contents */
   cout << p << endl;

   q = p;

   /* print string using pointer arithmatic */
   while (*q) {
      cout << *q;
      ++q;
   }

   cout << endl;

   return 0;
}
Let us compile and run the above program, this will produce the following result −
C++ standard library from tutorialspoint.com
C++ standard library from tutorialspoint.com

 Print
 Add Notes
 Bookmark this page
Level Order Tree Traversal in Data Structures

In this section we will see the level-order traversal technique for binary search tree.
Suppose we have one tree like this −
The traversal sequence will be like: 10, 5, 16, 8, 15, 20, 23
levelOrderTraverse(root):
Begin
   define queue que to store nodes
   insert root into the que.
   while que is not empty, do
      item := item present at front position of queue
      print the value of item
      if left of the item is not null, then
         insert left of item into que
      end if
      if right of the item is not null, then
         insert right of item into que
      end if
      delete front element from que
   done
End
 Live Demo
#include<iostream>
#include<queue>
using namespace std;
class node{
   public:
      int h_left, h_right, bf, value;
      node *left, *right;
};
class tree{
   private:
      node *get_node(int key);
   public:
      node *root;
      tree(){
         root = NULL; //set root as NULL at the beginning
      }
      void levelorder_traversal(node *r);
      node *insert_node(node *root, int key);
};
node *tree::get_node(int key){
   node *new_node;
   new_node = new node; //create a new node dynamically
   new_node->h_left = 0; new_node->h_right = 0;
   new_node->bf = 0;
   new_node->value = key; //store the value from given key
   new_node->left = NULL; new_node->right = NULL;
   return new_node;
}
void tree::levelorder_traversal(node *root){
   queue <node*> que;
   node *item;
   que.push(root); //insert the root at first
   while(!que.empty()){
      item = que.front(); //get the element from the front end
      cout << item->value << " ";
      if(item->left != NULL) //When left child is present, insert into queue
         que.push(item->left);
      if(item->right != NULL) //When right child is present, insert into queue
         que.push(item->right);
      que.pop(); //remove the item from queue
   }
}
node *tree::insert_node(node *root, int key){
   if(root == NULL){
      return (get_node(key)); //when tree is empty, create a node as root
   }
   if(key < root->value){ //when key is smaller than root value, go to the left
      root->left = insert_node(root->left, key);
   } else if(key > root->value) { //when key is greater than root value, go to the right
      root->right = insert_node(root->right, key);
   }
   return root; //when key is already present, do not insert it again
}
main(){
   node *root;
   tree my_tree;
   //Insert some keys into the tree.
   my_tree.root = my_tree.insert_node(my_tree.root, 10);
   my_tree.root = my_tree.insert_node(my_tree.root, 5);
   my_tree.root = my_tree.insert_node(my_tree.root, 16);
   my_tree.root = my_tree.insert_node(my_tree.root, 20);
   my_tree.root = my_tree.insert_node(my_tree.root, 15);
   my_tree.root = my_tree.insert_node(my_tree.root, 8);
   my_tree.root = my_tree.insert_node(my_tree.root, 23);
   cout << "Level-Order Traversal: ";
   my_tree.levelorder_traversal(my_tree.root);
}
Level-Order Traversal: 10 5 16 8 15 20 23
How to Write a SQL Query For a Specific Date Range and Date Time? - GeeksforGeeks

28 Oct, 2021
In SQL, some problems require us to retrieve rows based on their dates and times. For such cases, we use the DATETIME2 datatype present in SQL. For this article, we will be using the Microsoft SQL Server as our database.
Note – Here, we will use the WHERE and BETWEEN clauses along with the query to limit our rows to the given time. The pattern of saving date and time in MS SQL Server is yyyy:mm: dd hh:mm: ss. The time is represented in a 24-hour format. The date and time are collectively stored in a column using the datatype DATETIME2.
Syntax:
SELECT * FROM TABLE_NAME WHERE DATE_TIME_COLUMN
BETWEEN 'STARTING_DATE_TIME' AND 'ENDING_DATE_TIME';
Step 1: Create a Database. For this use the below command to create a database named GeeksForGeeks.
Query:
CREATE DATABASE GeeksForGeeks
Output:
Step 2: Use the GeeksForGeeks database. For this use the below command.
Query:
USE GeeksForGeeks
Output:
Step 3: Create a table PERSONAL inside the database GeeksForGeeks. This table has 3 columns namely BABY_NAME, WARD_NUMBER, and BIRTH_DATE_TIME containing the name, ward number, and date and time of birth of various babies.
Query:
CREATE TABLE PERSONAL(
BABY_NAME VARCHAR(10),
WARD_NUMBER INT,
BIRTH_DATE_TIME DATETIME2);
Output:
Step 4: Describe the structure of the table PERSONAL.
Query:
EXEC SP_COLUMNS PERSONAL;
Output:
Step 5: Insert 5 rows into the MARKS table.
Query:
INSERT INTO PERSONAL VALUES('TARA',3,'2001-01-10 10:40:50');
INSERT INTO PERSONAL VALUES('ANGEL',4,'2001-03-27 11:00:37');
INSERT INTO PERSONAL VALUES('AYUSH',1,'2002-09-18 13:45:21');
INSERT INTO PERSONAL VALUES('VEER',10,'2005-02-28 21:26:54');
INSERT INTO PERSONAL VALUES('ISHAN',2,'2008-12-25 00:01:00');
Output:
Step 6: Display all the rows of the MARKS table including the 0(zero) values.
Query:
SELECT * FROM PERSONAL;
Output:
Step 7: Retrieve the details of the babies born between 12:00 am, 1st January 2000 and 12:00 pm, 18th September 2002.
Query:
SELECT * FROM PERSONAL WHERE BIRTH_DATE_TIME BETWEEN
'2000-01-01 00:00:00' AND '2002-09-18 12:00:00';
Output:
Step 8: Retrieve the details of the babies born between 11:00 am, 1st May 2001 and 10:00 pm, 1st May 2005.
Query:
SELECT * FROM PERSONAL WHERE BIRTH_DATE_TIME BETWEEN
 '2001-03-01 11:00:00' AND '2005-03-01 22:00:00';
Output:
Step 9: Retrieve the details of the babies born on or after the Christmas of 2005.
Query:
SELECT * FROM PERSONAL WHERE BIRTH_DATE_TIME > 
'2005-12-25 00:00:00';
Output:
Picked
SQL-Query
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Alter Multiple Columns at Once in SQL Server?
How to Update Multiple Columns in Single Update Statement in SQL?
What is Temporary Table in SQL?
SQL using Python
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query for Matching Multiple Values in the Same Column
SQL | Subquery
SQL Query to Insert Multiple Rows
SQL Query to Convert VARCHAR to INT
SQL | Date functions
Find minimum sum of factors of number using C++.

Here we will see how to get a minimum sum of factors of a given number. Suppose a number is 12. We can factorize this in different ways −
12 = 12 * 1 (12 + 1 = 13)
12 = 2 * 6 (2 + 6 = 8)
12 = 3 * 4 (3 + 4 = 7)
12 = 2 * 2 * 3 (2 + 2 + 3 = 7)
The minimum sum is 7. We will take a number, and try to find the minimum factor sum. To get the minimum factor sum, we have to factorize the number as long as possible. In other words, we can say if we try to find the sum S by adding prime factors, then the sum will be minimized.
 Live Demo
#include<iostream>
using namespace std;
int primeFactorSum(int n) {
   int s = 0;
   for (int i = 2; i * i <= n; i++) {
      while (n % i == 0) {
         s += i;
         n /= i;
      }
   }
   s += n;
   return s;
}
int main() {
   int n = 12;
   cout << "Minimum sum of factors: " << primeFactorSum(n);
}
Minimum sum of factors: 7
ArrayList iterator() method in Java with Examples - GeeksforGeeks

11 Dec, 2018
The iterator() method of ArrayList class in Java Collection Framework is used to get an iterator over the elements in this list in proper sequence. The returned iterator is fail-fast.
Syntax:
 Iterator iterator()
Parameter: This method do not accept any parameter.
Return Value: This method returns an iterator over the elements in this list in proper sequence
Below examples illustrate the ArrayList.iterator() method:
Program 1:
// Java code to illustrate iterator()  import java.util.*;  public class GFG {      public static void main(String[] args)    {        // Create and populate the list        ArrayList<String> list            = new ArrayList<>();          list.add("Geeks");        list.add("for");        list.add("Geeks");        list.add("is");        list.add("a");        list.add("CS");        list.add("Students");        list.add("Portal");          // Displaying the list        System.out.println("The list is: \n"                           + list);          // Create an iterator for the list        // using iterator() method        Iterator<String> iter            = list.iterator();          // Displaying the values after iterating        // through the list        System.out.println("\nThe iterator values"                           + " of list are: ");        while (iter.hasNext()) {            System.out.print(iter.next() + " ");        }    }}
The list is: 
[Geeks, for, Geeks, is, a, CS, Students, Portal]

The iterator values of list are: 
Geeks for Geeks is a CS Students Portal

Program 2:
// Java code to illustrate iterator()  import java.util.*;  public class GFG {      public static void main(String args[])    {        // Creating an empty ArrayList        ArrayList<Integer> list            = new ArrayList<Integer>();          // Use add() method to add        // elements into the list        list.add(10);        list.add(15);        list.add(30);        list.add(20);        list.add(5);          // Displaying the list        System.out.println("The list is: \n"                           + list);          // Create an iterator for the list        // using iterator() method        Iterator<Integer> iter = list.iterator();          // Displaying the values        // after iterating through the list        System.out.println("\nThe iterator values"                           + " of list are: ");        while (iter.hasNext()) {            System.out.print(iter.next() + " ");        }    }}
The list is: 
[10, 15, 30, 20, 5]

The iterator values of list are: 
10 15 30 20 5

Java-ArrayList
Java-Collections
Java-Functions
Picked
Technical Scripter 2018
Java
Technical Scripter
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Initialize an ArrayList in Java
HashMap in Java with Examples
Interfaces in Java
Object Oriented Programming (OOPs) Concept in Java
ArrayList in Java
How to iterate any Map in Java
Multidimensional Arrays in Java
Overriding in Java
Stack Class in Java
Set in Java
Styling Tables with CSS

For styling the tables with CSS, we can set borders, collapse, set width and height. We can also set the padding, alig text in it, etc. Let us see some examples −
To add borders to a table in CSS, use the borders property. Let us now see an example −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
   border: 2px dashed orange;
}
</style>
</head>
<body>
<h2>Team Ranking Table</h2>
<table>
<tr>
<th>Team</th>
<th>Rank</th>
<th>Points</th>
</tr>
<tr>
<td>India</td>
<td>1</td>
<td>200</td>
</tr>
<tr>
<td>England</td>
<td>2</td>
<td>180</td>
</tr>
<tr>
<td>Australia</td>
<td>3</td>
<td>150</td>
</tr>
<tr>
<td>NewZealand</td>
<td>4</td>
<td>130</td>
</tr>
<tr>
<td>SouthAfrica</td>
<td>5</td>
<td>100</td>
</tr>
<tr>
<td>WestIndies</td>
<td>6</td>
<td>80</td>
</tr>
<tr>
<td>Pakistan</td>
<td>7</td>
<td>70</td>
</tr>
</table>
</body>
</html>
To collapse table borders, use the border-collapse property in CSS. Let us see an example to collapse table borders −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
table {
   border-collapse: collapse;
   background-color: black;
   color: white;
}
th, td {
   border: 2px dashed yellow;
}
</style>
</head>
<body>
<h2>Team Ranking Table</h2>
<table>
<tr>
<th>Team</th>
<th>Rank</th>
<th>Points</th>
</tr>
<tr>
<td>India</td>
<td>1</td>
<td>200</td>
</tr>
<tr>
<td>England</td>
<td>2</td>
<td>180</td>
</tr>
<tr>
<td>Australia</td>
<td>3</td>
<td>150</td>
</tr>
<tr>
<td>NewZealand</td>
<td>4</td>
<td>130</td>
</tr>
<tr>
<td>SouthAfrica</td>
<td>5</td>
<td>100</td>
</tr>
<tr>
<td>WestIndies</td>
<td>6</td>
<td>80</td>
</tr>
<tr>
<td>Pakistan</td>
<td>7</td>
<td>70</td>
</tr>
</table>
</body>
</html>
To set the space between border and content, use the padding property as in the below example −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
table {
   border: 1px solid black;
   background-color: blue;
   color: white;
}
th, td {
   border: 1px solid black;
   padding: 20px;
   text-align: center;
}
table#demo {
   table-layout: fixed;
   width: 100%;
}
</style>
</head>
<body>
<h2>Team Ranking Table</h2>
<table id="demo">
<tr>
<th>Team</th>
<th>Rank</th>
<th>Points</th>
</tr>
<tr>
<td>India</td>
<td>1</td>
<td>200</td>
</tr>
<tr>
<td>England</td>
<td>2</td>
<td>180</td>
</tr>
<tr>
<td>Australia</td>
<td>3</td>
<td>150</td>
</tr>
<tr>
<td>NewZealand</td>
<td>4</td>
<td>130</td>
</tr>
<tr>
<td>SouthAfrica</td>
<td>5</td>
<td>100</td>
</tr>
</table>
</body>
</html>
Python program to convert a list to string

27 Jun, 2022
There are various situations we might encounter when a list is given and we convert it to a string. For example, conversion to string from the list of strings or the list of integers or mixed data types.
 Example:
Chapters
descriptions off, selected
captions settings, opens captions settings dialog
captions off, selected
English
This is a modal window.
Beginning of dialog window. Escape will cancel and close the window.
End of dialog window.
Input: ['Geeks', 'for', 'Geeks']
Output: Geeks for Geeks

Input: ['I', 'want', 4, 'apples', 'and', 18, 'bananas']
Output: I want 4 apples and 18 bananas
Let’s see various ways we can convert the list to string. 
Method#1: The first method is to assign a list and traverse each element using for loop and adding it to an empty string.
Python3
s = ['Geeks', 'for', 'Geeks']str1 = ""# traverse in the string for i in s:    str1 += i print(str1)
Output:
GeeksforGeeks
type(str1)
str
Method #2: The Second method used here is using a function that traverse each element of the list using for loop and keep adding the element for every index in some empty string. 
Python3
# Python program to convert a list to string   # Function to convert def listToString(s):       # initialize an empty string    str1 = ""       # traverse in the string     for ele in s:        str1 += ele        # return string     return str1              # Driver code   s = ['Geeks', 'for', 'Geeks']print(listToString(s))
GeeksforGeeks
Method #3: Using .join() method 
Python3
# Python program to convert a list# to string using join() function   # Function to convert def listToString(s):       # initialize an empty string    str1 = " "       # return string     return (str1.join(s))              # Driver code   s = ['Geeks', 'for', 'Geeks']print(listToString(s))
Geeks for Geeks
But what if the list contains both string and integer as its element. In those cases, above code won’t work. We need to convert it to string while adding to string. 
Method #4: Using list comprehension 
Python3
# Python program to convert a list# to string using list comprehension  s = ['I', 'want', 4, 'apples', 'and', 18, 'bananas'] # using list comprehensionlistToStr = ' '.join([str(elem) for elem in s]) print(listToStr)
I want 4 apples and 18 bananas
Method #5: Using map() Use map() method for mapping str (for converting elements in list to string) with given iterator, the list. 
Python3
# Python program to convert a list# to string using list comprehension  s = ['I', 'want', 4, 'apples', 'and', 18, 'bananas'] # using list comprehensionlistToStr = ' '.join(map(str, s)) print(listToStr)
I want 4 apples and 18 bananas
nidhi_biet
sheetal18june
Python list-programs
Python string-programs
python-list
python-string
Python
Python Programs
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sheppard’s Correction for Moments | ML

23 Jan, 2020
Prerequisite: Raw and Central Moments
We assume in grouped data that the frequencies are concentrated in the middle part of the class interval. This assumption does not hold true in general and grouping error is introduced. Such an effect can be corrected in calculating the moments by using the information on the width of the class interval.
Sheppard’s Correction for grouping error is nothing but the adjustment to calculated sample moments for the grouped data or continuous data. Prof. W.F. Sheppard proved that if the frequency distribution is continuous and the frequency tapers off to zero in both directions, the grouping error can be corrected as follows:
Let ‘c’ be the width of the class interval. Then,Raw Moments
Central Moments
What Kind of data can be corrected?
This method of correction to moments is only possible for the continuous variables i.e. the continuous data.The width of the class interval should be equal.Frequencies should be symmetrical. Frequency should taper off to zero in both directions.
This method of correction to moments is only possible for the continuous variables i.e. the continuous data.
The width of the class interval should be equal.
Frequencies should be symmetrical. Frequency should taper off to zero in both directions.
Consider the given distribution of marks.
For the distribution of marks above, the value for moments are given below:
Raw Moments –, is the rth raw moment, where  is the frequency count and  is the mid value of class.
So, using the above formula for the Raw Moment we get following values for moments.
Sheppard’s correction for Raw Moments –
Similarly central moments can be corrected using Sheppard’s Correction.
Machine Learning
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
MathF.Abs() Method in C# with Examples

04 Apr, 2019
MathF.Abs(Single) Method is used to return the absolute value of a specified float number.
Syntax: public static float Abs (float x);Here, it takes a standard floating point number.
Return Value: This method returns a floating point value less than Single.MaxValue.
Example 1:
// C# program to demonstrate the// MathF.Abs(Single)  Methodusing System;  class GFG {      // Main Method    public static void Main()    {          // Declaring and initializing value        float value = 4.5f;          // Getting absolute float        // using Abs() method        float round = MathF.Abs(value);          // Display the value        Console.WriteLine("Absolute float value is {0}",                                                 round);    }}
Absolute float value is 4.5

Example 2:
// C# program to demonstrate the// MathF.Abs(Single) Methodusing System;using System.Globalization;  class GFG {      // Main Method    public static void Main()    {        // calling get() method        get(20f);        get(30.5f);        get(40.5f);        get(4294.586f);    }      // defining get() method    public static void get(float value)    {          // getting absolute float        // using Abs() method        float round = MathF.Abs(value);          // Display the value        Console.WriteLine("Float value is {0}", round);    }}
Float value is 20
Float value is 30.5
Float value is 40.5
Float value is 4294.586

CSharp-MathF-Class
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Lemmatization with NLTK

18 May, 2022
Lemmatization is the process of grouping together the different inflected forms of a word so they can be analyzed as a single item. Lemmatization is similar to stemming but it brings context to the words. So it links words with similar meanings to one word. Text preprocessing includes both Stemming as well as Lemmatization. Many times people find these two terms confusing. Some treat these two as the same. Actually, lemmatization is preferred over Stemming because lemmatization does morphological analysis of the words.Applications of lemmatization are:  
Used in comprehensive retrieval systems like search engines.
Used in compact indexing
 
Examples of lemmatization:

-> rocks : rock
-> corpora : corpus
-> better : good
One major difference with stemming is that lemmatize takes a part of speech parameter, “pos” If not supplied, the default is “noun.”Below is the implementation of lemmatization words using NLTK: 
Python3
# import these modulesfrom nltk.stem import WordNetLemmatizer  lemmatizer = WordNetLemmatizer()  print("rocks :", lemmatizer.lemmatize("rocks"))print("corpora :", lemmatizer.lemmatize("corpora"))  # a denotes adjective in "pos"print("better :", lemmatizer.lemmatize("better", pos ="a"))
Output :  
rocks : rock
corpora : corpus
better : good
 
tanwarsinghvaibhav
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ML | Monte Carlo Tree Search (MCTS)
Markov Decision Process
Introduction to Recurrent Neural Network
Getting started with Machine Learning
ML | Underfitting and Overfitting
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
Python Dictionary
How to get column names in Pandas dataframe
matplotlib.pyplot.plot_date() in Python

22 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface.
The plot_date() function in pyplot module of matplotlib library is used to plot with data that contains dates.
Syntax:
matplotlib.pyplot.plot_date(x, y, fmt='o', tz=None, xdate=True, ydate=False, hold=None, data=None, **kwargs)

Parameters: This method accept the following parameters that are described below:
x, y: These parameter are the horizontal and vertical coordinates of the data points.
fmt: This parameter is an optional parameter and it contains the string value.
tz: This parameter is the time zone to use in labeling dates.It contain timezone string.
xdate: This parameter is also an optional parameter. And it contain boolean values with default value True. If True, the x-axis will be interpreted as Matplotlib dates.
ydate: This parameter is also an optional parameter. And it contain boolean values with default value True. If True, the y-axis will be interpreted as Matplotlib dates.
Returns: This returns the following:
lines:This returns the list of Line2D objects representing the plotted data.
Below examples illustrate the matplotlib.pyplot.plot_date() function in matplotlib.pyplot:
Example #1:
# Implementation of matplotlib functionimport datetimeimport matplotlib.pyplot as pltfrom matplotlib.dates import drangeimport numpy as np   date1 = datetime.datetime(2020, 4, 2)date2 = datetime.datetime(2020, 4, 12)delta = datetime.timedelta(hours = 24)dates = drange(date1, date2, delta)   y = np.arange(len(dates))   plt.plot_date(dates, y ** 2)plt.title('matplotlib.pyplot.plot_date() function Example', fontweight ="bold")plt.show()
Output:
Example #2:
# Implementation of matplotlib functionimport datetimeimport matplotlib.pyplot as pltfrom matplotlib.dates import DayLocator, HourLocator, DateFormatter, drangeimport numpy as np   date1 = datetime.datetime(2020, 4, 2)date2 = datetime.datetime(2020, 4, 6)delta = datetime.timedelta(hours = 6)dates = drange(date1, date2, delta)   y = np.arange(len(dates))   fig, ax = plt.subplots()ax.plot_date(dates, y ** 2, 'g')   ax.set_xlim(dates[0], dates[-1])   ax.xaxis.set_major_locator(DayLocator())ax.xaxis.set_minor_locator(HourLocator(range(0, 25, 6)))ax.xaxis.set_major_formatter(DateFormatter('% Y-% m-% d'))   ax.fmt_xdata = DateFormatter('% Y-% m-% d % H:% M:% S')fig.autofmt_xdate()plt.title('matplotlib.pyplot.plot_date() function Example', fontweight ="bold")plt.show()
Output:
Python-matplotlib
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Matplotlib.dates.datestr2num() in Python

21 Apr, 2020
Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack.
The matplotlib.dates.datestr2num() function is used to convert a date string to a datenum by the uses of dateutil.parser.parser().
Syntax: matplotlib.dates.datestr2num(d, default=None)
Parameters:
d: It is a string or a sequence of strings representing the dates.default: This is an optional parameter that is a datetime instance. This is used when fields are not present in d, as a default.
d: It is a string or a sequence of strings representing the dates.
default: This is an optional parameter that is a datetime instance. This is used when fields are not present in d, as a default.
Example 1:
from datetime import datetimeimport matplotlib.pyplot as pltfrom matplotlib.dates import (    DateFormatter, AutoDateLocator, AutoDateFormatter, datestr2num)    days = [    '30/01/2019',    '31/01/2019',     '01/02/2019',    '02/02/2019',     '03/02/2019',     '04/02/2019']data1 = [2, 5, 13, 6, 11, 7]data2 = [6, 3, 10, 3, 6, 5]  z = datestr2num([    datetime.strptime(day, '%d/%m/%Y').strftime('%m/%d/%Y')    for day in days])  r = 0.25  figure = plt.figure(figsize =(8, 4))axes = figure.add_subplot(111)  axes.bar(z - r, data1, width = 2 * r,         color ='g', align ='center',         tick_label = day)  axes.bar(z + r, data2, width = 2 * r,         color ='y', align ='center',          tick_label = day)  axes.xaxis_date()axes.xaxis.set_major_locator(    AutoDateLocator(minticks = 3, interval_multiples = False))  axes.xaxis.set_major_formatter(DateFormatter("%d/%m/%y"))  plt.show()
Output:
Example 2:
import matplotlibimport matplotlib.pyplot as pltimport matplotlib.dates    dates =  ['1920-05-06',           '1920-05-07',           '1947-05-08',           '1920-05-09']  converted_dates = matplotlib.dates.datestr2num(dates)  x_axis = (converted_dates)y_axis = range(0, 4)  plt.plot_date( x_axis, y_axis, '-' )  plt.show()
Output:
Python-matplotlib
Python
Write From Home
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 ?
Convert integer to string in Python
Convert string to integer in Python
How to set input type date in dd-mm-yyyy format using HTML ?
Python infinity
Factory method design pattern in Java
GATE | GATE-CS-2009 | Question 60

28 Jun, 2021
The below DFA accepts the set of all strings over {0,1} that
(A) begin either with 0 or 1(B) end with 0(C) end with 00(D) contain the substring 00.Answer: (C)Explanation: If the strings beginning with 0 and 1 are 01 and 11 respectively, then the DFA doesn’t accept these( because it doesn’t reach to the final terminating/accepting state). Hence not option A.
If the string ending with 0 is 10, then the DFA doesn’t accept this also. Hence not option B.
If the string which contains substring 00 is 1001, then the DFA doesn’t accept this also. Hence not option D.
Now, take any string which ends with 00, like 00, 100, 1100, 10100, 0100 all are accepted by the given DFA. Hence option C.
Intuitively we can also observe here by looking at the DFA that there is only one direct path to reach the final terminating state C ( lets say given 3 states(circles) are A, B and C from left to right in the diagram ), then the path is A–>B–>C , and this path requires 00 in the current substring of the input to reach from A to C.
Now after reaching C, either the string should terminate to be accepted by the given DFA, or it can also have any number of 0’s following it, for the string to be accepted. In either of the case the string would be ending with 00.Quiz of this Question
GATE-CS-2009
GATE-GATE-CS-2009
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Batch Script - Comparing Registry Keys

Comparing registry keys is done via the REG COMPARE command.
REG COMPARE [ROOT\]RegKey [ROOT\]RegKey [/v ValueName] [Output] [/s]
REG COMPARE [ROOT\]RegKey [ROOT\]RegKey [/ve] [Output] [/s]

Wherein Output − /od (only differences) /os (only matches) /oa (all) /on (no output).
@echo off
REG COMPARE HKEY_CURRENT_USER\Console HKEY_CURRENT_USER\Console\Test
The above program will compare all of the values between the registry keys HKEY_CURRENT_USER\Console & HKEY_CURRENT_USER\Console\Test.
Result Compared: Identical
The operation completed successfully.

If there is a difference between the values in either registry key, it will be shown in the output as shown in the following result. The following output shows that the value ‘EnableColorSelection’ is extra I the registry key ‘HKEY_CURRENT_USER\Console’.
< Value: HKEY_CURRENT_USER\Console EnableColorSelection REG_DWORD 0x0
Result Compared: Different
The operation completed successfully.

 Print
 Add Notes
 Bookmark this page
How to escape parentheses in MySQL REGEXP clause and display only specific values with parentheses?

Let us first create a table −
mysql> create table DemoTable1908
   (
   Code text
   );
Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1908 values('MySQL(1)Database');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1908 values('MongoDB 2 Database');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1908 values('MySQL(3)Database');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1908 values('SQL Server(10)Database');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1908 values('MySQL 8 Database');
Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1908;
This will produce the following output −
+------------------------+
| Code                   |
+------------------------+
| MySQL(1)Database       |
| MongoDB 2 Database     |
| MySQL(3)Database       |
| SQL Server(10)Database |
| MySQL 8 Database       |
+------------------------+
5 rows in set (0.00 sec)
Here is the query to escape parentheses in a REGEXP clause and display only the paratheses value with () −
mysql> select * from DemoTable1908 where Code regexp '^MySQL[(][0-9][)]Database';
This will produce the following output −
+------------------+
| Code             |
+------------------+
| MySQL(1)Database |
| MySQL(3)Database |
+------------------+
2 rows in set (0.00 sec)
Encrypt and Decrypt Data in NodeJS

NodeJS provides inbuilt library crypto to encrypt and decrypt data in NodeJS. We can use this library to encrypt data of any type. You can do the cryptographic operations on a string, buffer, and even a stream of data. The crypto also holds multiple crypto algorithms for encryption. Please check the official resources for the same. In this article, we will use the most popular AES (Advanced Encryption Standard) for encryption.
In your project, check if NodeJS is initialized or not. If not, use the following command to initialize NodeJS.
In your project, check if NodeJS is initialized or not. If not, use the following command to initialize NodeJS.
>> npm init -y
The 'crypto' library is automatically added while installing the node manually. If not, you can use the following command to install crypto.
The 'crypto' library is automatically added while installing the node manually. If not, you can use the following command to install crypto.
>> npm install crypto –save
Encrypting and Decrypting Data
//Checking the crypto module
const crypto = require('crypto');
const algorithm = 'aes-256-cbc'; //Using AES encryption
const key = crypto.randomBytes(32);
const iv = crypto.randomBytes(16);

//Encrypting text
function encrypt(text) {
   let cipher = crypto.createCipheriv('aes-256-cbc', Buffer.from(key), iv);
   let encrypted = cipher.update(text);
   encrypted = Buffer.concat([encrypted, cipher.final()]);
   return { iv: iv.toString('hex'), encryptedData: encrypted.toString('hex') };
}

// Decrypting text
function decrypt(text) {
   let iv = Buffer.from(text.iv, 'hex');
   let encryptedText = Buffer.from(text.encryptedData, 'hex');
   let decipher = crypto.createDecipheriv('aes-256-cbc', Buffer.from(key), iv);
   let decrypted = decipher.update(encryptedText);
   decrypted = Buffer.concat([decrypted, decipher.final()]);
   return decrypted.toString();
}

// Text send to encrypt function
var hw = encrypt("Welcome to Tutorials Point...")
console.log(hw)
console.log(decrypt(hw))
C:\\Users\mysql-test>> node encrypt.js
{ iv: '61add9b0068d5d85e940ff3bba0a00e6', encryptedData:
'787ff81611b84c9ab2a55aa45e3c1d3e824e3ff583b0cb75c20b8947a4130d16' }
//Encrypted text
Welcome to Tutorials Point... //Decrypted text
How to use pip or easy_install Tkinter on Windows?

Tkinter is a Python library that is used to develop desktop-based GUI applications. In order to develop a Tkinter application, we have to make sure that Python is installed in our local system. We can install Tkinter in our local machine by using the pip install tkinter command in the Command Prompt or shell.
Once we enter the command pip install tkinter in the command shell, it will just start running the process of installing Tkinter in the local system.
First, we will make sure that Python is installed in our system. In order to check if Python is installed, use the following command −
First, we will make sure that Python is installed in our system. In order to check if Python is installed, use the following command −
python --version
Next, check if you have Pip preinstalled or not, by typing the following command in the shell,
Next, check if you have Pip preinstalled or not, by typing the following command in the shell,
pip -V
Now, install Tkinter by using the following command −
Now, install Tkinter by using the following command −
pip install tkinter