code-rag-bench/online-tutorials huggingface dataset:
continue statement in C

The continue statement in C programming works somewhat like the break statement. Instead of forcing termination, it forces the next iteration of the loop to take place, skipping any code in between.
For the for loop, continue statement causes the conditional test and increment portions of the loop to execute. For the while and do...while loops, continue statement causes the program control to pass to the conditional tests.
The syntax for a continue  statement in C is as follows −
continue;

#include <stdio.h>
 
int main () {

   /* local variable definition */
   int a = 10;

   /* do loop execution */
   do {
   
      if( a == 15) {
         /* skip the iteration */
         a = a + 1;
         continue;
      }
		
      printf("value of a: %d\n", a);
      a++;
   
   } while( a < 20 );
 
   return 0;
}
When the above code is compiled and executed, it produces the following result −
value of a: 10
value of a: 11
value of a: 12
value of a: 13
value of a: 14
value of a: 16
value of a: 17
value of a: 18
value of a: 19

 Print
 Add Notes
 Bookmark this page
PostgreSQL - Boolean Data Type - GeeksforGeeks

08 Jun, 2020
In this article, we will look into the PostgreSQL Boolean data type and it’s implementation while designing a database table. PostgreSQL boolean data type has 3 states namely TRUE< FALSE and NULL. It uses single byte for storing boolean value and can be abbreviated as BOOL.The below table depicts all valid literal values for TRUE and FALSE in PostgreSQL:
Now, let’s look into a few examples. For the same reason let’s create a sample database(say, bookstore) using the below command:
CREATE DATABASE bookstore;
Add a table (say, book_availability) to the bookstore database using the below command:
CREATE TABLE book_availability (
    book_id INT NOT NULL PRIMARY KEY,
    available BOOLEAN NOT NULL
);
Now insert some data to the book_availability table using the below command:
INSERT INTO book_availability (book_id, available)
VALUES
    (100, TRUE),
    (200, FALSE),
    (300, 't'),
    (400, '1'),
    (500, 'y'),
    (600, 'yes'),
    (700, 'no'),
    (800, '0');
Now that our database is ready let’s look into some examples.
Example 1:In this example we will query for all the available books in the bookstore.
SELECT
    *
FROM
    book_availability
WHERE
    available = 'yes';
Output:Example 2:In this example we will query for all books that are NOT available in the bookstore.
SELECT
    *
FROM
    book_availability
WHERE
    available = 'no';
Output:
Example 3:In this example we will make the use of NOT operator to check for books that are not available in the bookstore.
SELECT
    *
FROM
    book_availability
WHERE
    NOT available;
Output:
postgreSQL
postgreSQL-dataTypes
PostgreSQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
PostgreSQL - Change Column Type
PostgreSQL - Psql commands
PostgreSQL - For Loops
PostgreSQL - Function Returning A Table
PostgreSQL - Create Auto-increment Column using SERIAL
How to use PostgreSQL Database in Django?
PostgreSQL - DROP INDEX
PostgreSQL - Copy Table
PostgreSQL - Select Into
PostgreSQL - LIMIT with OFFSET clause
ASCII sum difference of strings in JavaScript

ASCII is a 7-bit character code where every single bit represents a unique character. Every
English alphabet has a unique decimal ascii code.
We are required to write a function that takes in two strings and calculates their ascii scores (i.e., the sum of ascii decimal of each character of string) and returns the difference.
Let’s write the code for this function −
The code for this will be −
const str1 = 'This is an example sting';
const str2 = 'This is the second string';
const calculateScore = (str = '') => {
   return str.split("").reduce((acc, val) => {
      return acc + val.charCodeAt(0);
   }, 0);
};
const ASCIIDifference = (str1, str2) => {
   const firstScore = calculateScore(str1);
   const secondScore = calculateScore(str2);
   return Math.abs(firstScore - secondScore);
};
console.log(ASCIIDifference(str1, str2));
The output in the console −
116
MariaDB - Create Database

Creation or deletion of databases in MariaDB requires privileges typically only given to root users or admins. Under these accounts, you have two options for creating a database − the mysqladmin binary and a PHP script.
The following example demonstrates the use of the mysqladmin binary in creating a database with the name Products −
[root@host]# mysqladmin -u root -p create PRODUCTS
Enter password:******

PHP employs the mysql_query function in creating a MariaDB database. The function uses two parameters, one optional, and returns either a value of “true” when successful, or “false” when not.
Review the following create database script syntax −
bool mysql_query( sql, connection );

The description of the parameters is given below −
sql
This required parameter consists of the SQL query needed to perform the operation.
connection
When not specified, this optional parameter uses the most recent connection used.
Try the following example code for creating a database −
<html>
   <head>
      <title>Create a MariaDB Database</title>
   </head>

   <body>
      <?php
         $dbhost = 'localhost:3036';
         $dbuser = 'root';
         $dbpass = 'rootpassword';
         $conn = mysql_connect($dbhost, $dbuser, $dbpass);
      
         if(! $conn ) {
            die('Could not connect: ' . mysql_error());
         }

         echo 'Connected successfully<br />';
         $sql = 'CREATE DATABASE PRODUCTS';
         $retval = mysql_query( $sql, $conn );
      
         if(! $retval ) {
            die('Could not create database: ' . mysql_error());
         }

         echo "Database PRODUCTS created successfully\n";
         mysql_close($conn);
      ?>
   </body>
</html>
On successful deletion, you will see the following output −
mysql> Database PRODUCTS created successfully 
mysql> SHOW DATABASES; 
+-----------------------+ 
| Database              | 
+-----------------------+ 
| PRODUCTS              | 
+-----------------------+  

 Print
 Add Notes
 Bookmark this page
Cypress - Configuration of JSON File

Cypress configurations consist of some key-value pairs that are applicable to all tests within a framework. Cypress default configurations are available under the Settings tab->Configuration (expand it) in the Test Runner window.
If we look further down in the same window, we shall have the existing values of multiple configurations given by Cypress like the timeouts, environment variables, folder path, and so on.
It is displayed below −
If we look further down in the same window, we shall have the existing values of multiple configurations given by Cypress like the timeouts, environment variables, folder path, and so on.
It is displayed below −
To override the default configurations from the cypress.json file, we have to specify the key-value pairs.
The implementation for overriding the default values for JSON file is as follows −
{
   "baseUrl" : "https://www.google.com/"
}
Here, the key is baseUrl and the value is https://www.google.com/. Once the tests are
run again, the changes are reflected in the global configurations, as shown below −
The implementation of actual test for overriding default values of the JSON file is as follows −
describe('Tutorialspoint', function () {
// test case
   it('First Test', function (){
      // launch application from configuration
      cy.visit("/")
   });
});
Execution Results
The output is as follows −
The execution logs show that the baseUrl has been obtained from the cypress.json file and it is applicable to all tests within the framework.
We can override the default configurations from the test scripts, which become applicable to an individual test step, within the test case and not to the complete framework.
This is done with the help of the config command in Cypress.
For example, if we want to increase the default timeout for a particular test step, implementation shall be as follows −
//set default time out to nine seconds from following steps in test
Cypress.config('defaultCommandTimeout',9000)
landPage.selectUser().click()

Simultaneously if the defaultCommandTimeout value is set to seven seconds in the cypress.json file, then Cypress shall give preference to the timeout applied to the test step(i.e nine seconds).
Finally, it gives preference to the default configurations.
We can disable the feature to override the default configurations from the cypress.json.
The configuration in cypress.json is as follows −
{
   "defaultCommandTimeout" : "9000"
}

To disable the above configuration, run the below mentioned command −
npx cypress open --config-file false

After running the above command, the Settings tab of the Test Runner window will show the config flag set to false.
Also, defaultCommandTimeout is set to four seconds, which is set by the default configuration and not overridden by cypress.json value of nine seconds.

    73 Lectures 
     12 hours 

 Rahul Shetty
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.6 - Show Node.js Command Prompt

var mysql = require('mysql');
​
var con = mysql.createConnection({
  host: "localhost",
  user: "myusername",
  password: "mypassword"
});
​
con.connect(function(err) {
  if (err) throw err;
ReactJS - Event management

Event management is one of the important features in a web application. It enables the user to interact with the application. React support all events available in a web application. React event handling is very similar to DOM events with little changes. Let us learn how to handle events in a React application in this chapter.
Let us see the step-by-step process of handling an event in a React component.
Define an event handler method to handle the given event.
Define an event handler method to handle the given event.
log() { 
   cosole.log("Event is fired"); 
}
React provides an alternative syntax using lambda function to define event handler. The lambda syntax is −
log = () => { 
   cosole.log("Event is fired"); 
}
If you want to know the target of the event, then add an argument e in the handler method. React will send the event target details to the handler method.
log(e) { 
   cosole.log("Event is fired"); 
   console.log(e.target); 
}
The alternative lambda syntax is −
log = (e) => { 
   cosole.log("Event is fired"); 
   console.log(e.target); 
}
If you want to send extra details during an event, then add the extra details as initial argument and then add argument (e) for event target.
log(extra, e) { 
   cosole.log("Event is fired"); 
   console.log(e.target); 
   console.log(extra); 
   console.log(this); 
}
The alternative lambda syntax is as follows −
log = (extra, e) => { 
   cosole.log("Event is fired"); 
   console.log(e.target); 
   console.log(extra); 
   console.log(this); 
}
Bind the event handler method in the constructor of the component. This will ensure the availability of this in the event handler method.
constructor(props) { 
   super(props); 
   this.logContent = this.logContent.bind(this); 
}
If the event handler is defined in alternate lambda syntax, then the binding is not needed. this keyword will be automatically bound to the event handler method.
Set the event handler method for the specific event as specified below −
<div onClick={this.log}> ... </div>

To set extra arguments, bind the event handler method and then pass the extra information as second argument.
<div onClick={this.log.bind(this, extra)}> ... </div>

The alternate lambda syntax is as follows −
<div onClick={this.log(extra, e)}> ... </div>

Here,
Create a event-aware component
Create a event-aware component
Introduce events in Expense manager app
Introduce events in Expense manager app
Binary search in sorted vector of pairs

12 Jun, 2022
How to apply STL binary_search to vector of pairs(key, value), given that vector is sorted by its first value(key) struct compare in the code contains two functions which compares the key(searching element) with the first element in the vector 
CPP
/* C++ code to demonstrate how Binary Searchcan be applied on a vector of pairs */#include <bits/stdc++.h>using namespace std; struct compare { bool operator()(const pair<int, int>& value,        const int& key) {  return (value.first < key); } bool operator()(const int& key,     const pair<int, int>& value) {  return (key < value.first); }}; int main(){ // initializing the vector of pairs vector<pair<int, int> > vect;  // insertion of pairs (key, value) in vector vect vect.push_back(make_pair(1, 20)); vect.push_back(make_pair(3, 42)); vect.push_back(make_pair(4, 36)); vect.push_back(make_pair(2, 80)); vect.push_back(make_pair(7, 50)); vect.push_back(make_pair(9, 20)); vect.push_back(make_pair(3, 29));  // sorting the vector according to key sort(vect.begin(), vect.end());  // printing the sorted vector cout << "KEY" << '\t' << "ELEMENT" << endl; for (pair<int, int>& x : vect)  cout << x.first << '\t' << x.second << endl;  // searching for the key element 3 cout << "search for key 3 in vector" << endl; if (binary_search(vect.begin(), vect.end(),        3, compare()))  cout << "Element found"; else  cout << "Element not found";  return 0;}
KEY    ELEMENT
1    20
2    80
3    29
3    42
4    36
7    50
9    20
search for key 3 in vector
Element found
Time complexity: O(n log n) (As sort() function is used)
Auxiliary Space: O(1)
Code_Mech
codewithrathi
cpp-pair
cpp-vector
STL
C++
Searching
Searching
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting a vector in C++
Polymorphism in C++
Friend class and function in C++
std::string class in C++
Pair in C++ Standard Template Library (STL)
Binary Search
Maximum and minimum of an array using minimum number of comparisons
Linear Search
K'th Smallest/Largest Element in Unsorted Array | Set 1
Search an element in a sorted and rotated array
How to match whitespace but not newlines using Python regular expressions?

The following code matches only the whitespaces but not newlines in the given string
import re
print re.findall(r"(\s){1,}","""I find
    Tutorialspoint useful""")
This gives the output
[' ', ' ', ' ']
Online Javascript Minifier

Editable Javascript Code
123456789101112131415161718192021222324252627282930$('#input').click(function() {  if (    $(this).val() == 'Type (or paste) your input here...'  ) {    $(this).val('');  }});$('#output').click(function() {  if (    $(this).val() == 'Compressed output goes here...'  ) {    $(this).val('');  }});$("#Minify").click(function(event){   var inputText = $("#input").val();   var charsetText = $("#charset").val();   var formData = {input:"" + inputText + "", charset: "" + charsetText + ""};   $.ajax({                                             type: "POST",      cache: false,      url: "javascript_minify.php",                 data: formData,      success: function(data) {            $('#output').val( data );      }   }); });X
Privacy Policy
Cookies Policy
Terms of Use
Python: The Boolean confusion. `if val` and `if val is not None` are... | by Akash Panchal | Towards Data Science

if valand if val is not None are not the same!
When you do if val is None, you call the operator is, which checks the identity of x. i.e, if val is value Here, is operator checks whether both the operands refer to the same object or not.
None is a singleton in Python and all None values are also the exact same instance.
when you say if val, python behaves differently. if expects a boolean, and assuming val is not a boolean, Python automatically calls val’s __bool__ a method.
if val is actually executed as if val.__bool__
The confusing thing is, that bool(None) returns False, so if val is None. This works as expected but there are other values that are evaluated as False.
The most important example is of an empty list. bool([]) returns False as well. Usually, an empty list has a different meaning thanNone; None means no value while an empty list means zero values. Semantically, they are different.
Here are some of the example for better understanding.
We will execute the following block of conditions against the different values:
if val:    print('if val')if not val:    print('if not val')if val is not None:    print('if val is not None')if val is None:    print('if val is None')
1. None
val = Noneif not valif val is None
2. [] (empty list)
val = []if not valif val is not None
3. [27, 37] (non-empty list)
val = [27, 37]if valif val is not None
4. 0 (number — zero)
val = 0if not valif val is not None
5. 1 (number — one/non-zero)
val = 1if valif val is not None
6. An Object
val = object()if valif val is not None
Interesting, right? Give it a try!
Java Program to convert integer to octal

To convert integer to octal in Java, use the Integer.toOctalString() method.
Let’s say the following is our integer.
int val = 768;
Convert the above integer to octal.
Integer.toOctalString(val)
The following is the final example.
 Live Demo
public class Demo {
    public static void main(String[] args) {
       int val = 768;
       // integer
       System.out.println("Integer: "+val);
       // octal
       System.out.println("Octal String = " + Integer.toOctalString(val));
    }
}
Integer: 768
Octal String = 1400
C# Enum Parse Method

The Parse method in Enum converts the string representation of the name or numeric value of enum constants to an equivalent enumerated object.
The following is our enumeration.
enum Vehicle { Car, Bus, Truck, Motobike };
Now, use the GetNames() method in a loop to get the enum values. Parse them using the Enum.Parse() method as shown below −
Enum.Parse(typeof(Vehicle)
 Live Demo
using System;
public class Demo {
   enum Vehicle { Car, Bus, Truck, Motobike };
   public static void Main() {
      Console.WriteLine("The enumeration...");
      foreach (string v in Enum.GetNames(typeof(Vehicle))) {
         Console.WriteLine("{0} = {1:D}", v, Enum.Parse(typeof(Vehicle), v));
      }
      Console.WriteLine();
   }
}
The enumeration...
Car = 0
Bus = 1
Truck = 2
Motobike = 3
How to compute Average for the Set of Values using C#?

Firstly, set an array with values −
int[] myArr = new int[] {
   34,
   23,
   77,
   67
};
To get the average, firstly get the sum of array elements.
Divide the sum with the length of the array and that will give you the average of the elements −
int sum = 0;
int average = 0;
for (int i = 0; i < len; i++) {
   sum += myArr[i];
}
average = sum / len;
The following is the complete code to get the array in C# −
 Live Demo
using System;
public class Program {
   public static void Main() {
      int[] myArr = new int[] {
         34,
         23,
         77,
         67
      };
      int len = myArr.Length;
      int sum = 0;
      int average = 0;
      for (int i = 0; i < len; i++) {
         sum += myArr[i];
      }
      average = sum / len;
      Console.WriteLine("Average = " + average);
   }
}
Average = 50
CSS | font-display property - GeeksforGeeks

07 May, 2020
While using web fonts, the text will be invisible until either web font is loaded or three seconds are passed, at which point the fallback font is used.
Font-display allows customizing how web fonts are displayed when the page is being rendered.
It is applied using @font-face rule which defines custom fonts in a style sheet.
Syntax:
@font-face {
  font-family: Sample;
  src: url(samplefont.woff) format('woff'),
       url(samplefontbold.woff) format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: optional;
}
Example:
<!DOCTYPE html><html><head>    <title>CSS | font-display</title>    <meta name='viewport' content="width=device-width, initial-scale=1">    <style>        @font-face {        font-family: Roboto;        src: url(Roboto\Roboto-BoldItalic.ttf) format('truetype');        font-style: italic;        font-weight: bold;        font-display: block;    }      div{        font-family: Roboto;        font-style: italic;        font-weight:bold;    }</style></head><body><h1>Usage of font-display</h1><div>Downloaded font</div><p>Normal font</p></body></html>
Output:
The downloaded font appears after a short span. Try running it on IDE to see it.
The font-display property timeline is divided into three periods:
Block
Swap
Failure
Block Period:The text will be invisible till web font hasn’t loaded, rendering is blocked in this period.
Swap Period:Originally the fallback font is used to render text, if web font is successfully loaded during the swap period, the fallback font is swapped with the web font.
Failure Period:At this point it is considered that loading is failed and the fallback font is to be used.
This property accepts the following values:
Auto (Initial value): At this value, the font-display technique is chosen by the browser. This is usually similar to Block value.
Block: It goes for a small block period and then goes into an infinite swap period so the rendering is allowed infinitely. In simpler form, it hides the text until web font is loaded.
Swap: At this value, the font-face is provided with minimal block period and an infinite swap period. It uses fallback font until web font is loaded
Fallback: It gives the font-face a minimal block period(100 ms) and a small swap period(about 3 seconds). It tries to load web font for a short period then goes into failure period and uses fallback font.
Optional: It gives the font-face a minimal block period and no swap period. It hides the text for a short time and then uses fallback font until web font is the custom font is available to use.
CSS-Properties
Picked
CSS
Web Technologies
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Design a web page using HTML and CSS
Form validation using jQuery
How to set space between the flexbox ?
Search Bar using HTML, CSS and JavaScript
How to Create Time-Table schedule using HTML ?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Perl sleep Function

This function Pauses the script for EXPR seconds, or forever if EXPR is not specified. Returns the number of seconds actually slept. Can be interrupted by a signal handler, but you should avoid using sleep with alarm, since many systems use alarm for the sleep implementation.
Following is the simple syntax for this function −
sleep EXPR

sleep

This function returns Integer, number of seconds actually slept
Following is the example code showing its basic usage −
#!/usr/bin/perl

$num = 5;
while($num--) {
   sleep(1);
}

    46 Lectures 
     4.5 hours 

 Devi Killada

    11 Lectures 
     1.5 hours 

 Harshit Srivastava

    30 Lectures 
     6 hours 

 TELCOMA Global

    24 Lectures 
     2 hours 

 Mohammad Nauman

    68 Lectures 
     7 hours 

 Stone River ELearning

    58 Lectures 
     6.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
How to convert std::string to LPCSTR in C++?

In this section we will see how to convert C++ string (std::string) to LPCSTR. The LPCSTR is the (Long Pointer to Constant STRing). It is basically the string like C. So by converting string to character array we can get LPCSTR. This LPCSTR is Microsoft defined. So to use them we have to include Windows.h header file into our program.
To convert std::string to C like string we can use the function called c_str().
#include<iostream>
#include<Windows.h>
using namespace std;
main() {
   string my_str = "Hello World";
   LPTSTR long_string = new TCHAR[my_str.size() + 1]; //define
   an array with size of my_str + 1
   strcpy(long_string, my_str.c_str());
   cout << "my_str is : " << my_str <<endl;
   cout << "Long String is : " << long_string <<endl;
}
my_str is : Hello World
Long String is : Hello World
How to add Phone Number Input in React.js ? - GeeksforGeeks

28 Dec, 2021
In this article, we are going to learn how we can add phone input in ReactJs. React is a free and open-source front-end JavaScript library for building user interfaces or UI components. It is maintained by Facebook and a community of individual developers and companies.
Approach: To add our phone input we are going to use the react-phone-input-2 package. The react-phone-input-2 package helps us to integrate the phone input in our app. So first, we will install the react-phone-input-2 package and then we will add a phone input on our homepage.
Create ReactJs Application: You can create a new ReactJs project using the below command:
npx create-react-app gfg
Install the required package: Now we will install the react-phone-input-2 package using the below command:
npm i react-phone-input-2
Project Structure: It will look like this.
Adding the Phone Input: After installing the package we can easily add a phone input on any page in our app. For this example, we are going to add a phone input to our homepage.
Add the below content in the App.js file:
Javascript
import React, { useState } from "react";import PhoneInput from 'react-phone-input-2'import 'react-phone-input-2/lib/style.css'  export default class PhoneInputGfg extends React.Component {  constructor(props) {    super(props);    this.state = { phone: "" };  }  render(){    return (      <div>        <h1>ReactJs Phone Input - GeeksforGeeks</h1>        <PhoneInput          country={'us'}          value={this.state.phone}          onChange={phone => this.setState({ phone })}        />      </div>    );  }};
Explanation: In the above example first, we are importing the PhoneInput component and useState hook from react. Then we are using the useState hook to store the value of the phone number. After that, we are adding our phone input using the installed package.
Steps to run the application: Run the below command in the terminal to run the app.
npm start
React-Questions
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
Remove elements from a JavaScript Array
How to get character array from string in JavaScript?
How to filter object array based on attributes?
How to get selected value in dropdown list using JavaScript ?
How to remove duplicate elements from JavaScript Array ?
Lodash _.debounce() Method
Angular File Upload
JavaScript | Promises
How can we alter a MySQL stored function?

If we have ALTER ROUTINE privileges then we can alter MySQL stored function with the help of ALTER FUNCTION query. Its syntax is as follows −
ALTER FUNCTION function_name [characteristic ...]
characteristic:
   { CONTAINS SQL | NO SQL | READS SQL DATA | MODIFIES SQL DATA }
| SQL SECURITY { DEFINER | INVOKER }
| COMMENT 'string'
Here function_name is the name of the function which we want to alter.
The ALTER FUNCTION statement can change the characteristics, defined above in the syntax, of a stored function. We can specify more than one change in an ALTER FUNCTION statement. But we cannot change the parameters or body of the function with this statement. To illustrate it we are adding comments in the function name ‘factorial’ in the following example −
mysql> ALTER FUNCTION factorial COMMENT 'Can accept fraction values';
Query OK, 0 rows affected (0.00 sec)

mysql> Show Create Function factorial\G
*************************** 1. row ***************************
       Function: factorial
       sql_mode: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Create Function: CREATE DEFINER=`root`@`localhost` FUNCTION `factorial`(n DECIMAL(3,0)) RETURNS decimal(20,0)
DETERMINISTIC
COMMENT 'Can accept fraction values'
BEGIN
DECLARE factorial DECIMAL(20,0) DEFAULT 1;
DECLARE counter DECIMAL(3,0);
SET counter = n;
      factorial_loop: REPEAT
SET factorial = factorial * counter;

SET counter = counter - 1;
   UNTIL counter = 1
END REPEAT;
   RETURN factorial;
END

character_set_client: cp850
collation_connection: cp850_general_ci
  Database Collation: latin1_swedish_ci
1 row in set (0.00 sec)
From the CREAT FUNCTION query, it is clear that Comment has been added to the definition of function ‘factorial’.
Tryit Editor v3.7

Tryit: CSS padding
Open New Browser Tab in Selenuim

Answer − We can open a new browser tab in Selenium webdriver. The methods - Keys.chord and sendKeys are required to achieve this task. The Keys.chord method is used to send multiple keys at once.
We shall pass Keys.CONTROL and Keys.ENTER as parameters to this method. The complete string is again passed as a parameter to the sendKeys. Finally, the method sendKeys shall be applied on the link which we want to open in a new tab
Syntax
String l = Keys.chord(Keys.CONTROL,Keys.ENTER);
driver.findElement(By.xpath("//*[text()='Links']")). sendKeys(l);
Code Implementation
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.Keys;
public class OpenNewTab{
   public static void main(String[] args) {
      System.setProperty("webdriver.gecko.driver",
      "C:\\Users\\ghs6kor\\Desktop\\Java\\geckodriver.exe");
      WebDriver driver = new FirefoxDriver();
      // wait of 5 seconds
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      //url launch
      driver.get("https://www.tutorialspoint.com/about/about_careers.htm");
      // Keys.Chord string
      String l = Keys.chord(Keys.CONTROL,Keys.ENTER);
      // open new tab
      driver.findElement(By.xpath("//*[text()='Terms of Use']")).sendKeys(l);
   }
}
Rexx - If statement

The first decision-making statement is the if statement. An if statement consists of a Boolean expression followed by one or more statements.
The general form of this statement in Rexx is as follows −
if (condition) then 
   do 
      #statement1 
      #statement2 
   end

In Rexx, the condition is an expression which evaluates to either true or false. If the condition is true, then the subsequent statements in the loop are executed.
The following diagram shows the diagrammatic explanation of this loop.
In the above diagram, you can see that only if the condition is evaluated to true does the conditional code gets executed.
The following program is an example of the simple if expression in Rexx.
/* Main program */ 
i = 5 

if (i < 10) then 
   do 
      say "i is less than 10" 
   end
The following key things need to be noted about the above program −
The if statement is used to first evaluate if the value of i is less than 10.
The if statement is used to first evaluate if the value of i is less than 10.
If yes, then the statement inside the do loop is evaluated.
If yes, then the statement inside the do loop is evaluated.
The output of the above program will be −
i is less than 10 

 Print
 Add Notes
 Bookmark this page
Add arrow in tooltip with CSS

With CSS, you can add a small arrow to the tooltip, using :after. With that, use the content property as well.
You can try to run the following code to add an arrow in the tooltip:
Live Demo
<!DOCTYPE html>
<html>
   <style>
      .mytooltip .mytext {
         visibility: hidden;
         width: 140px;
         background-color: blue;
         color: #fff;
         z-index: 1;
         bottom: 100%;
         left: 60%;
         margin-left: -90px;
         text-align: center;
         border-radius: 6px;
         padding: 5px 0;
         position: absolute;
      }
      .mytooltip {
         position: relative;
         display: inline-block;
         margin-top: 50px;
      }
      .mytooltip .mytext:after {
         content: "";
         position: absolute;
         top: 100%;
         left: 50%;
         margin-left: -10px;
         border-width: 7px;
         border-style: solid;
         border-color: blue transparent transparent transparent;
      }
      .mytooltip:hover .mytext {
         visibility: visible;
      }
   </style>

   <body>
      <div class = "mytooltip">Keep mouse cursor over me
         <span class = "mytext"> My Tooltip text</span>
      </div>
   </body>
</html>
Nested functions in C

In some applications, we have seen that some functions are declared inside another function. This is sometimes known as nested function, but actually this is not the nested function. This is called the lexical scoping. Lexical scoping is not valid in C because the compiler is unable to reach correct memory location of inner function.
Nested function definitions cannot access local variables of surrounding blocks. They can access only global variables. In C there are two nested scopes the local and the global. So nested function has some limited use. If we want to create nested function like below, it will generate error.
#include <stdio.h>
main(void) {
   printf("Main Function");
   int my_fun() {
      printf("my_fun function");
      // defining another function inside the first function.
      int my_fun2() {
         printf("my_fun2 is inner function");
      }
   }
   my_fun2();
}
text.c:(.text+0x1a): undefined reference to `my_fun2'
But an extension of GNU C compiler allows declaration of the nested function. For this we have to add auto keyword before the declaration of nested function.
#include <stdio.h>
main(void) {
   auto int my_fun();
   my_fun();
   printf("Main Function\n");
   int my_fun() {
      printf("my_fun function\n");
   }
   printf("Done");
}
my_fun function
Main Function
Done
SymPy - Printing

There are several printers available in SymPy. Following is a partial list −
str
srepr
ASCII pretty printer
Unicode pretty printer
LaTeX
MathML
Dot
SymPy objects can also be sent as output to code of various languages, such as C, Fortran, Javascript, Theano, and Python.
SymPy uses Unicode characters to render output in form of pretty print. If you are using Python console for executing SymPy session, the best pretty printing environment is activated by calling init_session() function.
>>> from sympy import init_session 
>>> init_session()

IPython console for SymPy 1.5.1 (Python 3.7.4-64-bit) (ground types: python).
These commands were executed −
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)
>>> init_printing()

Documentation can be found at https://docs.sympy.org/1.5.1/.
>>> Integral(sqrt(1/x),x)

∫1xdx
If LATEX is not installed, but Matplotlib is installed, it will use the Matplotlib rendering engine. If Matplotlib is not installed, it uses the Unicode pretty printer. However, Jupyter notebook uses MathJax to render LATEX.
In a terminal that does not support Unicode, ASCII pretty printer is used.
To use ASCII printer use pprint() function with use_unicode property set to False
>>> pprint(Integral(sqrt(1/x),x),use_unicode=False)

The Unicode pretty printer is also accessed from pprint() and pretty(). If the terminal supports Unicode, it is used automatically. If pprint() is not able to detect that the terminal supports unicode, you can pass use_unicode=True to force it to use Unicode.
To get the LATEX form of an expression, use latex() function.
>>> print(latex(Integral(sqrt(1/x),x)))

\int \sqrt{\frac{1}{x}}\, dx
You can also use mathml printer. for that purpose, import print_mathml function. A string version is obtained by mathml() function.
>>> from sympy.printing.mathml import print_mathml 
>>> print_mathml(Integral(sqrt(1/x),x))

<apply>
<int/>
<bvar>
<ci>x</ci>
</bvar>
<apply>
<root/>
<apply>
<power/>
<ci>x</ci>
<cn>-1</cn>
</apply>
</apply>
</apply>
>>>mathml(Integral(sqrt(1/x),x))

'<apply><int/><bvar><ci>x</ci></bvar><apply><root/><apply><power/><ci>x</ci><cn>-1</cn></apply></apply></apply>'
 Print
 Add Notes
 Bookmark this page
Different Methods to find Prime Number in Java

A prime number is a number that is only divisible by one or itself. Some of the prime numbers are 2, 3, 5, 7, 11, 13 etc.
Some of the different methods to find a prime number in Java are given as follows −
A program that finds if the given number is prime without using a function is given as follow −
 Live Demo
public class Example {
   public static void main(String args[]) {
      int num = 11, flag=0;
      if(num == 0||num == 1) {
         System.out.println( num + " is not a prime number");
      } else {
         for(int i = 2; i <= num/2; i++) {
            if(num % i == 0) {
               System.out.println( num + " is not prime number");
               flag = 1;
               break;
            }
         }
         if(flag == 0) {
            System.out.println( num + " is a prime number");
         }
      }
   }
}
11 is a prime number
A program that finds if the given number is prime using a function is given as follow −
 Live Demo
public class Example {
   static int PrimeOrNot(int num) {
      int flag = 0;
      if(num == 0||num == 1) {
         flag = 1;
      } else {
         for(int i = 2; i <= num/2; i++) {
            if(num % i == 0) {
               flag = 1;
               break;
            }
         }
      }
      return flag;
   }
   public static void main(String args[]) {
      int flag, num = 11;
      flag = PrimeOrNot(num);
      if(flag == 0) {
         System.out.println( num + " is a prime number");
      } else {
         System.out.println( num + " is not a prime number");
      }
   }
}
11 is a prime number
React Props

Props are arguments passed into React components.
Props are passed to components via HTML attributes.
props stands for properties.
React Props are like function arguments in JavaScript and attributes 
in HTML.
To send props into a component, use the same syntax as HTML attributes:
Add a "brand" attribute to the Car element:
const myElement = <Car brand="Ford" />;
The component receives the argument as a props object:
Use the brand attribute in the component:
function Car(props) {
  return <h2>I am a { props.brand }!</h2>;
}


Run 
Example »

Props are also how you pass data from one component to another, as parameters.
Send the "brand" property from the Garage component to the Car component:
function Car(props) {
  return <h2>I am a { props.brand }!</h2>;
}

function Garage() {
  return (
    <>
      <h1>Who lives in my garage?</h1>
      <Car brand="Ford" />
    </>
  );
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Garage />);


Run 
Example »

If you have a variable to send, and not a string as in the example above, you just put the variable name inside curly brackets:
Create a variable named carName and send it to the 
Car component:
function Car(props) {
  return <h2>I am a { props.brand }!</h2>;
}

function Garage() {
  const carName = "Ford";
  return (
    <>
      <h1>Who lives in my garage?</h1>
      <Car brand={ carName } />
    </>
  );
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Garage />);


Run 
Example »

Or if it was an object:
Create an object named carInfo and send it to the 
Car component:
function Car(props) {
  return <h2>I am a { props.brand.model }!</h2>;
}

function Garage() {
  const carInfo = { name: "Ford", model: "Mustang" };
  return (
    <>
      <h1>Who lives in my garage?</h1>
      <Car brand={ carInfo } />
    </>
  );
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Garage />);


Run 
Example »

Note: React Props are read-only! You will get an error if you try to change their 
value.
Create a variable named name and pass it to the Message component.
function Person(props) {
  return <h2>I'm { props.name }!</h2>;
}

function Greeting() {
  const name = "Jesse"
  return (
    <>
      <h1>Hello!</h1>
      <Person name= name  />
    </>
  );
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Greeting />);

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How do you overlap widgets/frames in Python tkinter?

There are three general ways through which we can align and position a particular widget in a Tkinter application. Let us suppose that we want to overlap two or more widgets or frames one on another, then we can use place() geometry manager. What place() geometry manager does is that it lines up the widget in rows and columns of a grid. We can certainly overlap the widget by providing the same coordinate in each.
# Import the required libraries
from tkinter import *
from tkinter import ttk

# Create an instance of tkinter frame
win = Tk()

# Set the size of the tkinter window
win.geometry("700x350")

# Add a Frame
frame1= Frame(win, bg= "LightPink1")

# Add an optional Label widget
Label(frame1, text= "Welcome Folks!", font= ('Aerial 18 bold italic'), background= "white").pack(pady= 50)
frame1.place(x= 260, y= 50)

# Add a Button widget in second frame
ttk.Button(frame1, text= "Button").place(x= 260, y=50)
win.mainloop()
Executing the above code will display a window with a Label and a button widget inside the frame.
PyTorch - Loading Data

PyTorch includes a package called torchvision which is used to load and prepare the dataset. It includes two basic functions namely Dataset and DataLoader which helps in transformation and loading of dataset.
Dataset is used to read and transform a datapoint from the given dataset. The basic syntax to implement is mentioned below −
trainset = torchvision.datasets.CIFAR10(root = './data', train = True,
   download = True, transform = transform)
DataLoader is used to shuffle and batch data. It can be used to load the data in parallel with multiprocessing workers.
trainloader = torch.utils.data.DataLoader(trainset, batch_size = 4,
   shuffle = True, num_workers = 2)
We use the Python package Panda to load the csv file. The original file has the following format: (image name, 68 landmarks - each landmark has a x, y coordinates).
landmarks_frame = pd.read_csv('faces/face_landmarks.csv')

n = 65
img_name = landmarks_frame.iloc[n, 0]
landmarks = landmarks_frame.iloc[n, 1:].as_matrix()
landmarks = landmarks.astype('float').reshape(-1, 2)
 Print
 Add Notes
 Bookmark this page
Flatten a 2d numpy array into 1d array in Python

A 2d numpy array is an array of arrays. In this article we will see how to flatten it to get the elements as one dimensional arrays.
The flatten function in numpy is a direct way to convert the 2d array in to a 1D array.
 Live Demo
import numpy as np
array2D = np.array([[31, 12, 43], [21, 9, 16], [0, 9, 0]])
# printing initial arrays
print("Given array:\n",array2D)
# Using flatten()
res = array2D.flatten()
# Result
print("Flattened array:\n ", res)
Running the above code gives us the following result −
Given array:
[[31 12 43]
[21 9 16]
[ 0 9 0]]
Flattened array:
[31 12 43 21 9 16 0 9 0]
There is another function called ravel which will do a similar thing of flattening the 2D array into 1D.
 Live Demo
import numpy as np
array2D = np.array([[31, 12, 43], [21, 9, 16], [0, 9, 0]])
# printing initial arrays
print("Given array:\n",array2D)
# Using ravel
res = array2D.ravel()
# Result
print("Flattened array:\n ", res)
Running the above code gives us the following result −
Given array:
[[31 12 43]
[21 9 16]
[ 0 9 0]]
Flattened array:
[31 12 43 21 9 16 0 9 0]
How to check if a string contains a specific sub string?

To check if a string contains a specific substring, the ‘strlen’ and ‘strpos’ functions can be used. The ‘strlen’ gives the entire length of the string. The function ‘strpos’ finds the position wherein the substring occurs first in the string.
 Live Demo
<?php
   $str_1 = "thisisasample";
   $str_2 = "asample";
   if (strpos($str_1, $str_2) >= 0 && strpos($str_1, $str_2) < strlen($str_1))
      echo("The substring is present within the string.");
   else
      echo("The substring is not present within the string.");
?>
The substring is present within the string.
Two strings are defined and the position of the second string in the first string is checked with the help of the ‘strpos’ function and compared with the length of the first string. Relevant message is displayed on the console.
Adjust gap size for CSS Grid

To adjust the gap size, use grid-column-gap, grid-row-gap or grid-gap property in CSS.
Set gap between Grid columns with CSS. You can try to run the following code to implement the grid-column-gap property.
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         .container {
            display: grid;
            background-color: green;
            grid-template-columns: auto auto;
            padding: 20px;
            grid-column-gap: 20px;
         }
         .ele {
            background-color: orange;
            border: 2px solid gray;
            padding: 35px;
            font-size: 30px;
            text-align: center;
         }
      </style>
   </head>
   <body>
      <h1>Game Board</h1>
      <div class = "container">
         <div class = "ele">1</div>
         <div class = "ele">2</div>
         <div class = "ele">3</div>
         <div class = "ele">4</div>
         <div class = "ele">5</div>
         <div class = "ele">6</div>
      </div>
   </body>
</html>
Set gap between Grid rows with CSS. You can try to run the following code to implement the grid-row-gap property.
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         .container {
            display: grid;
            background-color: green;
            grid-template-columns: auto auto;
            padding: 20px;
            grid-column-gap: 20px;
            grid-row-gap: 20px;
         }
         .ele {
            background-color: orange;
            border: 2px solid gray;
            padding: 35px;
            font-size: 30px;
            text-align: center;
         }
      </style>
   </head>
   <body>
      <h1>Game Board</h1>
      <div class = "container">
         <div class = "ele">1</div>
         <div class = "ele">2</div>
         <div class = "ele">3</div>
         <div class = "ele">4</div>
         <div class = "ele">5</div>
         <div class = "ele">6</div>
      </div>
   </body>
</html>
Set gap between Grid rows and columns with CSS. You can try to run the following code to implement the grid-gap property.
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <style>
         .container {
            display: grid;
            background-color: green;
            grid-template-columns: auto auto;
            padding: 20px;
            grid-gap: 20px 20px;
         }
         .ele {
            background-color: orange;
            border: 2px solid gray;
            padding: 35px;
            font-size: 30px;
            text-align: center;
         }
      </style>
   </head>
   <body>
      <h1>Game Board</h1>
      <div class = "container">
         <div class = "ele">1</div>
         <div class = "ele">2</div>
         <div class = "ele">3</div>
         <div class = "ele">4</div>
         <div class = "ele">5</div>
         <div class = "ele">6</div>
      </div>
   </body>
</html>