code-rag-bench/online-tutorials huggingface dataset:
JavaScript example to filter an array depending on multiple checkbox conditions.

Following is the code to filter an array depending on multiple checkbox condition using
JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result,.sample {
      font-size: 18px;
      font-weight: 500;
      color: rebeccapurple;
   }
   .result {
      color: red;
   }
</style>
</head>
<body>
<h1>Filter an array depending on multiple checkbox conditions</h1>
<div class="sample">[22,10,50,30,90,33,80,75,33,99,150,105]</div>
<div class="result"></div>
<br />
<input type="checkbox" class="check" onclick="filterArr()" />Number should be greater than 50<br />
<input type="checkbox" class="check" onclick="filterArr()" />Number should divide by 5<br />
<input type="checkbox" class="check" onclick="filterArr()" />Number should divide by 3<br />
<h3>tick the above checkbox to apply filter to the array above</h3>
<script>
   let resEle = document.querySelector(".result");
   let checkEle = document.querySelectorAll(".check");
   let arr = [22, 10, 50, 30, 90, 33, 80, 75, 33, 99, 150, 105];
   let resArr = arr;
   function filterArr() {
      checkEle.forEach((item, index) => {
         if (item.checked && index == 0) {
            resArr = resArr.filter((num) => num > 50);
            resEle.innerHTML = resArr;
         }
         else if (item.checked && index == 1) {
            resArr = resArr.filter((num) => num % 5 == 0);
            resEle.innerHTML = resArr;
         }
         else if (item.checked && index == 2)
         resArr = resArr.filter((num) => num % 3 == 0);
         resEle.innerHTML = resArr;
      });
   }
</script>
</body>
</html>
The above code will produce the following output −
On ticking some of the checkbox −
isalpha() and isdigit() in C/C++

The function isalpha() is used to check that a character is an alphabet or not. This function is declared in “ctype.h” header file. It returns an integer value, if the argument is an alphabet otherwise, it returns zero.
Here is the syntax of isalpha() in C language,
int isalpha(int value);
Here,
value − This is a single argument of integer type.
Here is an example of isalpha() in C language −
 Live Demo
#include<stdio.h>
#include<ctype.h>

int main() {
   char val1 = 's';
   char val2 = '8';

   if(isalpha(val1))
   printf("The character is an alphabet\n");
   else
   printf("The character is not an alphabet\n");

   if(isalpha(val2))
   printf("The character is an alphabet\n");
   else
   printf("The character is not an alphabet");

   return 0;
}
Here is the output
The character is an alphabet
The character is not an alphabet
The function isdigit() is used to check that character is a numeric character or not. This function is declared in “ctype.h” header file. It returns an integer value, if the argument is a digit otherwise, it returns zero.
Here is the syntax of isdigit() in C language,
int isdigit(int value);
Here,
value − This is a single argument of integer type.
Here is an example of isdigit() in C language,
 Live Demo
#include<stdio.h>
#include<ctype.h>

int main() {
   char val1 = 's';
   char val2 = '8';

   if(isdigit(val1))
   printf("The character is a digit\n");
   else
   printf("The character is not a digit\n");

   if(isdigit(val2))
   printf("The character is a digit\n");
   else
   printf("The character is not a digit");

   return 0;
}
Here is the output
The character is not a digit
The character is a digit
java variable declaration

A variable provides us with named storage that our programs can manipulate. Each variable in Java has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable.
You must declare all variables before they can be used. Following is the basic form of a variable declaration -
data type variable [ = value][, variable [ = value] ...] ;
Here data type is one of Java's data types and the variable is the name of the variable. To declare more than one variable of the specified type, you can use a comma-separated list.
Following are valid examples of variable declaration and initialization in Java -
int a, b, c;         // Declares three ints, a, b, and c.
int a = 10, b = 10;  // Example of initialization
byte B = 22;         // initializes a byte type variable B.
double pi = 3.14159; // declares and assigns a value of PI.
char a = 'a';        // the char variable a iis initialized with value 'a'
HTML | aria-label attribute

27 Sep, 2019
The aria-label helps define a string and provides additional information about the structure of the document for users using assistive technology. In most cases, arial-label is used to replace an existing label with more precise information. However, we should be careful while using aria-label as it does not work with all HTML elements.
The aria-label attribute can be used with HTML elements such as:
select
textarea
button
a(when href=”#” is in use)
audio and video(when control=”#” is in use)
The aria-label attribute does not always work with HTML elements like span, p, div. It may work across some of the browse assistive technology combinations.
Syntax:
<button aria-label="open" onclick="function()">CLICK</button>
Here, a button will be created with “click” written on it. The aria-label – Provides a label that exact mentions its output/function by using assistive technologies.
Example:
<!DOCTYPE html><html>  <head></head>  <body>    <center>        <h1 style="color:green">GeeksforGeeks</h1>        <button value="open">open</button>          <button aria-label="opens a new window"                 value="open"> open </button>    </center></body>  </html>
Here, as you can see an HTML page will open and will contain buttons side by side that are identical to each other without any difference. Now if someone is using a chromevox extension in chrome and have their earphone on while pressing tab, then they will hear the word “open” when the first button is selected, whereas when the second button is selected they will hear the phrase “opens a new window”. This is particularly useful in cases of people with bad eyesight who can see the two buttons but can’t comprehend the text written on them.
Output:Before clicking the button:
After:
HTML-Attributes
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Design a Tribute Page using HTML & CSS
Build a Survey Form using HTML and CSS
Design a web page using HTML and CSS
Angular File Upload
Installation of Node.js on Linux
Difference between var, let and const keywords in JavaScript
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Lodash _.compact() Function

10 Nov, 2021
Lodash proves to be much useful when working with arrays, strings, objects etc. It makes math operations and function paradigm much easier, concise. The _.compact() function is used to creates an array with all falsey values removed in JavaScript.
Syntax:
_.compact(array)
Parameters: This function accepts only a single parameter as mentioned above and described below:
array: It is an array to be compacted.
Note: The values false, null, 0, “”, undefined, and NaN are falsey.
Return Value: This function returns the array after filtering the values.
Few examples are given below for a better understanding of the function.
Example 1: Passing a list of both the true and the false elements to _.compact() function.
javascript
// Requiring the lodash librarylet lodash = require("lodash");   // Original array to be compactedlet array = [0, 1, false, 2, '', 3];   let newArray = lodash.compact(array);console.log("Before compact: " + array);   // Printing newArray console.log("After compact: " + newArray);
Output:
Example 2: Passing a list containing all the false values to the _.compact() function.
javascript
// Requiring the lodash librarylet lodash = require("lodash");   // Original array to be compactedlet array = [0, false, '', undefined, NaN];   let newArray = lodash.compact(array);console.log("Before compact: " + array);   // Printing newArray console.log("After compact: " + newArray);
Output:
Example 3: Passing a list which contains a false element in ” to _.compact() function.
javascript
// Requiring the lodash librarylet lodash = require("lodash");   // Original array to be compactedlet array = [false, 'HTML', NaN,                       'CSS', 'undefined'];   let newArray = lodash.compact(array);console.log("Before compact: " + array);   // Printing newArray console.log("After compact: " + newArray);
Output:
Example 4: Passing a list containing modified false values to the _.reduce() function.
javascript
// Requiring the lodash librarylet lodash = require("lodash");   // Original array to be compactedlet array = [false, true, 'yes', 'no', "no2"];   let newArray = lodash.compact(array);console.log("Before compact: " + array);   // Printing newArray console.log("After compact: " + newArray);
Output:
surindertarika1234
JavaScript-Lodash
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
vector capacity() function in C++ STL

09 Jun, 2022
The vector::capacity() function is a built-in function which returns the size of the storage space currently allocated for the vector, expressed in terms of elements. This capacity is not necessarily equal to the vector size. It can be equal to or greater, with the extra space allowing to accommodate for growth without the need to reallocate on each insertion. The capacity does not suppose a limit on the size of the vector. When this capacity is exhausted and more is needed, it is automatically expanded by the container (reallocating it storage space). The theoretical limit on the size of a vector is given by member max_size. Syntax: 
vector_name.capacity()
Parameters: The function does not accept any parameters. Return Value: The function returns the size of the storage space currently allocated for the vector, expressed in terms of elements. 
Time Complexity – Constant O(1)
Below programs illustrate the above functions: Program 1: 
CPP
// C++ program to illustrate the// vector::capacity() function#include <bits/stdc++.h>using namespace std; int main(){    vector<int> v;     // inserts elements    for (int i = 0; i < 10; i++) {        v.push_back(i * 10);    }     cout << "The size of vector is " << v.size();    cout << "\nThe maximum capacity is " << v.capacity();    return 0;}
The size of vector is 10
The maximum capacity is 16
Program 2: 
CPP
// C++ program to illustrate the// vector::capacity() function#include <bits/stdc++.h>using namespace std; int main(){    vector<int> v;     // inserts elements    for (int i = 0; i < 100; i++) {        v.push_back(i * 10);    }     cout << "The size of vector is " << v.size();    cout << "\nThe maximum capacity is " << v.capacity();    return 0;}
The size of vector is 100
The maximum capacity is 128
utkarshgupta110092
CPP-Functions
cpp-vector
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C++ Classes and Objects
Writing First C++ Program - Hello World Example
Functions that cannot be overloaded in C++
Basic Input / Output in C++
C++ Data Types
unordered_map in C++ STL
vector erase() and clear() in C++
Polymorphism in C++
Switch Statement in C/C++
Set in C++ Standard Template Library (STL)
random.weibullvariate() function in Python

26 May, 2020
random module is used to generate random numbers in Python. Not actually random, rather this is used to generate pseudo-random numbers. That implies that these randomly generated numbers can be determined.
weibullvariate() is an inbuilt method of the random module. It is used to return a random floating point number with Weibull distribution.
Syntax : random.weibullvariate(alpha, beta)
Parameters :alpha : scale parameterbeta : shape parameter
Returns : a random Weibull distribution floating number
Example 1:
# import the random moduleimport random  # determining the values of the parametersalpha = 1beta = 1.5  # using the weibullvariate() methodprint(random.weibullvariate(alpha, beta))
Output :
0.7231214446591137
Example 2: We can generate the number multiple times and plot a graph to observe the Weibull distribution.
# import the required libraries import random import matplotlib.pyplot as plt     # store the random numbers in a  # list nums = [] alpha = 1beta = 1.5    for i in range(100):     temp = random.weibullvariate(alpha, beta)    nums.append(temp)         # plotting a graph plt.plot(nums) plt.show()
Output :Example 3: We can create a histogram to observe the density of the Weibull distribution.
# import the required libraries import random import matplotlib.pyplot as plt     # store the random numbers in a list nums = [] alpha = 1beta = 1.5    for i in range(10000):     temp = random.weibullvariate(alpha, beta)     nums.append(temp)         # plotting a graph plt.hist(nums, bins = 200) plt.show()
Output :
Python-random
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Python map() function
Adding new column to existing DataFrame in Pandas
Python Dictionary
How to get column names in Pandas dataframe
Different ways to create Pandas Dataframe
Taking input in Python
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
Java Character charCount() with Examples

06 Dec, 2018
The java.lang.Character.charCount() is an inbuilt function in java which is used to determine number of characters needed to represent the specified character. If the character is equal to or greater than 0x10000, the method returns 2 otherwise 1.
Syntax:
public static int charCount(int code)

Parameters: The function accepts a single parameter code. It represents the tested character.
Return Value: It returns 2 if the character is valid otherwise 1.
Errors and Exceptions:
This method doesn’t validate the specified character to be a valid Unicode code point.
Non-static method is can be called by declaring method_name(argv) in this such case method is static, it should be called by adding the class name as the suffix. We will be get a compilation problem if we call charCount method non-statically.
Examples:
Input : 0x12456
Output : 2
Explanation: the code is greater than 0x10000

Input : 0x9456
Output : 1
Explanation: The code is smaller then 0x10000

Below Programs illustrates the java.lang.Character.charCount() function:Program 1:
// Java program that demonstrates the use of// Character.charCount() function  // include lang packageimport java.lang.*;  class GFG {    public static void main(String[] args)    {        int code = 0x9000;          int ans = Character.charCount(code);          // prints 2 if character is greater than 0x10000        // otherwise 1        System.out.println(ans);    }}
1

Program 2:
// Java program that demonstrates the use of// Character.charCount() function  // include lang packageimport java.lang.*;  class GFG {    public static void main(String[] args)    {        int code = 0x12456;          int ans = Character.charCount(code);          // prints 2 if character is greater than 0x10000        // otherwise 1        System.out.println(ans);    }}
2

Java-Character
Java-Functions
Java-lang package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Stream In Java
Introduction to Java
Constructors in Java
Exceptions in Java
Generics in Java
Functional Interfaces in Java
Java Programming Examples
Strings in Java
Differences between JDK, JRE and JVM
Abstraction in Java
Scala Char toString() method with example

29 Oct, 2019
The toString() method is utilized to convert a stated character into String.
Method Definition: def toString: String
Return Type: It returns the String representation of the stated character.
Example: 1#
// Scala program of toString()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Applying toString method        val result = 'B'.toString                  // Displays output        println(result)          }} 
B

Example: 2#
// Scala program of toString()// method  // Creating objectobject GfG{       // Main method    def main(args:Array[String])    {              // Applying toString method        val result = 'b'.toString                  // Displays output        println(result)              }} 
b

Scala
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in Scala
How to Install Scala with VSCode?
Hello World in Scala
Scala | Traits
Scala | Option
Scala ListBuffer
Scala | Functions - Basics
Introduction to Scala
Scala Sequence
Scala | Case Class and Case Object
Python | Pandas Series.agg()

19 Nov, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas Series.agg() is used to pass a function or list of function to be applied on a series or even each element of series separately. In case of list of function, multiple results are returned by agg() method.
Syntax: Series.agg(func, axis=0)
Parameters:func: Function, list of function or string of function name to be called on Series.axis:0 or ‘index’ for row wise operation and 1 or ‘columns’ for column wise operation.
Return Type: The return type depends on return type of function passed as parameter.
Example #1:In this example, a lambda function is passed which simply adds 2 to each value of series. Since the function will be applied to each value of series, the return type is also series. A random series of 10 elements is generated by passing array generated using Numpy random method.
# importing pandas moduleimport pandas as pd   # importing numpy moduleimport numpy as np   # creating random arr of 10 elementsarr=np.random.randn(10)   # creating series from arrayseries=pd.Series(arr)   # calling .agg() methodresult=series.agg(lambda num : num + 2)    # displayprint('Array before operation: \n', series,      '\n\nArray after operation: \n',result)
Output:As shown in output, the function was applied to each value and 2 was added to each value of series.
 Example #2: Passing List of functions
In this example, a list of some Python’s default function is passed and multiple results are returned by agg() method into multiple variables.
# importing pandas moduleimport pandas as pd   # importing numpy moduleimport numpy as np   # creating random arr of 10 elementsarr=np.random.randn(10)   # creating series from arrayseries=pd.Series(arr)   # creating list of function namesfunc_list=[min, max, sorted]   # calling .agg() method# passing list of functionsresult1, result2, result3= series.agg(func_list)    # displayprint('Series before operation: \n', series)print('\nMin = {}\n\nMax = {},\      \n\nSorted Series:\n{}'.format(result1,result2,result3))
Output:As shown in output, multiple results were returned. Min, Max and Sorted array were returned into different variables result1, result2, result3 respectively.
Python pandas-series
Python pandas-series-methods
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to pass variables to the next middleware using next() in Express.js ? - GeeksforGeeks

17 Feb, 2021
The following example covers how to pass variables to the next middleware using next() in Express.js.
Approach:
We cannot directly pass data to the next middleware, but we can send data through the request object.
[Middleware 1] [Middleware 2]request.mydata = someData; ——-> let dataFromMiddleware1 = request.mydata;
Installation of Express module:
You can visit the link Install express module. You can install this package by using this command.
npm install 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
Filename: index.js
Javascript
// Requiring moduleconst express = require("express");const app = express();  function middleware1(req, res, next) {  // Set data  req.dataFromMiddleware1 = "Data of Middleware 1";    // Go to next middleware  next();}  function middleware2(req, res, next) {  console.log("We are in Middleware 2.");    // Get Data of Middleware1  console.log(req.dataFromMiddleware1);    // Go to next middleware  next();}  // Handling Get Request '/'app.get("/", middleware1, middleware2, (req, res) => {  return res.send(req.dataFromMiddleware1);});  // Server Setupapp.listen(5000, () => {  console.log(`Server is up and running on 5000 ...`);});
Steps to run the program:
Run the index.js file using the following command:
node index.js
Output: 
We will see the following output on the console:
Server is up and running on 5000 ...

Now open the browser and go to http://localhost:5000/, you will see the following output on screen:
Output on Browser
Now again check the terminal output, it will look like the following: 
Server is up and running on 5000 ...
We are in Middleware 2.
Data of Middleware 1
Express.js
Picked
Technical Scripter 2020
Node.js
Technical Scripter
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Express.js express.Router() Function
JWT Authentication with Node.js
Express.js req.params Property
Mongoose Populate() Method
Difference between npm i and npm ci in Node.js
How to build a basic CRUD app with Node.js and ReactJS ?
Mongoose find() Function
Node.js Export Module
How to connect Node.js with React.js ?
Node.js fs.createReadStream() Method
OpenCV - The IMREAD_XXX Flag

OpenCV supports various types of images such as colored, binary, grayscale, etc. Using the imread() method and predefined fields of the Imgcodecs class, you can read a given image as another type.
In the earlier chapters, we have seen the syntax of imread() method of the Imgcodecs class. It accepts a string argument representing the location of the image that is to be read.
imread(filename)

The imread() method has another syntax.
imread(filename, int flags)

This syntax accepts two parameters −
filename − It accepts an argument (filename), a variable of the String type representing the path of the file that is to be read.
filename − It accepts an argument (filename), a variable of the String type representing the path of the file that is to be read.
flags − An integer value representing a predefined flag value. For each value, this reads the given image as a specific type (gray scale color etc.)
flags − An integer value representing a predefined flag value. For each value, this reads the given image as a specific type (gray scale color etc.)
Following is the table listing various fields provided in the Imgproc class as values for this parameter.
IMREAD_COLOR
If the flag is set to this value, the loaded image will be converted to a 3-channel BGR (Blue Green Red) color image.
IMREAD_GRAYSCALE
If the flag is set to this value, the loaded image will be converted to a single-channel grayscale image.
IMREAD_LOAD_GDAL
If the flag is set to this value, you can load the image using the gdal driver.
IMREAD_ANYCOLOR
If the flag is set to this value, the image is read in any possible color format.
IMREAD_REDUCED_COLOR_2
IMREAD_REDUCED_COLOR_4
IMREAD_REDUCED_COLOR_8
If the flag is set to this value, the image is read as three-channel BGR, and the size of the image is reduced to 1⁄2, 1⁄4th or 1⁄8th  of the original size of the image with respect to the field used.
IMREAD_REDUCED_GRAYSCALE_2
IMREAD_REDUCED_GRAYSCALE_4
IMREAD_REDUCED_GRAYSCALE_8
If the flag is set to this value, the image is read as a single-channel grayscale image, and the size of the image is reduced to 1⁄2, 1⁄4th or 1⁄8th of the original size of the image with respect to the field used.
IMREAD_UNCHANGED
If the flag is set to this value, the loaded image is returned as it is.

    70 Lectures 
     9 hours 

 Abhilash Nelson

    41 Lectures 
     4 hours 

 Abhilash Nelson

    20 Lectures 
     2 hours 

 Spotle Learn

    12 Lectures 
     46 mins

 Srikanth Guskra

    19 Lectures 
     2 hours 

 Haithem Gasmi

    67 Lectures 
     6.5 hours 

 Gianluca Mottola
 Print
 Add Notes
 Bookmark this page
Python Program to Read Height in Centimeters and convert the Height to Feet and Inches

When it is required to read the height in ‘cm’ and convert it into ‘feet’ and ‘inches’, the ‘round’ method can be used.
Below is a demonstration of the same −
 Live Demo
in_cm=int(input("Enter the height in centimeters..."))
in_inches=0.394*in_cm
in_feet=0.0328*in_cm
print("The length in inches is ")
print(round(in_inches,2))
print("The length in feet is")
print(round(in_feet,2))
Enter the height in centimeters...178
The length in inches is
70.13
The length in feet is
5.84
The input is taken by user, as ‘cm’.
The input is taken by user, as ‘cm’.
It can be converted into inches by multiplying it with 0.394.
It can be converted into inches by multiplying it with 0.394.
This is assigned to a variable.
This is assigned to a variable.
It can be converted into feet by multiplying it with 0.0328.
It can be converted into feet by multiplying it with 0.0328.
This is assigned to a variable.
This is assigned to a variable.
It is rounded off to nearest two decimal values.
It is rounded off to nearest two decimal values.
Both these converted values are displayed as output on the console.
Both these converted values are displayed as output on the console.
Finding duplicate "words" in a string - JavaScript

We are required to write a JavaScript function that takes in a string and returns a new string with only the words that appeared for more than once in the original string.
For example: If the input string is −
const str = "big black bug bit a big black dog on his big black nose";
Then the output should be −
const output = "big black";
Let’s write the code for this function −
const str = "big black bug bit a big black dog on his big black nose";
const findDuplicateWords = str => {
   const strArr = str.split(" ");
   const res = [];
   for(let i = 0; i < strArr.length; i++){
      if(strArr.indexOf(strArr[i]) !== strArr.lastIndexOf(strArr[i])){
         if(!res.includes(strArr[i])){
            res.push(strArr[i]);
         };
      };
   };
   return res.join(" ");
};
console.log(findDuplicateWords(str));
The output in the console: −
big black
How to create a responsive Image Grid with HTML and CSS?

Following is the code to create a responsive image grid using HTML and CSS −
 Live Demo
<!DOCTYPE html>
<html>
<style>
* {
   box-sizing: border-box;
}
h1 {
   text-align: center;
}
.outer-grid {
   display: flex;
   flex-wrap: wrap;
   padding: 0 4px;
}
.inner-grid {
   flex: 25%;
   max-width: 25%;
   padding: 0 4px;
}
.inner-grid img {
   margin-top: 8px;
   width: 100%;
   padding: 10px;
}
@media screen and (max-width: 800px) {
   .inner-grid {
      flex: 50%;
      max-width: 50%;
   }
}
@media screen and (max-width: 600px) {
   .inner-grid {
      flex: 100%;
      max-width: 100%;
   }
}
</style>
<body>
<h1>Responsive Image Grid Example</h1>
<div class="outer-grid">
<div class="inner-grid">
<img src="https://images.pexels.com/photos/1083822/pexels-photo-1083822.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"/>
<img src="https://images.pexels.com/photos/1083822/pexels-photo-1083822.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"/>
<img src="https://images.pexels.com/photos/1083822/pexels-photo-1083822.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"/>
</div>
<div class="inner-grid">
<img src="https://images.pexels.com/photos/3805102/pexels-photo-3805102.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"/>
<img src="https://images.pexels.com/photos/3805102/pexels-photo-3805102.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"/>
<img src="https://images.pexels.com/photos/3805102/pexels-photo-3805102.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"/>
</div>
<div class="inner-grid">
<img src="https://images.pexels.com/photos/3863778/pexels-photo-3863778.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"/>
<img src="https://images.pexels.com/photos/3863778/pexels-photo-3863778.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"/>
<img src="https://images.pexels.com/photos/3863778/pexels-photo-3863778.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"/>
</div>
</div>
</body>
</html>
The above code will produce the following output −
On resizing the screen the grid will resize from 3 columns to 2 columns and so on −
spaCy - Doc.ents Property

This doc property is used for the named entities in the document. If the entity recognizer has been applied, this property will return a tuple of named entity span objects.
An example of Doc.ents property is as follows −
import spacy
nlp_model = spacy.load("en_core_web_sm")
doc = nlp_model("This is Tutorialspoint.com.")
ents = list(doc.ents)
ents[0].label
When you execute the code, you will see the following output −
383

Here is an another example of Doc.ents property −
ents[0].label_
‘ORG’

Given below is an example of Doc.ents property −
ents[0].text
'Tutorialspoint.com'

 Print
 Add Notes
 Bookmark this page
Aptitude | Arithmetic Aptitude 4 | Question 5 - GeeksforGeeks

28 Jun, 2021
Subhash has 90 currency notes, some of which are Rs. 1000 denomination and rest of Rs. 500 denomination. The total amount is Rs 71,000. How many notes he has in denomination of Rs. 500?(A) 30(B) 32(C) 34(D) 38Answer: (D)Explanation:
Let the no. of Rs. 500 note be X
Then the no. of Rs. 1000 note = 90 – X
∴ 500X + 1000(90 – X) = 71000
∴ 500X + 90000 – 1000X = 71000
∴ 500X = 19000
∴ X = 38
Quiz of this Question
Aptitude
Aptitude-Arithmetic Aptitude 4
Arithmetic Aptitude 4
Aptitude
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
| | Question 44
Puzzle | How much money did the man have before entering the bank?
Maximum GCD of all subarrays of length at least 2
7 Best Tips to Prepare for Aptitude Test For Campus Placements
Puzzle | Splitting a Cake with a Missing Piece in two equal portion
Order and Ranking Questions & Answers
Aptitude | GATE CS 1998 | Question 77
10 Tips and Tricks to Crack Internships and Placements
Geometry and Co-ordinates
Seating Arrangement | Aptitude
RSpec - Subjects

One of RSpec’s strengths is that it provides many ways to write tests, clean tests. When your tests are short and uncluttered, it becomes easier to focus on the expected behavior and not on the details of how the tests are written. RSpec Subjects are yet another shortcut allowing you to write simple straightforward tests.
Consider this code −
class Person 
   attr_reader :first_name, :last_name 
   
   def initialize(first_name, last_name) 
      @first_name = first_name 
      @last_name = last_name 
   end 
end 

describe Person do 
   it 'create a new person with a first and last name' do
      person = Person.new 'John', 'Smith'
      
      expect(person).to have_attributes(first_name: 'John') 
      expect(person).to have_attributes(last_name: 'Smith') 
   end 
end
It’s actually pretty clear as is, but we could use RSpec’s subject feature to reduce the amount of code in the example. We do that by moving the person object instantiation into the describe line.
class Person 
   attr_reader :first_name, :last_name 
   
   def initialize(first_name, last_name) 
      @first_name = first_name 
      @last_name = last_name 
   end 
	
end 

describe Person.new 'John', 'Smith' do 
   it { is_expected.to have_attributes(first_name: 'John') } 
   it { is_expected.to have_attributes(last_name: 'Smith') }
end
When you run this code, you will see this output −
.. 
Finished in 0.003 seconds (files took 0.11201 seconds to load) 
2 examples, 0 failures

Note, how much simpler the second code sample is. We took the one it block in the first example and replaced it with two it blocks which end up requiring less code and are just as clear.

    9 Lectures 
     37 mins

 Harshit Srivastava

    27 Lectures 
     7 hours 

 Atul Tiwari
 Print
 Add Notes
 Bookmark this page
How to split a string into elements of a string array in C#?

Set the string you want to split.
string str = "Hello World!";
Use the split() method to split the string into separate elements.
string[] res = str.Split(' ');
The following is the complete code to split a string into elements of a string array in C#.
 Live Demo
using System;
class Demo {
   static void Main() {
      string str = "Hello World!";
      string[] res = str.Split(' ');
      Console.WriteLine("Separate elements:");
      foreach (string words in res) {
         Console.WriteLine(words);
      }
   }
}
Separate elements:
Hello
World!
Contains Duplicate III in C++

Suppose we have an array of integers, we have to check whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t. And the absolute difference between i and j is at most k. So if input is like [1,2,3,1], then if k = 3 and t = 0, then return true.
To solve this, we will follow these steps −
Make a set s, n := size of nums array
Make a set s, n := size of nums array
for i in range 0 to n – 1x is index of set element starting from nums[i] and aboveif x is not in range of the set and value of x <= nums[i] + t, then return trueif x is not the first elementx := next element as randomif t th element starting from x is >= nums[i], then return trueinsert nums[i] into s, then delete nums[i - k] from s
for i in range 0 to n – 1
x is index of set element starting from nums[i] and above
x is index of set element starting from nums[i] and above
if x is not in range of the set and value of x <= nums[i] + t, then return true
if x is not in range of the set and value of x <= nums[i] + t, then return true
if x is not the first elementx := next element as randomif t th element starting from x is >= nums[i], then return true
if x is not the first element
x := next element as random
x := next element as random
if t th element starting from x is >= nums[i], then return true
if t th element starting from x is >= nums[i], then return true
insert nums[i] into s, then delete nums[i - k] from s
insert nums[i] into s, then delete nums[i - k] from s
return false
return false
Let us see the following implementation to get a better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
   public:
   bool containsNearbyAlmostDuplicate(vector<int>& nums, int k, int t) {
      multiset <int> s;
      int n = nums.size();
      for(int i = 0; i< n; i++){
         multiset <int> :: iterator x = s.lower_bound(nums[i]);
         if(x != s.end() && *x <= nums[i] + t ) return true;
            if(x != s.begin()){
               x = std::next(x, -1);
               if(*x + t >= nums[i])return true;
            }
            s.insert(nums[i]);
            if(i >= k){
               s.erase(nums[i - k]);
            }
         }
         return false;
      }
};
main(){
   Solution ob;
   vector<int> v = {1,2,3,1};
   cout << (ob.containsNearbyAlmostDuplicate(v, 3,0));
}
[1,2,3,1]
3
0
1
RxJava - Environment Setup

RxJava is a library for Java, so the very first requirement is to have JDK installed in your machine.
First of all, open the console and execute a java command based on the operating system you are working on.
Let's verify the output for all the operating systems −
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101)
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101)
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101)
If you do not have Java installed on your system, then download the Java Software Development Kit (SDK) from the following link https://www.oracle.com. We are assuming Java 1.8.0_101 as the installed version for this tutorial.
Set the JAVA_HOME environment variable to point to the base directory location where Java is installed on your machine. For example.
Append Java compiler location to the System Path.
Verify Java installation using the command java -version as explained above.
Download the latest version of RxJava jar file from RxJava @ MVNRepository
and its dependency Reactive Streams @ MVNRepository
. At the time of writing this tutorial, we have downloaded rxjava-2.2.4.jar, reactive-streams-1.0.2.jar and copied it into C:\>RxJava folder.
Set the RX_JAVA environment variable to point to the base directory location where RxJava jar is stored on your machine. Let’s assuming we've stored rxjava-2.2.4.jar and reactive-streams-1.0.2.jar in the RxJava folder.
Windows
Set the environment variable RX_JAVA to C:\RxJava
Linux
export RX_JAVA = /usr/local/RxJava
Mac
export RX_JAVA = /Library/RxJava
Set the CLASSPATH environment variable to point to the RxJava jar location.
Windows
Set the environment variable CLASSPATH to %CLASSPATH%;%RX_JAVA%\rxjava-2.2.4.jar;%RX_JAVA%\reactive-streams-1.0.2.jar;.;
Linux
export CLASSPATH = $CLASSPATH:$RX_JAVA/rxjava-2.2.4.jar:reactive-streams-1.0.2.jar:.
Mac
export CLASSPATH = $CLASSPATH:$RX_JAVA/rxjava-2.2.4.jar:reactive-streams-1.0.2.jar:.
Create a class TestRx.java as shown below −
import io.reactivex.Flowable;
public class TestRx {
   public static void main(String[] args) {
      Flowable.just("Hello World!").subscribe(System.out::println);
   }
}
Compile the classes using javac compiler as follows −
C:\RxJava>javac Tester.java

Verify the output.
Hello World!

 Print
 Add Notes
 Bookmark this page
Return Statement vs Exit() in Main() using C++

If you are a programmer, you write the code; If you write the code, you use the function; if you use the function, you use return and exit statements in every function. So In this article, we will discuss what a return statement and exit statement are and their differences.
In C++,
return is a statement that returns the control of the flow of execution to the function which is calling.
Exit statement terminates the program at the point it is used.
int main()
This is where the execution of the program begins. The program is executed from the main() function, and since we have int in place of the return type, it has to return some integer value. We can say this integer represents the program's status, where 0 means the program executes successfully. A non-zero value means there is an execution error in the code.
A return statement always returns the control of flow to the function which is calling. Return uses exit code which is int value, to return to the calling function. Using the return statement in the main function means exiting the program with a status code; for example, return 0 means returning status code 0 to the operating system. Let us look at a C++ program using the return statement.
#include <iostream>
using namespace std;
class Test {
   public:
   //To activate Constructor
   Test() {
      cout<<"Hey this is Return Constructor \n";
   }

   //To activate Destructor
   ~Test() {
      cout<<"Hey this is return Destructor";
   }
};
int main() {
   //Creating object of Test class
   Test object;

   //Using return in main
   return 0;
}
Hey this is Return Constructor
Hey this is return Destructor
Looking at the above program, we can say that return calls the constructor and destructor of a class object. Calling the destructor is essential to release the allocated memory.
Exit () statement terminates the program at the point it is used. When the exit keyword is used in the main function, it will exit the program without calling the destructor for locally scoped objects. Any created object will not be destroyed and will not release memory; it will just terminate the program.
#include <iostream>
using namespace std;
class Test {
   public:
   //To activate Constructor
   Test() {
      cout<<"Hey this is exit Constructor \n";
   }

   //To activate Destructor
   ~Test() {
      cout<<"Hey this is exit Destructor";
   }
};
int main() {
   //Creating object of Test class
   Test object;

   //Using exit() in main
   exit(0);
}
Hey this is exit Constructor
Looking at the program's output, we can conclude that using the exit keyword in our program means it will not call a destructor to destroy allocated memory and the locally scoped objects.
In this article, we understand the differences between return statements and exit statements. We can conclude from the differences that using them makes a lot of difference in our program. Using exit over return requires precautions. However, they don't impact much on one page of code and impact a lot when developing software. We hope you find this article helpful.
How to draw a circle in JavaScript?

Following is the code to draw a circle in JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .circleCanvas {
      border: 3px solid #110101;
   }
</style>
</head>
<body>
<h1>Draw a circle in JavaScript</h1>
<canvas class="circleCanvas" width="400" height="200"></canvas><br />
<button class="Btn">CLICK HERE</button>
<h3>Click on the above button to create a circle in the above canvas element</h3>
<script>
   let canvasEle = document.querySelector(".circleCanvas");
   let BtnEle = document.querySelector(".Btn");
   BtnEle.addEventListener("click", () => {
      var circle = canvasEle.getContext("2d");
      circle.beginPath();
      circle.arc(180, 100, 90, 0, 2 * Math.PI);
      circle.stroke();
   });
</script>
</body>
</html>
The above code will produce the following output −
On clicking the ‘CLICK HERE’ button −
How to insert only a single column into a MySQL table with Java?

Use INSERT INTO statement in the Java-MySQL connection code to insert a column.
Let us first create a table −
mysql> create table DemoTable
   -> (
   -> Name varchar(20)
   -> );
Query OK, 0 rows affected (0.54 sec)
Here is the Java code to insert only a single column into a MySQL table.
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class InsertOneColumnDemo {
   public static void main(String[] args) {
      Connection con = null;
      PreparedStatement ps = null;
      try {
         con = DriverManager.getConnection("jdbc:mysql://localhost:3306/web?" + "useSSL=false", "root", "123456");
         String query = "insert into DemoTable(Name) values(?) ";
         ps = con.prepareStatement(query);
         ps.setString(1, "Robert");
         ps.executeUpdate();
         System.out.println("Record is inserted successfully......");
      }
      catch (Exception e) {
         e.printStackTrace();
      }
   }
}
This will produce the following output −
Now let us check the records inserted in the table using select statement −
mysql> select * from DemoTable;
This will produce the following output −
+--------+
| Name   |
+--------+
| Robert |
+--------+
1 row in set (0.00 sec)
How to put a Toplevel window in front of the main window in Tkinter?

The Tkinter Toplevel window creates an additional window apart from the main window. We can add widgets and components to the newly created top-level window. It supports all the properties of the parent or main window.
Sometimes the Toplevel window is also referred to as the child window. To put the child window in front of the parent window, we can use the wm_transient() method.
# 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")
win.title("Parent Window")

# Create a Toplevel window
top=Toplevel(win)
top.geometry('600x250')
top.title("Child Window")

# Place the toplevel window at the top
top.wm_transient(win)

win.mainloop()
If we run the above code, it will display a Toplevel window in front of the main window.
Fortran - Variables

A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable should have a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable.
The name of a variable can be composed of letters, digits, and the underscore character. A name in Fortran must follow the following rules −
It cannot be longer than 31 characters.
It cannot be longer than 31 characters.
It must be composed of alphanumeric characters (all the letters of the alphabet, and the digits 0 to 9) and underscores (_).
It must be composed of alphanumeric characters (all the letters of the alphabet, and the digits 0 to 9) and underscores (_).
First character of a name must be a letter.
First character of a name must be a letter.
Names are case-insensitive.
Names are case-insensitive.
Based on the basic types explained in previous chapter, following are the variable types −
Integer
It can hold only integer values.
Real
It stores the floating point numbers.
Complex
It is used for storing complex numbers.
Logical
It stores logical Boolean values.
Character
It stores characters or strings.
Variables are declared at the beginning of a program (or subprogram) in a type declaration statement.
Syntax for variable declaration is as follows −
type-specifier :: variable_name

integer :: total  	
real :: average 
complex :: cx  
logical :: done 
character(len = 80) :: message ! a string of 80 characters
Later you can assign values to these variables, like,
total = 20000  
average = 1666.67   
done = .true.   
message = “A big Hello from Tutorials Point” 
cx = (3.0, 5.0) ! cx = 3.0 + 5.0i

You can also use the intrinsic function cmplx, to assign values to a complex variable −
cx = cmplx (1.0/2.0, -7.0) ! cx = 0.5 – 7.0i 
cx = cmplx (x, y) ! cx = x + yi

The following example demonstrates variable declaration, assignment and display on screen −
program variableTesting
implicit none

   ! declaring variables
   integer :: total      
   real :: average 
   complex :: cx  
   logical :: done 
   character(len=80) :: message ! a string of 80 characters
   
   !assigning values
   total = 20000  
   average = 1666.67   
   done = .true.   
   message = "A big Hello from Tutorials Point" 
   cx = (3.0, 5.0) ! cx = 3.0 + 5.0i

   Print *, total
   Print *, average
   Print *, cx
   Print *, done
   Print *, message
   
end program variableTesting
When the above code is compiled and executed, it produces the following result −
20000
1666.67004    
(3.00000000, 5.00000000 )
T
A big Hello from Tutorials Point         

 Print
 Add Notes
 Bookmark this page