code-rag-bench/online-tutorials huggingface dataset:
NOW() function in MYSQL - GeeksforGeeks

11 Jan, 2021
NOW() :This function in MySQL is used to check the current date and time value. The return type for NOW() function is either in ‘YYYY-MM-DD HH:MM:SS’ format or YYYYMMDDHHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context.
Syntax :
NOW()
Parameter :This method does not accept any parameter.
Returns :It returns the current date and time value.
Example-1 :Finding the current date and time using NOW Function. Here we will get the result in ‘YYYY-MM-DD HH:MM:SS’ format.
SELECT NOW() 
as CurrDateTime ;
Output :
Example-2 :Getting the current date and time using NOW Function in numeric format. Here the result will be in YYYYMMDDHHMMSS.uuuuuu format.
SELECT NOW()+ 0 
as CurrDateTime ;
Output :
Example-3 :We can also use The NOW function to set value of columns. To demonstrate create a table named DeliveryDetails.
CREATE TABLE Product (
ProductId INT NOT NULL,
ProductName VARCHAR(20) NOT NULL,
Delivered_At TIMESTAMP NOT NULL,
PRIMARY KEY(ProductId)
);
Here, we will use NOW function when a delivery will be completed. The value in Delivered_At column will be the value given by NOW Function.
INSERT INTO  
Product (ProductId, ProductName, Delivered_At)
VALUES
(1010, 'Apple MacBook', NOW());
Now, checking the Product table :
SELECT * FROM Product;
Output :
DBMS-SQL
mysql
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL | Subquery
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL Query to Find the Name of a Person Whose Name Starts with Specific Letter
SQL Query to Convert VARCHAR to INT
SQL using Python
How to Write a SQL Query For a Specific Date Range and Date Time?
How to Select Data Between Two Dates and Times in SQL Server?
SQL Query to Compare Two Dates
Python isinstance() method - GeeksforGeeks

23 Sep, 2021
Python isinstance() function returns True if the object is specified types, and it will not match then return False. 
Syntax : isinstance(obj, class)
Parameters : 
obj : The object that need to be checked as a part of class or not.
class : class/type/tuple of class or type, against which object is needed to be checked.
Returns : True, if object belongs to the given class/type if single class is passed or any of the class/type if tuple of class/type is passed, else returns False. Raises
TypeError: if anything other than mentioned valid class type. 
Python3
# Python 3 code to demonstrate# working of isinstance()# with native types # initializing native typestest_int = 5test_list = [1, 2, 3] # testing with isinstanceprint("Is test_int integer? : " + str(isinstance(test_int, int)))print("Is test_int string? : " + str(isinstance(test_int, str)))print("Is test_list integer? : " + str(isinstance(test_list, int)))print("Is test_list list? : " + str(isinstance(test_list, list))) # testing with tupleprint("Is test_int integer or list or string? : "      + str(isinstance(test_int, (list, int))))
Output: 
Is test_int integer? : True
Is test_int string? : False
Is test_list integer? : False
Is test_list list? : True
Is test_int integer or list or string? : True
Python3
# Python 3 code to demonstrate# working of isinstance()# with objects # declaring classesclass gfg1:    a = 10 # inherited classclass gfg2(gfg1):    string = 'GeeksforGeeks'  # initializing objectsobj1 = gfg1()obj2 = gfg2() # checking instancesprint("Is obj1 instance of gfg1? : " + str(isinstance(obj1, gfg1)))print("Is obj2 instance of gfg2? : " + str(isinstance(obj2, gfg2)))print("Is obj1 instance of gfg2? : " + str(isinstance(obj1, gfg2)))  # check inheritance case# return trueprint("Is obj2 instance of gfg1? : " + str(isinstance(obj2, gfg1)))
Output: 
Is obj1 instance of gfg1? : True
Is obj2 instance of gfg2? : True
Is obj1 instance of gfg2? : False
Is obj2 instance of gfg1? : True
Python3
test_list = [1, 2, 3]print ("Is test_list list? : " + str(isinstance(test_list, list)))
Output:
Is test_list list? : True
Python3
test_str = "GeeksforGeeks"print ("Is test_str string? : " + str(isinstance(test_str, str)))
Output:
Is test_str string? : True
Python3
test_dict = {"apple" : 1, "Ball" : 2 }print ("Is test_str dictionary? : " + str(isinstance(test_dict, dict)))
Output:
Is test_str dictionary? : True
Python
class geeks:    course = 'DSA'       def purchase(obj):        return obj.course      geeks.purchase = classmethod(geeks.purchase)str(isinstance(geeks.purchase(), str ))
Output:
True
anikakapoor
surinderdawra388
kumar_satyam
Python-Built-in-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
C | Arrays | Question 1 - GeeksforGeeks

10 Jan, 2013
Predict the output of below program:
#include <stdio.h>  int main(){    int arr[5];          // Assume that base address of arr is 2000 and size of integer        // is 32 bit    arr++;    printf("%u", arr);          return 0;}
(A) 2002(B) 2004(C) 2020(D) lvalue requiredAnswer: (D)Explanation: Array name in C is implemented by a constant pointer. It is not possible to apply increment and decrement on constant types.
Arrays
C-Arrays
C Language
C Quiz
Arrays
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
std::string class in C++
TCP Server-Client implementation in C
Structures in C
Exception Handling in C++
Memory Layout of C Programs
Compiling a C program:- Behind the Scenes
Operator Precedence and Associativity in C
C | File Handling | Question 1
C | Misc | Question 7
Output of C programs | Set 64 (Pointers)
Python - Matching Pairs of Brackets - GeeksforGeeks

22 Jun, 2020
Sometimes, while working with Python data, we can have a problem in which we need to pair all the elements with the suitable closing brackets, and can have data associated with pairing. This kind of problem is classic application of Stack Data Structure and can have usage across many domains. Let’s discuss a certain way in which this task can be done.
Input : test_list = [(‘(‘, 1), (‘(‘, 2), (‘)’, 3), (‘)’, 4)]Output : [(2, 3), (1, 4)]
Input : test_list = [(‘(‘, 1), (‘)’, 4)]Output : [(1, 4)]
Method : Using stack DS + loopThe combination above functionalities can be used to solve this problem. In this, we make a new pair with each opening bracket and when the corresponding closing bracket comes using LIFO technique, we form a pair with that closing bracket.
# Python3 code to demonstrate working of # Matching Pairs of Brackets# Using stack DS + loop  # initializing listtest_list = [('(', 7), ('(', 9), (')', 10), (')', 11), ('(', 15), (')', 100)]  # printing original listprint("The original list is : " + str(test_list))  # Matching Pairs of Brackets# Using stack DS + loopstck = []res = []for ele1, ele2 in test_list:    if '(' in ele1:        stck.append((ele1, ele2))    elif ')' in ele1:        res.append((stck.pop()[1], ele2))  # printing result print("The paired elements : " + str(res)) 
The original list is : [('(', 7), ('(', 9), (')', 10), (')', 11), ('(', 15), (')', 100)]
The paired elements : [(9, 10), (7, 11), (15, 100)]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
time() function in C - GeeksforGeeks

15 Jul, 2021
The time() function is defined in time.h (ctime in C++) header file. This function returns the time since 00:00:00 UTC, January 1, 1970 (Unix timestamp) in seconds. If second is not a null pointer, the returned value is also stored in the object pointed to by second.
Syntax:  
time_t time( time_t *second )
Parameter: This function accepts single parameter second. This parameter is used to set the time_t object which store the time.Return Value: This function returns current calendar time as a object of type time_t.
Program 1: 
C
// C program to demonstrate// example of time() function.#include <stdio.h>#include <time.h> int main (){    time_t seconds;         seconds = time(NULL);    printf("Seconds since January 1, 1970 = %ld\n", seconds);         return(0);}
Seconds since January 1, 1970 = 1538123990
 
Example 2: 
C
// C program to demonstrate// example of time() function.  #include <stdio.h>#include <time.h>  int main(){    time_t seconds;       // Stores time seconds    time(&seconds);    printf("Seconds since January 1, 1970 = %ld\n", seconds);      return 0;}
Seconds since January 1, 1970 = 1538123990
 
clintra
C-Functions
C-Library
C Language
C Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Multidimensional Arrays in C / C++
Left Shift and Right Shift Operators in C/C++
Function Pointer in C
Substring in C++
fork() in C
Strings in C
Arrow operator -> in C/C++ with Examples
C Program to read contents of Whole File
Header files in C/C++ and its uses
Basics of File Handling in C
Compute Derivative of an Expression in R Programming - deriv() and D() Function - GeeksforGeeks

30 Jun, 2020
In R programming, derivative of a function can be computed using deriv() and D() function. It is used to compute derivatives of simple expressions.
Syntax:deriv(expr, name)D(expr, name)
Parameters:expr: represents an expression or a formula with no LHSname: represents character vector to which derivatives will be computed
Example 1:
# Expression or formulaf = expression(x^2 + 5*x + 1)  # Derivativecat("Using deriv() function:\n")print(deriv(f, "x"))  cat("\nUsing D() function:\n")print(D(f, 'x'))
Output:
Using deriv() function:
expression({
    .value <- x^2 + 5 * x + 1
    .grad <- array(0, c(length(.value), 1L), list(NULL, c("x")))
    .grad[, "x"] <- 2 * x + 5
    attr(.value, "gradient") <- .grad
    .value
})

Using D() function:
2 * x + 5

Example 2:
# Little harder derivative  # Using deriv() Functioncat("Using deriv() function:\n")print(deriv(quote(sinpi(x^2)), "x"))  # Using D() Functioncat("\nUsing D() function:\n")print(D(quote(sinpi(x^2)), "x"))
Output:
Using deriv() function:
expression({
    .expr1 <- x^2
    .value <- sinpi(.expr1)
    .grad <- array(0, c(length(.value), 1L), list(NULL, c("x")))
    .grad[, "x"] <- cospi(.expr1) * (pi * (2 * x))
    attr(.value, "gradient") <- .grad
    .value
})

Using D() function:
cospi(x^2) * (pi * (2 * x))

R Math-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to import an Excel File into R ?
How to filter R dataframe by multiple conditions?
Replace Specific Characters in String in R
Time Series Analysis in R
R - if statement
Function to check two strings and return common words in JavaScript

We are required to write a JavaScript function that takes in two strings as arguments. The function should then check the two strings for common characters and prepare a new string of those characters.
Lastly, the function should return that string.
The code for this will be −
const str1 = "IloveLinux";
const str2 = "weloveNodejs";
const findCommon = (str1 = '', str2 = '') => {
   const common = Object.create(null);
   let i, j, part;
   for (i = 0; i < str1.length - 1; i++) {
      for (j = i + 1; j <= str1.length; j++) {
         part = str1.slice(i, j);
         if (str2.indexOf(part) !== −1) {
            common[part] = true;
         }
      }
   }
   const commonEl = Object.keys(common);
   return commonEl;
};
console.log(findCommon(str1, str2));
And the output in the console will be −
[
   'l', 'lo', 'lov',
   'love', 'o', 'ov',
   'ove', 'v', 've',
   'e'
]
How to find out port of MySQL Server?

To find the port of the MySQL server, the command show can be used. Its syntax is as follows −
show variables where variable_name=’port’;
The above syntax is used to get the port number of the MySQL server using the following query −
mysql> show variables where variable_name = 'port';
After executing the above command, port of MySQL server is obtained as 3306. This can be seen in the following output −
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port          | 3306  |
+---------------+-------+
1 row in set (0.01 sec)
Alternatively, the system variable @@port can also be used to find the MySQL server port. This is demonstrated by the following query −
mysql> SELECT @@port;
The output of the above query is as follows −
+--------+
| @@port |
+--------+
| 3306   |
+--------+
1 row in set (0.00 sec)
The above output also gives the port of MySQL server as 3306.
Tryit Editor v3.7

HTML Input attributes
Tryit: The placeholder attribute
Print all n-digit numbers whose sum of digits equals to given sum in C++

In this problem, we are given two numbers n and sum. We have to print all n digit numbers whose sum is equal to the sum. In this problem, numbers with leading 0’s are not considered.
Let’s take an example to understand the problem,
Input: n = 2 , sum = 5
Output: 14 23 32 41 50
Explanation: The sum of digits of the number in all numbers in 5.
To solve this problem, we will have to find all the n-digit numbers with sum with the given sum value. For this, we will fix a digit place with all values and based on its position to be even or odd, call for values at other places in the number such that the condition remains satisfied.
Program to implement the above solution −
 Live Demo
#include <iostream>
using namespace std;
void PrintNumberWithDigitSum(int n, int sum, char* out, int index) {
   if (index > n || sum < 0)
      return;
   if (index == n) {
      if(sum == 0) {
         out[index] = ' ';
         cout << out << " ";
      }
      return;
   }
   for (int i = 0; i <= 9; i++) {
      out[index] = i + '0';
      PrintNumberWithDigitSum(n, sum - i, out, index + 1);
   }
}
void numberWithSum(int n, int sum) {
   char out[n + 1];
   for (int i = 1; i <= 9; i++) {
      out[0] = i + '0';
      PrintNumberWithDigitSum(n, sum - i, out, 1);
   }
}
int main() {
   int n = 3, sum = 6;
   cout<<"All "<<n<<" digit numbers with sum "<<sum<<" are :\n";
   numberWithSum(n, sum);
   return 0;
}
All 3 digit numbers with sum 6 are −
105 114 123 132 141 150 204 213 222 231 240 303 312 321 330 402 411 420 501 510 600
Tryit Editor v3.7

Tryit: Text shadow with border
Remove specific word in a comma separated string with MySQL

Let us first create a table −
mysql> create table DemoTable836(FirstName SET('John','Chris','Adam'));
Query OK, 0 rows affected (0.60 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable836 values('John,Chris');
Query OK, 1 row affected (0.11 sec)
mysql> insert into DemoTable836 values('John,Chris,Adam');
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable836 values('Chris,Adam');
Query OK, 1 row affected (0.25 sec)
mysql> insert into DemoTable836 values('John,Adam');
Query OK, 1 row affected (0.37 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable836;
This will produce the following output −
+-----------------+
| FirstName       |
+-----------------+
| John,Chris      |
| John,Chris,Adam |
| Chris,Adam      |
| John,Adam       |
+-----------------+
4 rows in set (0.00 sec)
Following is the query to remove a specific word in a comma-separated string −
mysql> update DemoTable836 set FirstName = FirstName &~ (1 << FIND_IN_SET('Chris', FirstName) - 1);
Query OK, 3 rows affected (0.21 sec)
Rows matched: 4 Changed: 3 Warnings: 0
Let us check the table records once again −
mysql> select *from DemoTable836;
This will produce the following output −
+-----------+
| FirstName |
+-----------+
| John      |
| John,Adam |
| Adam      |
| John,Adam |
+-----------+
4 rows in set (0.00 sec)
Difference between Synchronous and Asynchronous Sequential Circuits - GeeksforGeeks

08 Apr, 2022
Sequential Circuits are those which have the notion of an internal state. This notion of Internal State is necessary because in sequential circuits, the output of the circuit is function of both the present input as well as the past inputs. The Internal State of a sequential circuit is nothing but the reflection of the past inputs to the circuit. Now the Internal State of a Sequential Circuit is represented by a number of State Variables. Each state variable can be in 1 of 2 possible states. This is because State Variables are physically implemented with the help of Flip-Flops, and each Flip-Flop can only represent 2 possible states. Therefore, if we have ‘N’ Flip-Flops, we can represent a maximum of 2N states.
Max. No. of States with 'N' Flip-Flops = 
This means that a Sequential Circuit having ‘N’ Flip-Flops can be in at most Internal States. Now let’s illustrate the difference between that of Synchronous and Asynchronous Sequential Circuits with the example of a Synchronous and Asynchronous 2-bit binary UP Counter using T-Flip-Flops. Figure – 2-bit Binary Asynchronous UP CounterFigure – 2-bit Binary Synchronous UP CounterIn both the above circuits are the State Variables denoting the Internal State of each of the above circuits. Since there are 2 state variable the above sequential circuits can be in 4 possible states, and the function of a counter is to cycle through these 4 states in a particular order. Now the difference between Synchronous and Asynchronous Circuits is in how the circuit goes for one Internal State to the Next Internal State. In a Synchronous Sequential Circuit all the State Variables representing the internal state of the circuit change their state simultaneously with a given input clock signal to achieve the next state. On the other hand in case of an Asynchronous Circuit all the State Variables may not change their state simultaneously to achieve the next steady internal state. In other words the state variables are not synchronized with any universal clock signal. Comparisons –
nikhatkhan11
Technical Scripter 2018
Difference Between
Digital Electronics & Logic Design
GATE CS
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Difference between Process and Thread
Difference Between Method Overloading and Method Overriding in Java
Difference between Clustered and Non-clustered index
Differences between Procedural and Object Oriented Programming
Full Adder in Digital Logic
Program for Decimal to Binary Conversion
Introduction of K-Map (Karnaugh Map)
Program for Binary To Decimal Conversion
4-bit binary Adder-Subtractor
stack push() and pop() in C++ STL

In this article we will be discussing the working, syntax, and examples of stack::push() and
stack::pop() function in C++ STL.
Stacks are the data structure which stores the data in LIFO (Last In First Out) where we do
insertion and deletion from the top of the last element inserted. Like a stack of plates, if we want to push a new plate into the stack we insert on the top and if we want to remove the plate from the stack we then also remove it from the top.
stack::push() function is an inbuilt function in C++ STL, which is defined in <stack>header file. push() is used to push or insert an element at the top of the stack container. The content of the new element is copied and initialized.
stack_name.push(value_type& val);
The function accepts the following parameter(s) −
val − Value which we want to push
val − Value which we want to push
This function returns nothing
Input 
std::stack<int> stack1;
stack1.push(1);
stack1.push(2);
stack1.push(3);
Output 
3 2 1
 Live Demo
#include <iostream>
#include <stack>
using namespace std;
int main(){
   stack<int>stck;
   int Product = 1;
   stck.push(1);
   stck.push(2);
   stck.push(3);
   stck.push(4);
   stck.push(5);
   stck.push(6);
   while (!stck.empty()){
      Product = Product * stck.top();
      cout<<"\nsize of stack is: "<<stck.size();
      stck.pop();
   }
   return 0;
}
If we run the above code it will generate the following output −
size of stack is: 6
size of stack is: 5
size of stack is: 4
size of stack is: 3
size of stack is: 2
size of stack is: 1
stack::pop() function is an inbuilt function in C++ STL, which is defined in <stack>header file. pop() is used to pop or remove an element from the top of the stack container. The content from the top is removed and the size of the container is reduced by 1.
stack_name.pop();
The function accepts no parameter(s) −
This function returns nothing
Input 
std::stack<int> stack1;
stack1.push(1);
stack1.push(2);
stack1.push(3);
stack1.pop();
Output 
2 1
 Live Demo
#include <iostream>
#include <stack>
using namespace std;
int main(){
   stack<int> stck;
   int Product = 1;
   stck.push(1);
   stck.push(2);
   stck.push(3);
   stck.push(4);
   stck.push(5);
   stck.push(6);
   while (!stck.empty()){
      Product = Product * stck.top();
      cout<<"\nsize of stack is: "<<stck.size();
      stck.pop();
   }
   return 0;
}
If we run the above code it will generate the following output −
size of stack is: 6
size of stack is: 5
size of stack is: 4
size of stack is: 3
size of stack is: 2
size of stack is: 1
jQuery - Widget Dialog

The Widget Dialog function can be used with widgets in JqueryUI. Dialog boxes are one of the nice ways of presenting information on an HTML page. A dialog box is a floating window with a title and content area. This window can be moved, resized, and of course, closed using "X" icon by default.
Here is the simple syntax to use Dialog −
$( "#dialog" ).dialog();

Following is a simple example showing the usage of Dialog −
<!doctype html>
<html lang = "en">
   <head>
      <meta charset = "utf-8">
      <title>jQuery UI Dialog - Default functionality</title>
		
      <link rel = "stylesheet" 
         href = "//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
			
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
			
      <script type = "text/javascript" 
         src = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js">
      </script>
  
      <script>
         $(function() {
            $( "#dialog" ).dialog();
         });
      </script>
   </head>
	
   <body>
      <div id = "dialog" title = "Basic dialog">
         <p>This is the default dialog which is useful for displaying
            information. The dialog window can be moved, resized and closed with
            the 'x' icon.</p>
      </div>
 
   </body>
</html>
This will produce following result −
This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.

    27 Lectures 
     1 hours 

 Mahesh Kumar

    27 Lectures 
     1.5 hours 

 Pratik Singh

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    60 Lectures 
     9 hours 

 Eduonix Learning Solutions

    17 Lectures 
     2 hours 

 Sandip Bhattacharya

    12 Lectures 
     53 mins

 Laurence Svekis
 Print
 Add Notes
 Bookmark this page
Invoking functions with call() and apply() in JavaScript

Following is the code for invoking functions with call() and apply() in JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 18px;
      font-weight: 500;
      color: blueviolet;
   }
</style>
</head>
<body>
<h1>Invoking functions with call() and apply()</h1>
<div class="result"></div>
<br />
<button class="Btn">Click Here</button>
<h3>Click on the above buttons to invoke functions with call() and apply()
method</h3>
<script>
   let resEle = document.querySelector(".result");
   let BtnEle = document.querySelector(".Btn");
   function addNum(num1, num2, num3, num4) {
      return num1 + num2 + num3 + num4;
   }
   function multiplyNum(num1, num2, num3, num4) {
      return num1 * num2 * num3 * num4;
   }
   let arr = [22, 33, 44, 55];
   BtnEle.addEventListener("click", () => {
      resEle.innerHTML = "Sum of the numbers = " + addNum.call(this, 22, 33, 44, 55) + "<br>";
      resEle.innerHTML +="Multiplication of the array elements = " +multiplyNum.apply(this, arr) +"<br>";
   });
</script>
</body>
</html>
On clicking the ‘Click Here’ button −
Convert the number from Indian system to International system - GeeksforGeeks

04 Jun, 2020
Given an input string N consisting of numerals and separators (, ) in the Indian Numeric System, the task is to print the string after placing separators(, ) based on International Numeric System.
Examples:
Input: N = “12, 34, 56, 789”Output: 123, 456, 789
Input: N = “90, 05, 00, 00, 000”Output: 90, 050, 000, 000
Approach:
Remove all the separators (, ) from the string.Iterate from the end of the string and place a separator(, ) after every third number.Print the result.
Remove all the separators (, ) from the string.
Iterate from the end of the string and place a separator(, ) after every third number.
Print the result.
Below is the implementation of the above approach:
C++
// C++ Program to convert// the number from Indian system// to International system  #include <bits/stdc++.h>using namespace std;  // Function to convert Indian Numeric// System to International Numeric Systemstring convert(string input){    // Length of the input string    int len = input.length();      // Removing all the separators(, )    // From the input string    for (int i = 0; i < len; i++) {        if (input[i] == ',') {            input.erase(input.begin() + i);            len--;            i--;        }    }      // Initialize output string    string output = "";    int ctr = 0;      // Process the input string    for (int i = len - 1; i >= 0; i--) {          ctr++;        output = input[i] + output;          // Add a separator(, ) after        // every third digit        if (ctr % 3 == 0 && ctr < len) {            output = ',' + output;        }    }      // Return the output string back    // to the main function    return output;}  // Driver Codeint main(){    string input1 = "12,34,56,789";    string input2 = "90,05,00,00,000";      cout << convert(input1) << endl;    cout << convert(input2) << endl;}
123,456,789
90,050,000,000

Related article: Convert the number from International system to Indian system
Mathematical
School Programming
Strings
Strings
Mathematical
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Merge two sorted arrays
Program to find GCD or HCF of two numbers
Modulo Operator (%) in C/C++ with Examples
Prime Numbers
Program to find sum of elements in a given array
Python Dictionary
Arrays in C/C++
Inheritance in C++
Reverse a string in Java
Interfaces in Java
Create a Date Picker Calendar - Tkinter - GeeksforGeeks

19 Oct, 2021
Prerequisite: Tkinter
Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applications. In this article, we will learn how to create a date picker calendar in Tkinter.
In Tkinter, there is no in-built method for date picker calendar, here we will use the tkcalendar Module.
tkcalendar: tkcalendar is a Python module that provides the Calendar and DateEntry widgets for Tkinter. 
For installation run this command into your terminal:
pip install tkcalendar
Approach:
First, we will import the required library
Then we will create a Calendar Object and pass the default date
Pick the year, month, and date from the calendar
For getting the value of the picked date value, use the get() method.
Syntax: Calendar(master=None, **kw)
year: intCode block
it initially displayed year, default is the current year.
month: int
initially displayed month, default is the current month.
day: int
initially selected day, if month or year is given but not day, no initial selection, otherwise, default is today.
Below is the Implementation:-
Python3
# Import Required Libraryfrom tkinter import *from tkcalendar import Calendar # Create Objectroot = Tk() # Set geometryroot.geometry("400x400") # Add Calendarcal = Calendar(root, selectmode = 'day',               year = 2020, month = 5,               day = 22) cal.pack(pady = 20) def grad_date():    date.config(text = "Selected Date is: " + cal.get_date()) # Add Button and LabelButton(root, text = "Get Date",       command = grad_date).pack(pady = 20) date = Label(root, text = "")date.pack(pady = 20) # Execute Tkinterroot.mainloop()
Output:
simranarora5sos
adnanirshad158
Python Tkinter-exercises
Python-tkinter
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Box Plot in Python using Matplotlib
Bar Plot in Matplotlib
Python | Get dictionary keys as a list
Python | Convert set into a list
Ways to filter Pandas DataFrame by column values
Python - Call function from another file
loops in python
Multithreading in Python | Set 2 (Synchronization)
Python Dictionary keys() method
Python Lambda Functions
Calculate sine of a value in R Programming - sin() Function - GeeksforGeeks

01 Jun, 2020
sin() function in R Language is used to calculate the sine value of the numeric value passed to it as argument.
Syntax: sin(x)
Parameter:x: Numeric value
Example 1:
# R code to calculate sine of a value  # Assigning values to variablesx1 <- -90x2 <- -30  # Using sin() Functionsin(x1)sin(x2)
Output:
[1] -0.8939967
[1] 0.9880316
Example 2:
# R code to calculate sine of a value  # Assigning values to variablesx1 <- pix2 <- pi / 3  # Using sin() Functionsin(x1)sin(x2)
Output:
[1] 1.224647e-16
[1] 0.8660254
R Math-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Control Statements in R Programming
How to Replace specific values in column in R DataFrame ?
Loops in R (for, while, repeat)
Change Color of Bars in Barchart using ggplot2 in R
Group by function in R using Dplyr
Data Visualization in R
How to change Row Names of DataFrame in R ?
How to Change Axis Scales in R Plots?
Logistic Regression in R Programming
Remove rows with NA in one column of R DataFrame
Update _id field in MongoDB

To update, just save new ID and remove the old one using remove(). Let us first create a collection with documents −
> db.updatingDemo.insertOne({"StudentName":"Robert"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e04dae5150ee0e76c06a04b")
}
> db.updatingDemo.insertOne({"StudentName":"Bob"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e04dae7150ee0e76c06a04c")
}
Following is the query to display all documents from a collection with the help of find() method −
> db.updatingDemo.find();
This will produce the following output −
{ "_id" : ObjectId("5e04dae5150ee0e76c06a04b"), "StudentName" : "Robert" }
{ "_id" : ObjectId("5e04dae7150ee0e76c06a04c"), "StudentName" : "Bob" }
Here is the query to update _id in MongoDB −
> myDocument = db.updatingDemo.findOne({"StudentName":"Bob"});
{ "_id" : ObjectId("5e04dae7150ee0e76c06a04c"), "StudentName" : "Bob" }
> myDocument._id = 1001;
1001
> db.updatingDemo.insert(myDocument);
WriteResult({ "nInserted" : 1 })
> db.updatingDemo.remove({_id:ObjectId("5e04dae7150ee0e76c06a04c")});
WriteResult({ "nRemoved" : 1 })
Following is the query to display all documents from a collection with the help of find() method −
> db.updatingDemo.find();
This will produce the following output −
{ "_id" : ObjectId("5e04dae5150ee0e76c06a04b"), "StudentName" : "Robert" }
{ "_id" : 1001, "StudentName" : "Bob" }
Spring MVC - Page Redirection Example

The following example shows how to write a simple web based application, which makes use of redirect to transfer an http request to another page. To start with, let us have a working Eclipse IDE in place and consider the following steps to develop a Dynamic Form based Web Application using Spring Web Framework −
package com.tutorialspoint;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class WebController {

   @RequestMapping(value = "/index", method = RequestMethod.GET)
   public String index() {
	   return "index";
   }
   
   @RequestMapping(value = "/redirect", method = RequestMethod.GET)
   public String redirect() {
     
      return "redirect:finalPage";
   }
   
   @RequestMapping(value = "/finalPage", method = RequestMethod.GET)
   public String finalPage() {
     
      return "final";
   }
}
Following is the content of Spring view file index.jsp. This will be a landing page, this page will send a request to the access-redirect service method, which will redirect this request to another service method and finally a final.jsppage will be displayed.
<%@taglib uri = "http://www.springframework.org/tags/form" prefix = "form"%>
<html>
   <head>
      <title>Spring Page Redirection</title>
   </head>
   <body>
      <h2>Spring Page Redirection</h2>
      <p>Click below button to redirect the result to new page</p>
      <form:form method = "GET" action = "/HelloWeb/redirect">
         <table>
            <tr>
               <td>
                  <input type = "submit" value = "Redirect Page"/>
               </td>
            </tr>
         </table>  
      </form:form>
   </body>
</html>
<%@taglib uri = "http://www.springframework.org/tags/form" prefix = "form"%>
<html>
   
   <head>
      <title>Spring Page Redirection</title>
   </head>
   
   <body>
      <h2>Redirected Page</h2>
   </body>

</html>
Once you are done with creating source and configuration files, export your application. Right click on your application, use Export → WAR File option and save your HelloWeb.war file in Tomcat's webapps folder.
Now, start your Tomcat server and make sure you are able to access other webpages from webapps folder using a standard browser. Try a URL –http://localhost:8080/HelloWeb/index and you should see the following screen if everything is fine with the Spring Web Application.
Now click on the "Redirect Page" button to submit the form and to get to the final redirected page. We should see the following screen, if everything is fine with our Spring Web Application −
 Print
 Add Notes
 Bookmark this page
What is the difference between a method and a function?

Method and a function are the same, with different terms. A method is a procedure or function in object-oriented programming.
A function is a group of reusable code which can be called anywhere in your program. This eliminates the need for writing the same code again and again. It helps programmers in writing modular codes.
The following is the syntax of a JavaScript function:
<script type="text/javascript">
   <!--
      function functionname(parameter-list) {
         statements
      }
   //-->
</script>
Here’s an example:
<script type="text/javascript">
   <!--
      function sayHello() {
         alert("Hello there");
      }
   //-->
</script>
Empty List in C#

Set a list that has zero elements −
List<string> myList = new List<string>();
Now check whether the list is empty or null −
Console.WriteLine(myList == null);
Above, returns “False” i.e. the list is not null - the list is empty.
Let us see the complete code −
 Live Demo
using System;
using System.Collections.Generic;
using System.Linq;
public class Demo {
   public static void Main() {
      List<string> myList = new List<string>();
      // returns false i.e. an empty list (not a null list)
      Console.WriteLine(myList == null);
   }
}
False
PHP Generators.

Traversing a big collection of data using looping construct such as foreach would require large memory and considerable processing time. With generators it is possible to iterate over a set of data without these overheads. A generator function is similar to a normal function. However, instead of return statement in a function, generator uses yield keyword to be executed repeatedly so that it provides values to be iterated.
The yield keyword is the heart of generator mechanism. Even though its use appears to be similar to return, it doesn't stop execution of function. It provides next value for iteration and pauses execution of function.
A for loop yields each value of looping variable is used inside a generator function
 Live Demo
<?php
function squaregenerator(){
   for ($i=1; $i<=5; $i++){
      yield $i*$i;
   }
}
$gen=squaregenerator();
foreach ($gen as $val){
   echo $val . " ";
}
?>
As foreach statement tries to display valforfirsttime,thesquaregeneratoryieldsfirstelement,retainsi and pauses execution till foreach takes next iteration. The output is similar to a regular foreach loop
1 4 9 16 25
PHP's range() function returns a list of integers from starttostop with interval of $step between each numbers. Following program implements range() as generator
 Live Demo
<?php
function rangegenerator($start, $stop, $step){
   for ($i=$start; $i<=$stop; $i+=$step){
      yield $i;
   }
}
foreach (rangegenerator(2,10,2) as $val){
   echo $val . " ";
}
?>
Output is similar to range(2,20,2)
2 4 6 8 10
An associative array can also be implemented as generator
 Live Demo
<?php
function arrgenerator($arr){
   foreach ($arr as $key=>$val){
      yield $key=>$val;
   }
}
$arr=array("one"=>1, "two"=>2, "three"=>3, "four"=>4);
$gen=arrgenerator($arr);
foreach ($gen as $key=>$val)
echo $key . "=>" . $val . "\n";
?>
one=>1
two=>2
three=>3
four=>4
Lua - if...else statement

An if statement can be followed by an optional else statement, which executes when the Boolean expression is false.
The syntax of an if...else statement in Lua programming language is −
if(boolean_expression)
then
   --[ statement(s) will execute if the boolean expression is true --]
else
   --[ statement(s) will execute if the boolean expression is false --]
end

If the Boolean expression evaluates to true, then the if block of code will be executed, otherwise else block of code will be executed.
Lua programming language assumes any combination of Boolean true and non-nil values as true, and if it is either Boolean false or nil, then it is assumed as false value. It is to be noted that in Lua, zero will be considered as true.
--[ local variable definition --]
a = 100;

--[ check the boolean condition --]

if( a < 20 )
then
   --[ if condition is true then print the following --]
   print("a is less than 20" )
else
   --[ if condition is false then print the following --]
   print("a is not less than 20" )
end

print("value of a is :", a)
When you build and run the above code, it produces the following result.
a is not less than 20
value of a is :	100

An if statement can be followed by an optional else if...else statement, which is very useful to test various conditions using single if...else if statement.
While using if , else if , else statements, there are a few points to keep in mind −
An if can have zero or one else's and it must come after any else if's.
An if can have zero or one else's and it must come after any else if's.
An if can have zero to many else if's and they must come before the else.
An if can have zero to many else if's and they must come before the else.
Once an else if succeeds, none of the remaining else if's or else's will be tested.
Once an else if succeeds, none of the remaining else if's or else's will be tested.
The syntax of an if...else if...else statement in Lua programming language is −
if(boolean_expression 1)
then
   --[ Executes when the boolean expression 1 is true --]

elseif( boolean_expression 2)
   --[ Executes when the boolean expression 2 is true --]

elseif( boolean_expression 3)
   --[ Executes when the boolean expression 3 is true --]
else 
   --[ executes when the none of the above condition is true --]
end

--[ local variable definition --]
a = 100

--[ check the boolean condition --]

if( a == 10 )
then
   --[ if condition is true then print the following --]
   print("Value of a is 10" )
elseif( a == 20 )
then   
   --[ if else if condition is true --]
   print("Value of a is 20" )
elseif( a == 30 )
then
   --[ if else if condition is true  --]
   print("Value of a is 30" )
else
   --[ if none of the conditions is true --]
   print("None of the values is matching" )
end
print("Exact value of a is: ", a )
When you build and run the above code, it produces the following result.
None of the values is matching
Exact value of a is:	100


    12 Lectures 
     2 hours 

 Manish Gupta

    80 Lectures 
     3 hours 

 Sanjeev Mittal

    54 Lectures 
     3.5 hours 

 Mehmet GOKTEPE
 Print
 Add Notes
 Bookmark this page
How to enter values in an edit box in Selenium with python?

We can enter values in an edit box in Selenium with the help of the methods listed below −
Using the send_keys method.This method can send any text to an edit box or perform pressing keys with the help of Keys class.
Using the send_keys method.
This method can send any text to an edit box or perform pressing keys with the help of Keys class.
Using the Javascript executor.Javascript Document Object Model can work with any of the elements on the page. Javascript works on the client side and performs actions on the web page. Selenium can execute a Javascript script with the help of execute_script() method. We can enter values on any edit box with the help of this method.
Using the Javascript executor.
Javascript Document Object Model can work with any of the elements on the page. Javascript works on the client side and performs actions on the web page. Selenium can execute a Javascript script with the help of execute_script() method. We can enter values on any edit box with the help of this method.
Code Implementation with send_keys method.
from selenium import webdriver
#browser exposes an executable file
#Through Selenium test we will invoke the executable file which will then #invoke #actual browser
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
# to maximize the browser window
driver.maximize_window()
#get method to launch the URL
driver.get("https://www.tutorialspoint.com/index.htm")
#to refresh the browser
driver.refresh()
# identifying the edit box and entering text with send_keys method
driver. find_element_by_css_selector("input[class='gsc-input']").
send_keys("Selenium")
#to close the browser
driver.close()
Code Implementation with Javascript executor.
from selenium import webdriver
#browser exposes an executable file
#Through Selenium test we will invoke the executable file which will then #invoke #actual browser
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
# to maximize the browser window
driver.maximize_window()
#get method to launch the URL
driver.get("https://www.tutorialspoint.com/index.htm")
#to refresh the browser
driver.refresh()
# enter text with the Javascript executor
driver.execute_script(
"document.getElementsByName('search')[0].value = 'Selenium' ;")
#to close the browser
driver.close()
How to handle an exception using lambda expression in Java?


A lambda expression body can't throw any exceptions that haven't specified in a functional interface. If the lambda expression can throw an exception then the "throws" clause of a functional interface must declare the same exception or one of its subtype.
interface Student {
   void studentData(String name) throws Exception;
}
public class LambdaExceptionTest {
   public static void main(String[] args) {
      // lamba expression 
      Student student = name -> {
         System.out.println("The Student name is: " + name);
         throw new Exception();
      };
      try {
         student.studentData("Adithya");
      } catch(Exception e) {

      }
   }
}
The Student name is: Adithya
Differences between Java 8 and Java 9?

Java 9 version has introduced new enhancements and added new features. It includes JShell, Http2Client, Java Platform Module System (JPMS), Multi-release jar files, Stack Walking API, Private methods in an interface, Process API updates, Collection API updates, Stream API improvements, and etc.
Below are the few differences between Java 8 and Java 9
In Java 8 and earlier versions, the top-level component is the package. It places a set of related types (classes, interfaces, enums, and etc) into a group, and also contains a set of resources whereas Java 9 introduces a new component: module, which can be used to place a set of related packages into a group, and also another new component: the module descriptor, module-info.java file.
Java 8 applications use packages as a top-level component whereas Java 9 applications use modules as a top-level component.
Each Java 9 module has only one module with one module descriptor whereas Java 8 package doesn't build multiple modules into a single module.
Packages  
   - Types (classes, enums, interfaces, etc)
      - Code
      - Data
      - Resources
         - xml
         - images   
         - properties
Modules (Resources, Module Descriptor)
   - Packages
      - Types (classes, enums, interfaces, etc)
         - Code
         - Data
         - Resources
            - xml
            - images
            - properties
Delete records where timestamp older than 5 minutes in MySQL?

For this, use DELETE command. Let us first create a table −
mysql> create table DemoTable1851
     (
     DueDate datetime
     );
Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1851 values('2019-12-03 21:30:35');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1851 values('2019-12-03 21:45:00');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1851 values('2019-12-03 21:34:00');
Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1851;
This will produce the following output −
+---------------------+
| DueDate             |
+---------------------+
| 2019-12-03 21:30:35 |
| 2019-12-03 21:45:00 |
| 2019-12-03 21:34:00 |
+---------------------+
3 rows in set (0.00 sec)
The current date time is as follows −
mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2019-12-03 21:38:46 |
+---------------------+
1 row in set (0.00 sec)
Here is the query to delete records where timestamp is older than 5 minutes −
mysql> delete from DemoTable1851 where DueDate < (NOW() - INTERVAL 5 MINUTE);
Query OK, 2 rows affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1851;
This will produce the following output −
+---------------------+
| DueDate             |
+---------------------+
| 2019-12-03 21:45:00 |
+---------------------+
1 row in set (0.00 sec)