code-rag-bench/online-tutorials huggingface dataset:
Create a column using for loop in Pandas Dataframe - GeeksforGeeks

08 Jan, 2019
Let’s see how to create a column in pandas dataframe using for loop. Such operation is needed sometimes when we need to process the data of dataframe created earlier for that purpose, we need this type of computation so we can process the existing data and make a separate column to store the data.
In this type of computation, we need to take care about the value that is in the existing dataframe. We only use those value to add new column in dataframe.
# importing pandasimport pandas as pd  # Creating new dataframeinitial_data = {'First_name': ['Ram', 'Mohan', 'Tina', 'Jeetu', 'Meera'],                 'Last_name': ['Kumar', 'Sharma', 'Ali', 'Gandhi', 'Kumari'],                 'Marks': [12, 52, 36, 85, 23] }  df = pd.DataFrame(initial_data, columns = ['First_name', 'Last_name', 'Marks'])  # Generate result using pandasresult = []for value in df["Marks"]:    if value >= 33:        result.append("Pass")    elif value < 0 and value > 100:        result.append("Invalid")    else:        result.append("Fail")       df["Result"] = result   print(df)
  First_name Last_name  Marks Result
0        Ram     Kumar     12   Fail
1      Mohan    Sharma     52   Pass
2       Tina       Ali     36   Pass
3      Jeetu    Gandhi     85   Pass
4      Meera    Kumari     23   Fail

pandas-dataframe-program
Python pandas-dataFrame
Python-pandas
Technical Scripter 2018
Python
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
Python | Numpy np.assert_approx_equal() method - GeeksforGeeks

30 Jan, 2020
With the help of np.assert_approx_equal() method, we can get the assertion error if two items are not equal up to significant digits by using np.assert_approx_equal() method.
Syntax : np.assert_approx_equal(actual, desired, significant)Return : Return the assertion error if two values are not equal.
Example #1 :In this example we can see that by using np.assert_approx_equal() method, we are able to get the assertion error if two values are not equal up to a significant digit by using this method.
# import numpy and assert_approx_equalimport numpy as npimport numpy.testing as npt  # using np.assert_approx_equal() methodgfg = npt.assert_approx_equal(1.2222222222, 1.2222222222, significant = 5)  print(gfg)
Output :
Nope
Example #2 :
# import numpy and assert_approx_equalimport numpy as npimport numpy.testing as npt  # using np.assert_approx_equal() methodgfg = npt.assert_approx_equal(1.2222222222, 1.23422222, significant = 5)  print(gfg)
Output :
AssertionError:Items are not equal to 5 significant digits:ACTUAL: 1.2222222222DESIRED: 1.23422222
Python numpy-Testing
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Blocks in PL/SQL - GeeksforGeeks

03 Dec, 2018
In PL/SQL, All statements are classified into units that is called Blocks. PL/SQL blocks can include variables, SQL statements, loops, constants, conditional statements and exception handling. Blocks can also build a function or a procedure or a package.
Broadly, PL/SQL blocks are two types: Anonymous blocks and
1. Anonymous blocks: In PL/SQL, That’s blocks which is not have header are known as anonymous blocks. These blocks do not form the body of a function or triggers or procedure.
Example: Here a code example of find greatest number with Anonymous blocks.
DECLARE     -- declare variable a, b and c     -- and these three variables datatype are integer     a number;    b number;    c number; BEGIN    a:= 10;    b:= 100;     --find largest number    --take it in c variable   IF a > b THEN       c:= a;    ELSE       c:= b;    END IF;   dbms_output.put_line(' Maximum number in 10 and 100: ' || c); END; / -- Program End 
Output:
Maximum number in 10 and 100: 100

2. Named blocks: That’s PL/SQL blocks which having header or labels are known as Named blocks. These blocks can either be subprograms like functions, procedures, packages or Triggers.
Example: Here a code example of find greatest number with Named blocks means using function.
DECLARE       -- declare variable a, b and c     -- and these three variables datatype are integer  DECLARE    a number;    b number;    c number;    --Function return largest number of     -- two given numberFUNCTION findMax(x IN number, y IN number)  RETURN number IS     z number; BEGIN    IF x > y THEN       z:= x;    ELSE       Z:= y;    END IF;     RETURN z; END; BEGIN    a:= 10;    b:= 100;     c := findMax(a, b);    dbms_output.put_line(' Maximum number in 10 and 100 is: ' || c); END; / -- Program End 
Output:
Maximum number in 10 and 100: 100

SQL-PL/SQL
Technical Scripter 2018
SQL
Technical Scripter
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?
How to Create a Table With Multiple Foreign Keys in SQL?
What is Temporary Table in SQL?
SQL | Subquery
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
PHP password_verify() Function

The password_verify() function can verify that a password matches a hash. 
boolean password_verify( string $password , string $hash )

The password_verify() function can verify that given hash matches the given password. 
Note that the password_hash() function can return the algorithm, cost, and salt as part of a returned hash. Therefore, all information that needs to verify a hash that includes in it. This can allow the password_verify() function to verify a hash without need separate storage for the salt or algorithm information. 
The password_verify() function can return true, if the password and hash match, or false otherwise. 
<?php
   $passw01 = "53nh46u74m3nt3";
   $hashp02 = '$argon2i$v=19$m=1024,t=2,p=2$d1JJWnNHMkVEekZwcTFUdA$zeSi7c/Adh/1KCTHddoF39Xxwo9ystxRzHEnRA0lQeM';

   $test02 = password_verify($passw01, $hashp02);
   
   if($test02 == true) {
      echo "VALID password for the informed HASH!<br>"; 
      var_dump($test02);
   } else {
      echo "INVALID password for the informed HASH!<br>";     
      var_dump($test02);    
   }
?>
INVALID password for the informed HASH!<br>bool(false)

VALID password for the informed HASH!<br>bool(true)
<br><br>algo = argon2i<br>algoName = argon2i<br>memory_cost = 1024<br>time_cost = 2<br>threds = 2<br><br> 


    45 Lectures 
     9 hours 

 Malhar Lathkar

    34 Lectures 
     4 hours 

 Syed Raza

    84 Lectures 
     5.5 hours 

 Frahaan Hussain

    17 Lectures 
     1 hours 

 Nivedita Jain

    100 Lectures 
     34 hours 

 Azaz Patel

    43 Lectures 
     5.5 hours 

 Vijay Kumar Parvatha Reddy
 Print
 Add Notes
 Bookmark this page
How to edit a Listbox item in Tkinter?

Tkinter Listbox widget is generally used to create a list of items. It can store a list of numbers, characters and support many features like selecting and editing the list items.
To edit the Listbox items, we have to first select the item in a loop using listbox.curselection() function and insert a new item after deleting the previous item in the listbox. To insert a new item in the listbox, you can use listbox.insert(**items) function.
In this example, we will create a list of items in the listbox widget and a button will be used for editing the selected item in the list.
# Import the required libraries
from tkinter import *
from tkinter import ttk

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

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

# Create a Listbox widget
lb = Listbox(win, width=100, height=10, background="purple2", foreground="white", font=('Times 13'), selectbackground="black")

lb.pack()

# Select the list item and delete the item first
# Once the list item is deleted,
# we can insert a new item in the listbox
def edit():
   for item in lb.curselection():
      lb.delete(item)
      lb.insert("end", "foo")

# Add items in the Listbox
lb.insert("end", "item1", "item2", "item3", "item4", "item5")

# Add a Button To Edit and Delete the Listbox Item
ttk.Button(win, text="Edit", command=edit).pack()

win.mainloop()
Running the above code will allow you to select and edit the list items.
You can configure the list of items by clicking the "Edit" button.
How to display value of textbox in JavaScript?

Extract the value from text box using value and can display in paragraph using innerHTML.
Following is the code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Document</title>
</head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<body>
   Enter your Name:
   <input type="text" placeholder="enter your name" id="txtInputData">
   <button onclick="displayName()">Click Me</button>
   <p id="show_name">
   </p>
</body>
<script>
   function displayName() {
      var originalName = document.getElementById("txtInputData").value;
      document.getElementById("show_name").innerHTML = "Your Name is :" + originalName;
   }
</script>
</html>
To run the above program, save the file name “anyName.html(index.html)”. Right click on the file and select the option “Open with Live Server” in VSCode editor −
This will produce the following output on console −
Now, enter the value into the text box and click the button −
After clicking the button, the output is as follows −
Keras - RepeatVector Layers

RepeatVector is used to repeat the input for set number, n of times. For example, if RepeatVector with argument 16 is applied to layer having input shape as (batch_size, 32), then the output shape of the layer will be (batch_size, 16, 32)
RepeatVector has one arguments and it is as follows −
keras.layers.RepeatVector(n)

A simple example to use RepeatVector layers is as follows −
>>> from keras.models import Sequential 
>>> from keras.layers import Activation, Dense, RepeatVector 
>>> 
>>> 
>>> model = Sequential() 
>>> layer_1 = Dense(16, input_shape=(8,)) 
>>> model.add(layer_1) 
>>> layer_2 = RepeatVector(16) 
>>> model.add(layer_2) 
>>> layer_2.input_shape (None, 16) 
>>> layer_2.output_shape
(None, 16, 16)
>>>
where, 16 is set as repeat times.

    87 Lectures 
     11 hours 

 Abhilash Nelson

    61 Lectures 
     9 hours 

 Abhishek And Pukhraj

    57 Lectures 
     7 hours 

 Abhishek And Pukhraj

    52 Lectures 
     7 hours 

 Abhishek And Pukhraj

    52 Lectures 
     6 hours 

 Abhishek And Pukhraj

    68 Lectures 
     2 hours 

 Mike West
 Print
 Add Notes
 Bookmark this page
ReactJS – getDerivedStateFromProps() Method

In this article, we are going to see how to execute a function before the component is rendered.
This method is called before the rendering or before any updation of the component. This method is majorly used to update the state, before the rendering of the component, which depends upon the props received by the component. This method is called on every rerendering of the component.
static getDerivedStateFromProps(props, state)
props − Props passed to component
props − Props passed to component
state − Previous state of component
state − Previous state of component
In this example, we will build a React application which will fetch the list of users and on clicking the 'fetch user' button, the Show component will get placed in the DOM and before rendering this component, getDerivedStateFromProps method is called which updates the state according to the props passed to it.
App.jsx
import React from 'react';

class App extends React.Component {
   constructor() {
      super();
      this.state = {
         show: false,
      };
   }
   render() {
      return (
         <div>
            <h1>User List</h1>
            <h3>Username: Rahul</h3>
            <button onClick={() => this.setState({ show: true })}>
               Fetch Users
            </button>
            {this.state.show ? <Show email="qwerty@gmail.com" /> : null}
         </div>
      );
   }
}
class Show extends React.Component {
   constructor() {
      super();
         this.state = {
            email: '',
         };
   }
   static getDerivedStateFromProps(props, state) {
      console.log('getDerivedStateFromProps method is called');
      return { email: props.email };
   }
   render() {
      return (
         <div>
            <h3>Email: {this.state.email}</h3>
         </div>
      );
   }
}
export default App;
This will produce the following result.
std::greater in C++ with Examples

22 Apr, 2020
The std::greater is a functional object which is used for performing comparisons. It is defined as a Function object class for the greater-than inequality comparison. This can be used for changing the functionality of the given function. This can also be used with various standard algorithms such as sort, priority queue, etc.
Header File:
#include <functional.h>

Template Class:
template <class T> struct greater;

Parameter: T is a type of the arguments to compare by the functional call.
Return Value: It returns boolean variable as shown below:
True: If two element say(a & b) such that a > b.
False: If a < b.
Below is the illustration of std::greater in C++:
Program 1:
// C++ program to illustrate std::greater  #include <algorithm>#include <functional>#include <iostream>using namespace std;  // Function to print array elementsvoid printArray(int arr[], int n){      for (int i = 0; i < n; i++) {        cout << arr[i] << ' ';    }}  // Driver Codeint main(){      int arr[] = { 60, 10, 80, 40, 30,                  20, 50, 90, 70 };    int n = sizeof(arr) / sizeof(arr[0]);      // To sort the array in decreasing order    // use greater <int>() as an third arguments    sort(arr, arr + 9, greater<int>());      // Print array elements    printArray(arr, n);      return 0;}
90 80 70 60 50 40 30 20 10

Program 2:
// C++ program to illustrate std::greater  #include <functional>#include <iostream>#include <queue>using namespace std;  // Function to print elements of priority_queuevoid showpq(priority_queue<int, vector<int>,                           greater<int> >                pq){    priority_queue<int,                   vector<int>,                   greater<int> >        g;    g = pq;      // While priority_queue is not empty    while (!g.empty()) {          // Print the top element        cout << g.top() << ' ';          // Pop the top element        g.pop();    }}  // Driver Codeint main(){    // priority_queue use to implement    // Max Heap, but using function    // greater <int> () it implements    // Min Heap    priority_queue<int, vector<int>,                   greater<int> >        gquiz;      // Inserting Elements    gquiz.push(10);    gquiz.push(30);    gquiz.push(20);    gquiz.push(5);    gquiz.push(1);      // Print elements of priority queue    cout << "The priority queue gquiz is : ";    showpq(gquiz);    return 0;}
The priority queue gquiz is : 1 5 10 20 30

C++
C++ Programs
Write From Home
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Set in C++ Standard Template Library (STL)
Inheritance in C++
unordered_map in C++ STL
vector erase() and clear() in C++
C++ Classes and Objects
Header files in C/C++ and its uses
Sorting a Map by value in C++ STL
Program to print ASCII Value of a character
How to return multiple values from a function in C or C++?
Shallow Copy and Deep Copy in C++
Express.js | app.route() Function

10 Jun, 2020
The app.route() function returns an instance of a single route, which you can then use to handle HTTP verbs with optional middleware. Use app.route() to avoid duplicate route names (and thus typo errors).
Syntax:
app.route( path )
Installation of express module:
You can visit the link to Install express module. You can install this package by using this command.npm install expressAfter installing express module, you can check your express version in command prompt using the command.npm version expressAfter that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command.node index.js
You can visit the link to Install express module. You can install this package by using this command.npm install express
npm install express
After installing express module, you can check your express version in command prompt using the command.npm version express
npm version express
After that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command.node index.js
node index.js
Filename: index.js
var express = require('express');var app = express();var PORT = 3000;  app.route('/user').get((req, res, next) => {    res.send('GET request called');}).post((req, res, next) => {res.send('POST request called');}).all((req, res, next) => {res.send('Other requests called');})  app.listen(PORT, function(err){    if (err) console.log(err);    console.log("Server listening on PORT", PORT);});
Steps to run the program:
The project structure will look like this:Make sure you have installed express module using following command:npm install expressRun index.js file using below command:node index.jsOutput:Server listening on PORT 3000
Now, if me make POST request to /user we get POST request called, similarly if me make GET request to /user we get GET request called and so on.
The project structure will look like this:
Make sure you have installed express module using following command:npm install express
npm install express
Run index.js file using below command:node index.jsOutput:Server listening on PORT 3000

node index.js
Output:
Server listening on PORT 3000

Now, if me make POST request to /user we get POST request called, similarly if me make GET request to /user we get GET request called and so on.
So this is how you can use the express app.route() function which returns an instance of a single route, which you can then use to handle HTTP verbs with optional middleware.
Express.js
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python program to implement Full Adder

09 Jun, 2021
Prerequisite : Full Adder in Digital LogicGiven three inputs of Full Adder A, B,C-IN. The task is to implement the Full Adder circuit and Print output i.e sum and C-Out of three inputs.
Full Adder : A Full Adder is a logical circuit that performs an addition operation on three one-bit binary numbers. The full adder produces a sum of the three inputs and carry value. 
Logical Expression :
SUM  =  C-IN  XOR  ( A XOR B )
C-0UT= A B + B C-IN + A C-IN
Truth Table : 
Examples :
Input : 0 1 1
Output: Sum=0, C-Out=1
According to logical expression Sum= C-IN XOR (A XOR B )  i.e 1 XOR (0 XOR 1) =0 , C-Out= A B + B C-IN + A C-IN  i.e.,  0 AND 1 + 1 AND 1 + 0 AND 1 = 1 
Input : 1 0 0
Output: Sum=1, C-Out=0
Approach :
We take three inputs A ,B and C-in .
Applying C-IN XOR (A XOR B ) gives the value of sum
Applying  A B + B C-IN + A C-IN gives the value of C-Out
Below is the implementation :
Python3
# python program to implement full adder # Function to print sum and C-Outdef getResult(A, B, C):     # Calculating value of sum    Sum = C ^ (A ^ B)    C    # Calculating value of C-Out    C_Out = Bin&(not(A ^ B))| not(A)&B     # printing the values    print("Sum = ", Sum)    print("C-Out = ", C_Out)  # Driver codeA = 0B = 0C = 1# passing three inputs of fulladder as arguments to get result functiongetResult(A, B, C)
Output :
Sum =  1
C-Out =  0
simranarora5sos
Digital Electronics & Logic Design
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
LogManager getLogger() method in Java with Examples

29 Oct, 2019
The getLogger() method of java.util.logging.LogManager is used to get the specified Logger in this LogManager instance. This Logger must be a named Logger. This method will get this Logger in this LogManager if it exists. If it does not exists, then this method returns null.
Syntax:
public Logger getLogger(Logger logger)

Parameters: This method accepts a parameter logger which is the name of the Logger to be get in this LogManager instance.
Return Value: This method returns the name of this Logger in this LogManager if it exists. If it does not exists, then this method returns null.
Below programs illustrate getLogger() method:
// Java program to illustrate// LogManager getLogger() method  import java.util.logging.*;import java.util.*;  public class GFG {      public static void main(String[] args)    {          // Create LogManager object        LogManager logManager            = LogManager.getLogManager();          String LoggerName = "GFG";        Logger logger            = Logger.getLogger(LoggerName);        logManager.addLogger(logger);          System.out.println("\nList of Logger Names: ");        Enumeration<String> listOfNames            = logManager.getLoggerNames();        while (listOfNames.hasMoreElements())            System.out.println(listOfNames.nextElement());          System.out.println(            "\nGet Logger Name "            + LoggerName + ": "            + logManager.getLogger(LoggerName));          LoggerName = "Geeks";          System.out.println(            "\nGet Logger Name "            + LoggerName + ": "            + logManager.getLogger(LoggerName));    }}
List of Logger Names: 
GFG
global


Get Logger Name GFG: java.util.logging.Logger@1540e19d

Get Logger Name Geeks: null

Reference: https://docs.oracle.com/javase/9/docs/api/java/util/logging/LogManager.html#getLogger-java.lang.String-
Java-Functions
Java-LogManager
java.util.logging package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Object Oriented Programming (OOPs) Concept in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
ArrayList in Java
Stream In Java
Collections in Java
Singleton Class in Java
Multidimensional Arrays in Java
Set in Java
jQuery UI Dialog closeOnEscape Option

12 Jan, 2021
closeOnEscape option if set to true and the current dialog box is focused will close the dialog on pressing Escape key(esc). By default, value is true.
Syntax:
$( ".selector" ).dialog({
    closeOnEscape : true
});
Approach: First, add jQuery UI scripts needed for your project.
<link href = “https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css” rel = “stylesheet”><script src = “https://code.jquery.com/jquery-1.10.2.js”></script><script src = “https://code.jquery.com/ui/1.10.4/jquery-ui.js”></script>
Example 1:
HTML
<!doctype html><html lang="en">  <head>    <meta charset="utf-8">    <link href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css"        rel="stylesheet">    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>    <script src=        "https://code.jquery.com/ui/1.10.4/jquery-ui.js">    </script>      <script>        $(function () {            $("#gfg").dialog({                closeOnEscape: true,            });            $("#geeks").click(function () {                $("#gfg").dialog("open");            });        });    </script></head>  <body>    <div id="gfg" title="GeeksforGeeks">        Jquery UI| closeOnEscape dialog option    </div>          <button id="geeks">Open Dialog</button></body>  </html>
Output:
Example 2:
HTML
<!doctype html><html lang="en">  <head>    <meta charset="utf-8">    <link href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css"        rel="stylesheet">    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>    <script src=        "https://code.jquery.com/ui/1.10.4/jquery-ui.js">    </script>      <script>        $(function () {            $("#gfg").dialog({                closeOnEscape: false,            });            $("#geeks").click(function () {                $("#gfg").dialog("open");            });        });    </script></head>  <body>    <div id="gfg" title="GeeksforGeeks">        Jquery UI| closeOnEscape dialog option    </div>          <button id="geeks">Open Dialog</button></body>  </html>
Output:
jQuery-UI
HTML
JQuery
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
REST API (Introduction)
Hide or show elements in HTML using display property
JQuery | Set the value of an input text field
How to change selected value of a drop-down list using jQuery?
Form validation using jQuery
How to add options to a select element using jQuery?
jQuery | children() with Examples
Javascript Short circuiting operators

10 Feb, 2022
Below is the example of the Short circuiting operators.
Example:<script>     function gfg() {           // AND short circuit         document.write(false && true)          document.write("</br>");         document.write(true && true)          document.write("</br>");          // OR short circuit         document.write(true || false)          document.write("</br>");         document.write(false || true)     }     gfg(); </script>
<script>     function gfg() {           // AND short circuit         document.write(false && true)          document.write("</br>");         document.write(true && true)          document.write("</br>");          // OR short circuit         document.write(true || false)          document.write("</br>");         document.write(false || true)     }     gfg(); </script>
Output:false
true
true
true

false
true
true
true

In JavaScript short-circuiting, an expression is evaluated from left to right until it is confirmed that the result of the remaining conditions is not going to affect the already evaluated result. If the result is clear even before the complete evaluation of the expression, it short circuits and the result will be returned. Short circuit evaluation avoids unnecessary work and leads to efficient processing.
AND(&&) short circuit: In case of AND, the expression is evaluated until we get one false result because the result will always be false, independent of the further conditions. If there is an expression with &&(logical AND), and the first operand itself is false, then a short circuit occurs, the further expression is not evaluated and false is returned.
Example: Short circuiting using AND(&&) operator.
<script>  // Since first operand is false and operator// is AND, Evaluation stops and false is// returned.console.log(false && true && true && false)  // Whole expression will be evaluated.console.log(true && true && true)</script>
Output:
false
true

OR(||) short circuit: In case of OR, the expression is evaluated until we get one true result because the result will always be true, independent of the further conditions. If there is an expression with ||(logical OR), and the first operand itself is true, then a short circuit occurs, evaluation stops, and true is returned.
Example: Short circuiting using OR(||).
<script>  // First operand is true and operator is ||, // evaluation stops and true is returned.console.log(true || false || false)  // Evaluation stops at the second operand(true).console.log(false || true || true || false)</script>
Output:
true
true

JavaScript-Misc
javascript-operators
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
jQuery | focusout() with Example

12 Feb, 2019
The focusout() is an inbuilt method in jQuery which is used to remove focus from the selected element.Syntax:
$(selector).focusout(function);

Parameter: It accepts a parameter “function” which is to be executed after execution of fadeout method.Return Value: It returns the selected element which loses its focus.jQuery code to show the working of focusout() method:
<html>  <head>    <script     src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>    <!-- jQuery code to show the working of this method -->    <script>        $(document).ready(function() {            $("div").focusin(function() {                $(this).css("background-color", "green");            });            $("div").focusout(function() {                $(this).css("background-color", "#FFFFFF");            });        });    </script>    <style>        div {            border: 2px solid black;            width: 50%;            padding: 20px;        }                  input {            padding: 5px;            margin: 10px;        }    </style></head>  <body>    <!-- click inside the field focusin will take place and when                       click outside focusout will take place -->    <div>        Enter name:        <input type="text">        <br>    </div>  </body>  </html>
Output:After clicking inside of the input field focusin will be in action-
After clicking outside of the input field focusout will be in action.
jQuery-Events
JavaScript
JQuery
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
How to Open URL in New Tab using JavaScript ?
Form validation using jQuery
How to change selected value of a drop-down list using jQuery?
How to add options to a select element using jQuery?
jQuery | children() with Examples
Scroll to the top of the page using JavaScript/jQuery
Python math function | hypot()

28 Aug, 2020
hypot() function is an inbuilt math function in Python that return the Euclidean norm, .
Syntax :
hypot(x, y) 
Parameters :
x and y are numerical values 
Returns :
Returns a float value having Euclidean norm, sqrt(x*x + y*y). 
Error :
When more then two arguments are 
passed, it returns a TypeError.
Note : One has to import math module before using hypot() function. Below is the demonstration of hypot() function :
Code #1 :
# Python3 program for hypot() function   # Import the math moduleimport math  # Use of hypot functionprint("hypot(3, 4) : ", math.hypot(3, 4))  # Neglects the negative signprint("hypot(-3, 4) : ", math.hypot(-3, 4))  print("hypot(6, 6) : ", math.hypot(6, 6))
Output :
hypot(3, 4) :  5.0
hypot(-3, 4) :  5.0
hypot(6, 6) :  8.48528137423857

 Code #2 :
# Python3 program for error in hypot() function   # import the math moduleimport math  # Use of hypot() functionprint("hypot(3, 4, 6) : ",  math.hypot(3, 4, 6))
Output :
Traceback (most recent call last):
  File "/home/d8c8612ee97dd2c763e2836de644fac1.py", line 7, in 
    print("hypot(3, 4, 6) : ",  math.hypot(3, 4, 6))
TypeError: hypot expected 2 arguments, got 3

 Practical Application :Given perpendicular and base of a right angle triangle find the hypotenuse.
Using Pythagorean theorem which states that the square of the hypotenuse (the side opposite the right angle) is equal to the sum of the squares of the other two sides.
Hence,
 Hypotenuse = sqrt(p^2 + b^2) 
Code #3 :
# Python3 program for finding Hypotenuse# in hypot() function   # import the math modulefrom math import hypot  # Perpendicular and basep = 3b = 4  # Calculates the hypotenuseprint("Hypotenuse is:", hypot(p, b))
Output :
Hypotenuse is: 5.0

Akanksha_Rai
Python-Built-in-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Generate a matrix product of two NumPy arrays - GeeksforGeeks

29 Aug, 2020
We can multiply two matrices with the function np.matmul(a,b). When we multiply two arrays of order (m*n) and  (p*q ) in order to obtained matrix product then its output contains m rows and q columns where n is n==p is a necessary condition.
Syntax: numpy.matmul(x1, x2, /, out=None, *, casting=’same_kind’, order=’K’, dtype=None, subok=True[, signature, extobj]) 
To multiply two matrices take the row from first array and column of second array and multiply the corresponding elements. Then add the value for the final answer. Suppose there are two matrices A and B.
A = [[A00, A01],
     [A10, A11]]
     
B = [[B00, B01],
     [B10, B11]]

Then the product is calculated as shown below
A*B = [[(A00*B00 + A01*B10), (A00*B01 + A01*B11)],
       [(A10*B00 + A11+B10), (A10*B01 + A11*B11)]]

Below is the implementation.
Python3
# Importing Libraryimport numpy as np  # Finding the matrix productarr1 = np.array([[1, 2, 3], [4, 5, 6],                 [7, 8, 9]])arr2 = np.array([[11, 12, 13], [14, 15, 16],                 [17, 18, 19]])  matrix_product = np.matmul(arr1, arr2)print("Matrix Product is ")print(matrix_product)print()  arr1 = np.array([[2,2],[3,3]])arr2 = np.array([[1,2,3],[4,5,6]])  matrix_product = np.matmul(arr1, arr2)print("Matrix Product is ")print(matrix_product)print()  arr1 = np.array([[100,200],[300,400]])arr2 = np.array([[1,2],[4,6]])  matrix_product = np.matmul(arr1, arr2)print("Matrix Product is ")print(matrix_product)
Output:
Matrix Product is 
[[ 90  96 102]
 [216 231 246]
 [342 366 390]]

Matrix Product is 
[[10 14 18]
 [15 21 27]]

Matrix Product is 
[[ 900 1400]
 [1900 3000]]

Python numpy-Matrix Function
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
Selecting rows in pandas DataFrame based on conditions
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python Classes and Objects
How to pass arguments in Invoke-Command in PowerShell?

To pass the argument in the Invoke-command, you need to use -ArgumentList parameter. For example, we need to get the notepad process information on the remote server.
Invoke-Command -ComputerName Test1-Win2k12 -
ScriptBlock{param($proc) Get-Process -Name $proc} -
ArgumentList "Notepad"
Handles NPM(K) PM(K) WS(K) CPU(s)  Id SI ProcessName PSComputerName
------- ------ ----- ----- ------  -- -- ----------- --------------
  67      8  1348  7488   0.08 104    notepad     Test1-Win2k12
In the above example, we are passing "Notepad" name as the argument to the command and the same has been caught by the $proc variable inside Param().
If you have the multiple, check the below command to pass the multiple parameters.
Invoke-Command -ComputerName Test1-Win2k12 -ScriptBlock{param($proc,$proc2) Get-Process -Name $proc,$proc2} -ArgumentList "Notepad","Calc"
Handles NPM(K) PM(K) WS(K) CPU(s)  Id SI ProcessName PSComputerName
------- ------ ----- ----- ------  -- -- ----------- --------------
  96     20  5980 11392   0.19 288    calc        Test1-Win2k12
  67      8  1344  7556   0.08 104    notepad     Test1-Win2k12
Same can be achieved with the Session variable.
$sess = New-PSSession -ComputerName Test1-win2k12
Invoke-Command -Session $sess -ScriptBlock{param($proc) Get-Process $proc} -ArgumentList "Notepad"
Handles NPM(K) PM(K) WS(K) CPU(s)  Id SI ProcessName PSComputerName
------- ------ ----- ----- ------  -- -- ----------- --------------
  67      8  1348  7488   0.08 104    notepad     Test1-Win2k12
Find a value in lowercase from a MongoDB collection with documents

To find a value in lowercase, use the toLowerCase() method in MongoDB. Use the method in find() to find the value in lowercase.
Let us create a collection with documents −
> db.demo172.insertOne({"SubjectName":"MySQL"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e3838ce9e4f06af551997e1")
}
> db.demo172.insertOne({"SubjectName":"mongodb"});
{
    "acknowledged" : true,
   "insertedId" : ObjectId("5e3838d69e4f06af551997e2")
}
> db.demo172.insertOne({"SubjectName":"MongoDB"});
{
   "acknowledged" : true,
   "insertedId" : ObjectId("5e3838db9e4f06af551997e3")
}
Display all documents from a collection with the help of find() method −
> db.demo172.find();
This will produce the following output −
{ "_id" : ObjectId("5e3838ce9e4f06af551997e1"), "SubjectName" : "MySQL" }
{ "_id" : ObjectId("5e3838d69e4f06af551997e2"), "SubjectName" : "mongodb" }
{ "_id" : ObjectId("5e3838db9e4f06af551997e3"), "SubjectName" : "MongoDB" }
Following is the query to find a value in lowercase −
> db.demo172.find({"SubjectName":"MONGODB".toLowerCase()});
This will produce the following output −
{ "_id" : ObjectId("5e3838d69e4f06af551997e2"), "SubjectName" : "mongodb" }
Tryit Editor v3.7

Tryit basic HTML image
GATE | GATE-CS-2015 (Set 2) | Question 65 - GeeksforGeeks

28 Jun, 2021
Consider two relations R1(A, B) with the tuples (1, 5), (3, 7) and R1(A, C) = (1, 7), (4, 9). Assume that R(A,B,C) is the full natural outer join of R1 and R2. Consider the following tuples of the form (A,B,C)
  a = (1, 5, null),
  b = (1, null, 7), 
  c = (3, null, 9), 
  d = (4, 7, null), 
  e = (1, 5, 7), 
  f = (3, 7, null), 
  g = (4, null, 9). 
Which one of the following statements is correct?(A) R contains a, b, e, f, g but not c, d(B) R contains a, b, c, d, e, f, g(C) R contains e, f, g but not a, b(D) R contains e but not f, gAnswer: (C)Explanation:
Below is R1 
  A   |   B
 -----------
  1   |   5
  3   |   7


Below is R2
  A   |   C
 -----------
  1   |   7
  4   |   9 


Full outer join of above two is 

  A   |   B   |   C
 -------------------
  1   |   5   |   7
  3   |   7   |  NULL
  4   |  NULL |   9
So the full outer join contains e = (1, 5, 7), f = (3, 7, null), g = (4, null, 9).Quiz of this Question
GATE-CS-2015 (Set 2)
GATE-GATE-CS-2015 (Set 2)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
GATE | GATE CS 1997 | Question 25
GATE | GATE CS 2012 | Question 54
GATE | GATE-CS-2014-(Set-1) | Question 65
GATE | GATE CS 2019 | Question 50
GATE | GATE CS 2008 | Question 69
GATE | GATE CS 2018 | Question 45
GATE | GATE CS 2020 | Question 16
GATE | GATE CS 2011 | Question 65
GATE | GATE CS 2011 | Question 43
GATE | GATE CS 2010 | Question 33
How to create a Calendar with CSS?

To create a calendar with CSS, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   * {
      box-sizing: border-box;
   }
   .calender {
      border: 1px solid darkorchid;
   }
   .month {
      padding: 50px;
      width: 100%;
      background: #874de6;
      text-align: center;
      border: 1px solid rgba(139, 0, 139, 0.671);
   }
   .month ul {
      margin: 0;
      padding: 0;
      list-style-type: none;
   }
   .month ul li {
      font-size: 30px;
      text-transform: uppercase;
      letter-spacing: 6px;
      color: yellow;
   }
   .month .lastMonth {
      float: left;
      padding-top: 10px;
   }
   .month .nextMonth {
      float: right;
      padding-top: 10px;
   }
   .Days {
      margin: 0;
      padding: 10px 0;
      background-color: rgb(169, 210, 248);
      border: 1px solid rgba(0, 0, 139, 0.514);
   }
   .Days li {
      font-weight: bold;
      display: inline-block;
      width: 13.6%;
      color: rgb(0, 0, 0);
      text-align: center;
   }
   .daysNumber {
      padding: 10px 0;
      background: rgb(235, 255, 182);
      margin: 0;
      font-weight: bold;
   }
   .daysNumber li {
      list-style-type: none;
      display: inline-block;
      width: 13.6%;
      text-align: center;
      margin-bottom: 5px;
      font-size: 12px;
      color: rgb(0, 0, 0);
   }
   .daysNumber li .today {
      padding: 5px;
      background: #17003b;
      font-weight: bolder;
      border-radius: 50%;
      color: rgb(229, 255, 0) !important;
   }
</style>
</head>
<body>
<h1 style="text-align: center;">CSS Calendar Example</h1>
<div class="calender">
<div class="month">
<ul>
<li class="lastMonth">❮</li>
<li class="nextMonth">❯</li>
<li>
March<br />
<span>2020</span>
</li>
</ul>
</div>
<ul class="Days">
<li>Mo</li>
<li>Tu</li>
<li>We</li>
<li>Th</li>
<li>Fr</li>
<li>Sa</li>
<li>Su</li>
</ul>
<ul class="daysNumber">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
<li>10</li>
<li>11</li>
<li>12</li>
<li>13</li>
<li>14</li>
<li>15</li>
<li>16</li>
<li>17</li>
<li>18</li>
<li>19</li>
<li>20</li>
<li>21</li>
<li><span class="today">22</span></li>
<li>23</li>
<li>24</li>
<li>25</li>
<li>26</li>
<li>27</li>
<li>28</li>
<li>29</li>
<li>30</li>
<li>31</li>
</ul>
</div>
</body>
</html>
The above code will produce the following output −
HTML DOM Style display Property

The HTML DOM Style display property is used for setting or returning the display type of an element. Elements are mostly block or inline. You can also hide the element using display:none.
Following is the syntax for −
Setting the display property −
object.style.display = value
The above property value is explained as follows −
Let us look at an example for the display property −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<style>
   #DIV1{
      padding:10px;
      background-color:lightblue;
      display:flex;
      flex-direction:right;
   }
   #flexSpan{
      width:70px;
      background-color:red;
      margin:20px;
      padding:10px;
   }
</style>
<script>
   function changeDisplay() {
      document.getElementById("DIV1").style.display = "block";
      document.getElementById("flexSpan").style.display = "block";
      document.getElementById("Sample").innerHTML="The display is now changed to block for both the    div and its inner Span elements";
   }
</script>
</head>
<body>
   <div id="DIV1">
      <span id="flexSpan">WORLD1</span>
      <span id="flexSpan">WORLD2</span>
   </div>
   <p>Change the display property of the above div and its inner elements by clicking the below    button</p>
   <button onclick="changeDisplay()">Change Display</button>
   <p id="Sample"></p>
</body>
</html>
On clicking the “Change Display” −
How to use lastIndexOf () in Android textview?

This example demonstrate about How to use lastIndexOf () in Android textview.
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   android:orientation="vertical"
   android:gravity="center"
   tools:context=".MainActivity">
   <EditText
      android:id="@+id/name"
      android:layout_width="match_parent"
      android:hint="Enter name"
      android:layout_height="wrap_content" />
   <Button
      android:id="@+id/click"
      android:text="Click"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" />
   <TextView
      android:id="@+id/textview"
      android:layout_width="wrap_content"
      android:textSize="25sp"
      android:layout_height="wrap_content" />
</LinearLayout>
In the above code, we have taken name as Edit text, when user click on button it will take data and returns last index of “sai”.
Step 3 − Add the following code to src/MainActivity.java
package com.example.myapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
   EditText name;
   Button button;
   TextView text;

   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      name = findViewById(R.id.name);
      button = findViewById(R.id.click);
      text = findViewById(R.id.textview);
      button.setOnClickListener(new View.OnClickListener() {
         @Override
         public void onClick(View v) {
            if (!name.getText().toString().isEmpty()) {
               if (name.getText().toString().length() >= 0) {
                  int index = name.getText().toString().lastIndexOf("sai");
                  text.setText(String.valueOf(index));
               }
            } else {
               name.setError("Plz enter name");
            }
         }
      });
   }
}
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run  icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
In the above result, enter the string as “Krishna sai sai” and it returned last index of sai as 12.
Click here to download the project code
24-hour time in Python

Suppose we have a string s. Here s is representing a 12-hour clock time with suffixes am or pm, we have to find its 24-hour equivalent.
So, if the input is like "08:40pm", then the output will be "20:40"
To solve this, we will follow these steps −
hour := (convert the substring of s [from index 0 to 2] as integer) mod 12
hour := (convert the substring of s [from index 0 to 2] as integer) mod 12
minutes := convert the substring of s [from index 3 to 5] as integer
minutes := convert the substring of s [from index 3 to 5] as integer
if s[5] is same as 'p', thenhour := hour + 12
if s[5] is same as 'p', then
hour := hour + 12
hour := hour + 12
return the result as hour:minutes
return the result as hour:minutes
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, s):
      hour = int(s[:2]) % 12
      minutes = int(s[3:5])
      if s[5] == 'p':
         hour += 12
      return "{:02}:{:02}".format(hour, minutes)
ob = Solution()
print(ob.solve("08:40pm"))
"08:40pm"
20:40