code-rag-bench/online-tutorials huggingface dataset:
GATE | GATE-CS-2015 (Set 2) | Question 65

02 May, 2019
A computer system implements a 40 bit virtual address, page size of 8 kilobytes, and a 128-entry translation look-aside buffer (TLB) organized into 32 sets each having four ways. Assume that the TLB tag does not store any process id. Theminimum length of the TLB tag in bits is _________(A) 20(B) 10(C) 11(D) 22Answer: (D)Explanation:
Total virtual address size = 40

Since there are 32 sets, set offset = 5

Since page size is 8kilobytes, word offset = 13

Minimum tag size = 40 - 5- 13 = 22
Quiz of this Question
GATE-CS-2015 (Set 2)
GATE-GATE-CS-2015 (Set 2)
Operating Systems
Operating Systems
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
File Allocation Methods
Memory Management in Operating System
Logical and Physical Address in Operating System
Different approaches or Structures of Operating Systems
Segmentation in Operating System
Structures of Directory in Operating System
Difference between Internal and External fragmentation
File Access Methods in Operating System
Process Table and Process Control Block (PCB)
Introduction of System Call
Instant plus() method in Java with Examples

27 Dec, 2018
In Instant class, there are two types of plus() method depending upon the parameters passed to it.
plus() method of a Instant class used to return a copy of this instant with the specified amount of unit added.If it is not possible to add the amount, because the unit is not supported or for some other reason, an exception is thrown. This instance is immutable and unaffected by this method call.
Syntax:
public Instant plus(long amountToAdd,
                    TemporalUnit unit)

Parameters: This method accepts two parameters amountToAdd which is the amount of the unit to add to the result, may be negative and unit which is the unit of the amount to add, not null.
Return value: This method returns Instant based on this instant with the specified amount added.
Below programs illustrate the plus() method:Program 1:
// Java program to demonstrate// Instant.plus() method  import java.time.*;import java.time.temporal.ChronoUnit;  public class GFG {    public static void main(String[] args)    {          // create an Instant object        Instant instant            = Instant.parse("2018-12-30T19:34:50.63Z");          // add 30 DAYS to Instant        Instant value            = instant.plus(30, ChronoUnit.DAYS);          // print result        System.out.println("Instant after adding 30 DAYS: "                           + value);    }}
Instant after adding 30 DAYS: 2019-01-29T19:34:50.630Z

plus() method of a Instant class used to return a copy of this instant with the specified amount added to date-time.The amount is typically Period or Duration but may be any other type implementing the TemporalAmount interface.
Syntax:
public Instant plus(TemporalAmount amountToAdd)

Parameters: This method accepts one single parameter amountToAdd which is the amount to add, It should not be null.
Return value: This method returns Instant based on this instant with the addition made, not null
Below programs illustrate the plus() method:Program 1:
// Java program to demonstrate// Instant.plus() method  import java.time.*;public class GFG {    public static void main(String[] args)    {          // create a Instant object        Instant inst            = Instant.parse("2018-12-30T19:34:50.63Z");          // add 20 Days to Instant        Instant value            = inst.plus(Period.ofDays(10));          // print result        System.out.println("Instant after adding Days: "                           + value);    }}
Instant after adding Days: 2019-01-09T19:34:50.630Z

References:https://docs.oracle.com/javase/10/docs/api/java/time/Instant.html#plus(java.time.temporal.TemporalAmount)https://docs.oracle.com/javase/10/docs/api/java/time/Instant.html#plus(long, java.time.temporal.TemporalUnit)
Java-Functions
Java-Instant
Java-time 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
Collections in Java
Multidimensional Arrays in Java
Stream In Java
Singleton Class in Java
Set in Java
Python - 3D Charts

Python is also capable of creating 3d charts. It involves adding a subplot to an existing two-dimensional plot and assigning the projection parameter as 3d.  
3dPlot is drawn by mpl_toolkits.mplot3d  to add a subplot to an existing 2d plot.
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt


chart = plt.figure()
chart3d = chart.add_subplot(111, projection='3d')

# Create some test data.
X, Y, Z = axes3d.get_test_data(0.08)

# Plot a wireframe.
chart3d.plot_wireframe(X, Y, Z, color='r',rstride=15, cstride=10)

plt.show()
 
Its output is as follows −

    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
Combinational Circuits - GeeksforGeeks

19 Nov, 2018
In the 1st column there are 4 NOR Gates, 
number them as 1 to 4 ( top to down).

In the 2nd column there are 2 NOR Gates, 
number them as 5 and 6 ( top to down).

In the 3rd column there is only 1 NOR Gate, 
number it as 7.

1st numbered Gate gives output as : ( P + Q )'
2nd numbered Gate gives output as : ( Q + R )'
3rd numbered Gate gives output as : ( P + R )'
4th numbered Gate gives output as : ( R + Q )'
5th numbered Gate gives output as :
(( P + Q )' + ( Q + R )')'
= ((P + Q)'' . ( Q + R )'') ( De Morgan's law)
= (P + Q ) . ( Q + R ) ( Idempotent Law, A'' = A)
= (PQ + PR + Q + QR )
= (Q(1 + P + R) + PR) = Q + PR ( as, 1 + " any 
                                boolean expression" = 1 )

Similarly 6th numbered Gate gives output as : R + PQ 
                             (as this time R is common here)

Now 7th numbered Gate gives output as :
((Q + PR) + (R + PQ))'
= (Q( 1+P) + R(1+P))'
= (Q+R)' 
Pi = Ai ⨁ Bi and Gi = AiBi 
Si = Pi ⨁ Ci and Ci+1 = Gi + PiCi , where C0 is the input carry. 
c1 = g0 + p0c0 = 1 AND, 1 OR
c2 = g1 + p1g0 + p1p0c0 
   = 2 AND, 1 OR

c3 = g2 + p2g1 + p2p1go + p2p1p0c0 
   = 3 AND, 1 OR
c4 = g3 + p3g2 + p3p2g1 + p3p2p1g0 + p3p2p1p0c0 
   = 4 AND, 1 OR
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Comments
Old Comments
Tailwind CSS vs Bootstrap
How to Show Images on Click using HTML ?
Microsoft Interview Experience for Internship (Via Engage)
How to Calculate Number of Host in a Subnet?
How to Convert Categorical Variable to Numeric in Pandas?
How to Replace Values in Column Based on Condition in Pandas?
C Program to read contents of Whole File
Insert Image in a Jupyter Notebook
How to Replace Values in a List in Python?
How to Read Text Files with Pandas?
swap() function in C++

The swap() function is used to swap two numbers. By using this function, you do not need any third variable to swap two numbers.
Here is the syntax of swap() in C++ language,
void swap(int variable_name1, int variable_name2);
If we assign the values to variables or pass user-defined values, it will swap the values of variables but the value of variables will remain same at the actual place.
Here is an example of swap() in C++ language,
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int main() {
   int x = 35, y = 75;
   printf("Value of x :%d",x);
   printf("\nValue of y :%d",y);
   swap(x, y);
   printf("\nAfter swapping, the values are: x = %d, y = %d", x, y);
   return 0;
}
Value of x :35
Value of y :75
After swapping, the values are: x = 75, y = 35
It is better that we pass the values to the variables by reference, it will swap the values of variables at actual place.
Here is another example of swap() in C++ language,
 Live Demo
#include <stdio.h>
void SwapValue(int &a, int &b) {
   int t = a;
   a = b;
   b = t;
}
int main() {
   int a, b;
   printf("Enter value of a : ");
   scanf("%d", &a);
   printf("\nEnter value of b : ");
   scanf("%d", &b);
   SwapValue(a, b);
   printf("\nAfter swapping, the values are: a = %d, b = %d", a, b);
   return 0;
}
Enter value of a : 8
Enter value of b : 28
After swapping, the values are: a = 28, b = 8
Why static methods of parent class gets hidden in child class in java?

When we have two classes where, one extends another and if, these two classes have same method including parameters and return type (say, sample) the method in the sub class overrides the method in the super class.
i.e. Since it is inheritance. If we instantiate the subclass a copy of superclass’s members is created in the subclass object and, thus both methods are available to the object of the subclass.
But if you call the method (sample), the sample method of the subclass will be executed overriding the super class’s method.
class Super{
   public static void sample(){
      System.out.println("Method of the superclass");
   }
}
public class OverridingExample extends Super {
   public static void sample(){
      System.out.println("Method of the subclass");
   }
   public static void main(String args[]){
      Super obj1 = (Super) new OverridingExample();
      OverridingExample obj2 = new OverridingExample();
      obj1.sample();
      obj2.sample();
   }
}
Method of the superclass
Method of the subclass
When superclass and subclass contains same method including parameters and if they are static. The method in the superclass will be hidden by the one that is in the subclass.
This mechanism is known as method hiding in short, though super and subclasses have methods with same signature it they are static, it is not considered as overriding.
class Super{
   public static void demo() {
      System.out.println("This is the main method of the superclass");
   }
}
class Sub extends Super{
   public static void demo() {
      System.out.println("This is the main method of the subclass");
   }
}
public class MethodHiding{
   public static void main(String args[]) {
      MethodHiding obj = new MethodHiding();
      Sub.demo();
   }
}
This is the main method of the subclass
The key in method overloading is, if the super class and sub class have method with same signature, to the object of the sub class both of them are available. Based on the object type (reference) you used to hold the object, the respective method will be executed.
SuperClass obj1 = (Super) new SubClass();
obj1.demo() // invokes the demo method of the super class
SubClass obj2 = new SubClass ();
obj2.demo() //invokes the demo method of the sub class
But, in case of static methods, since they don’t belong to any instance, you need to access them using the class name.
SuperClass.demo();
SubClass.Demo();
Therefore, if a super class and sub class have static methods with same signature, though a copy of the super class method is available to the sub class object. Since they are static the method calls resolve at the compile time itself, overriding is not possible with static methods.
But, since a copy of static method is available, if you call the sub class method the method of the super class will be redefined/hidden.
Check if concatenation of two strings is balanced or not in Python

Suppose we have two bracket sequences s and t with only these characters '(' and ')'. We have to check whether the concatenated string of s and t is balanced or not. The concatenation can be done by s | t or t | s.
So, if the input is like s = "()()))", t = "()(()(", then the output will be True because if we concatenate t | s, then we will get "()(()(()()))", which is balanced.
To solve this, we will follow these steps −
Define a function is_balanced_parenthesis() . This will take string
stack := a new list
for i in range 0 to size of string, doif string[i] is same as '(', thenpush string[i] into stackotherwise,if stack is empty, thenreturn Falseotherwise,pop from stack
if string[i] is same as '(', thenpush string[i] into stack
push string[i] into stack
otherwise,if stack is empty, thenreturn Falseotherwise,pop from stack
if stack is empty, thenreturn False
return False
otherwise,pop from stack
pop from stack
if stack is not empty, thenreturn False
return False
return True
From the main method do the following −
if is_balanced_parenthesis(s + t) is true, thenreturn True
return True
return is_balanced_parenthesis(t + s)
Let us see the following implementation to get better understanding −
 Live Demo
def is_balanced_parenthesis(string):
   stack = []
   for i in range(len(string)):
      if string[i] == '(':
         stack.append(string[i])
      else:
         if len(stack) == 0:
            return False
         else:
            stack.pop()
   if len(stack) > 0:
      return False
   return True
def solve(s, t):
   if is_balanced_parenthesis(s + t):
      return True
   return is_balanced_parenthesis(t + s)
s = "()()))"
t = "()(()("
print(solve(s, t))
"()()))", "()(()("
True
Chained exception in Java


Chained exception helps to relate one exception to other. Often we need to throw a custom exception and want to keep the details of an original exception that in such scenarios we can use the chained exception mechanism. Consider the following example, where we are throwing a custom exception while keeping the message of the original exception.
Live Demo
public class Tester {
   public static void main(String[] args) {
      try {
         test();
      }catch(ApplicationException e) {          
         System.out.println(e.getMessage());
      }
   }  

   public static void test() throws ApplicationException {
      try {
         int a = 0;
         int b = 1;
         System.out.println(b/a);
      }catch(Exception e) {
         throw new ApplicationException(e);
      }
   }
}

class ApplicationException extends Exception {
   public ApplicationException(Exception e) {          
      super(e);
   }
}
java.lang.ArithmeticException: / by zero
The throwable class supports chained exception using the following methods:
Throwable(Throwable cause) - the cause is the current exception.
Throwable(Throwable cause) - the cause is the current exception.
Throwable(String msg, Throwable cause) - msg is the exception message, the cause is the current exception.
Throwable(String msg, Throwable cause) - msg is the exception message, the cause is the current exception.
getCause - returns actual cause.
getCause - returns actual cause.
initCause(Throwable cause) - sets the cause for calling an exception.
initCause(Throwable cause) - sets the cause for calling an exception.
Print colored message with different fonts and sizes in C

C/C++ programming language, the user is provided with functionality to customize the output based on the requirement of the user. C/C++ graphics functions are included in graphics.h header file. Using this library you can create different objects, set the color of text, change the font and size of the text and change the background of the output.
Now, let's see the working of all the function to alter the text of the output in c/c++ programming language −
setcolor() − This function is used to change the color of the output text.
setcolor(int)
#include<stdio.h>
#include<graphics.h>
int main(){
   int gdriver = DETECT,gmode,i;
   initgraph(&gdriver,&gmode,"C:\\Turboc3\\BGI");
   setcolor(5);
   return 0;
}
settexttyle() − This function is used to change the font style, orientation, and size of the output text.
settexttyle(int style , int orientation , int size);
#include<stdio.h>
#include<graphics.h>
int main(){
   int gdriver = DETECT,gmode,i;
   initgraph(&gdriver,&gmode,"C:\\Turboc3\\BGI");
   settextstyle(3,1,4);
   return 0;
}
Outtext − this function is used to print the message passed to it at some certain coordinates(x,y) on the screen.
outtext(int x_cordinate , int y_cordinate, text)
#include<stdio.h>
#include<graphics.h>
int main(){
   int gdriver = DETECT,gmode,i;
   initgraph(&gdriver,&gmode,"C:\\Turboc3\\BGI");
   settextstyle(25,15,’hello!’);
   return 0;
}
textheight() − this function is used to change the height of the text in the output screen.
textheight(int)
textwidth() − This function is used to change the width of the text in the output screen.
textwidth(int)
How do I get the id after INSERT into MySQL database in Python?

First, we need to complete the below requirements. The following are the prerequisites.
We need to install MySQL version 8.0.12.
We need to install Python version 3.6.3 (32 bit).
We need to install pymysql with the help of pip command.
To install “pymysql” with the help of pip command.
The database name is ‘business’ and the table name is ‘student’ with ID 3 after inserting records.
Here is the query.
mysql> select *from student;
The following is the output.
+------+-------+
| id   | Name  |
+------+-------+
|    1 | John  |
|    2 | Bob   |
|    3 | Smith |
+------+-------+
3 rows in set (0.00 sec)

We can get it with the help of Python for the same table name and database business.
The Python code snapshot is as follows −
The following is the output.
The output for MySQL and Python gets the ID after inserting::
JavaScript | Classes

25 Nov, 2021
Introduction of new version of JavaScript (ES6) introduced the use of classes instead of functions.Classes are similar to functions.They use class keyword instead of function keyword. They use constructor method to initialise. 
Syntax:
class classname {
  constructor(parameter) {
    this.classname = parameter;
  }
}
Below example illustrates the JavaScript classes:
html
<!DOCTYPE html><html> <body>    <center>        <h1 style="color: green;">            GeeksforGeeks        </h1>         <p>          A Computer Science Portal for Geeks        </p>          <b>JavaScript Classes</b>         <p id="demo"></p>          <script>            class class_name {                constructor(value) {                    this.classes = value;                }            }             myvalue = new class_name("GeeksforGeeks");             document.getElementById("demo").innerHTML =              myvalue.classes;        </script>    </center></body> </html>
Output:  
 
varshagumber28
javascript-basics
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Using Lynx to Browse the Web From the Linux Terminal

03 Oct, 2019
Lynx is a terminal-based web browser for all Linux distributions. It shows the result as plain text on the terminal. It is a classic non-graphical text-mode web browser which displays the pages on the terminal. Lynx does not load images and multimedia contents, hence it is fast as compared to other browsers. One who do not want so many images and multimedia contents on web pages, they prefer using lynx. It is easy to install and easy to use and it does not require any additional interface to run or show the contents, it does so on the terminal.Lynx does not come by default with ubuntu, we need to install it using the command:
sudo apt-get install lynx
After installation, we can simply browse the pages using the command:
lynx desired url
Up arrow, Down arrow and Tab keys are used to navigate to different links in the web page. It also provides a feature to ask to save cookies of the requested web page i.e we are given choices whether choosing to save the cookies or not.
Properties of Lynx Browser:
Text-based Web Browser
Highly configurable
Commands used to configure
Oldest web browser in use
Supports many features of HTML
Compatible with old hardware
Linux-Unix
Technical Scripter
TechTips
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ZIP command in Linux with examples
tar command in Linux with examples
curl command in Linux with Examples
TCP Server-Client implementation in C
Conditional Statements | Shell Script
How to Find the Wi-Fi Password Using CMD in Windows?
Docker - COPY Instruction
Setting up the environment in Java
How to Run a Python Script using Docker?
Running Python script on GPU.
What is the Shortcut to Auto Import All in Android Studio?

07 Mar, 2021
There are some basics import in Android Studio that is predefined present in Android studio. like Menu, AppBar, MenuItem, Bundle, Toast, etc. When we require those then we import that manually. In case of pasting some code copied from the Internet in Editor, it asks to import every Views and class. You can simply import all of them by pressing the ALT + ENTER key. Here, we are going to explain how to auto-import all in Android studio. 
Import like this:
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
Step 1: Go to File and then Select Settings
Step 2: Then Go to Editor > General > Auto Import 
Here Select Java and then change Insert imports on paste value to All
Step 3: Then mark the “Add unambiguous imports on the fly” option as checked. Then click on Apply and Ok.
Note: We can import a single missing import using Alt + Enter which shown in the pop-up. To optimize imports (to remove unused imports ) use Ctrl + Alt + O. If for some reason auto-import is not enabled you can go to settings by typing shortcut: Ctrl + Alt + S.
If you use macOS, the only difference is where you can configure the above settings. Just click Android Studio > Preferences. The subsequent settings are very similar.
Android-Studio
Picked
Android
Android
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference Between Implicit Intent and Explicit Intent in Android
Retrofit with Kotlin Coroutine in Android
Flutter - BoxShadow Widget
Bundle in Android with Example
Animation in Android with Example
ExoPlayer in Android with Example
Bottom Navigation Bar in Android Using Kotlin
How to Post Data to API using Retrofit in Android?
Android | How to Create/Start a New Project in Android Studio?
Data Binding in Android with Example
Parametric & Geometric Continuity of Curves in Computer Graphics

27 Jan, 2022
Prerequisite: B-spline curve, Bezier curve
The continuity condition represents that how smoothly a curve transit from one curve segment to another segment. Consider you are given a curve as shown below:
There are three kinds of Parametric continuities that exist:
(a) Zero-order parametric continuity(_C0 ) : A curve is said to be zero-order parametric continuous if both segments of the curve intersect at one endpoint.
                                        P(t2) =  Q(t1)
(b) First-order parametric continuity(C1) : A curve is said to be first-order parametric continuous if it is Co Continuous and the first-order derivative of segment P at t=t2  is equal to the first-order derivative of segment Q at t=t1. Such kinds of curves have the same tangent line at the intersection point.
                                     P'(t2) = Q'(t1)
(c) Second-order parametric continuity(C2) : A curve is said to be second-order parametric continuous if it is Co and C1 Continuous and the second-order derivative of the segment P at t=t1 is equal to the second-order derivative of segment Q at t=t2. 
                                    P''(t2) = Q''(t1)
Geometric Continuity : It is an alternate method for joining two curve segments, where it requires the parametric derivation of both segments which are proportional to each other rather than equal to each other.
(a) Zero-order geometric continuity(Go) : It is similar to the zero-order parametric curve continuity condition.
                                         P(t2) =  Q(t1)
 (b) First-order geometric continuity(G1) : The junction point between two points is said to be G1 continuous if the coordinate of both curve segments is G0 continuous and following the below condition:
                                 P'(t2) =  k * Q'(t1)  for all x, y, z and k > 0.
(c) Second-order geometric continuity(G2) : The junction point between two points is said to be G2 continuous if the coordinate of both curve segments is G1 continuous and following the below condition:
                                P''(t2) =  k * Q''(t1)  for all x, y, z and k > 0.
miclack30
computer-graphics
Misc
Misc
Misc
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to write Regular Expressions?
Virtualization In Cloud Computing and Types
Association Rule
OOPs | Object Oriented Design
Software Engineering | Prototyping Model
std::unique in C++
Distributed Database System
Java Math min() method with Examples
Recursive Functions
fgets() and gets() in C language
Generate a set of Sample data from a Data set in R Programming – sample() Function

28 Jul, 2020
sample() function in R Language creates random sample based on the parameters provided in the function call. It takes either a vector or a positive integer as the object in the function parameter.
Syntax:sample(x, size, replace)
Parameters:x: indicates either vector or a positive integer or data framesize: indicates size of sample to be takenreplace: indicates logical value. If TRUE, sample may have more than one same value
To know about more optional parameters, use below command in console:
help("sample")

Example 1:
# Create samplex <- sample(1:100, 10, replace=TRUE)  # Print# Output may differ each time the command is executedprint(x)
Output:
[1] 47 52 22 98 75 94 91 94 42 53

Example 2:
# Create samplepos <- sample(1:nrow(mtcars), 5, replace = TRUE)  # Print sample observations# Output may differ each time the command is executedprint(mtcars[pos, ])
Output:
                  mpg cyl  disp  hp drat    wt  qsec vs am gear carb
Honda Civic      30.4   4  75.7  52 4.93 1.615 18.52  1  1    4    2
Merc 240D        24.4   4 146.7  62 3.69 3.190 20.00  1  0    4    2
Hornet 4 Drive   21.4   6 258.0 110 3.08 3.215 19.44  1  0    3    1
Hornet 4 Drive.1 21.4   6 258.0 110 3.08 3.215 19.44  1  0    3    1
Fiat 128         32.4   4  78.7  66 4.08 2.200 19.47  1  1    4    1

R Statistics-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Split Column Into Multiple Columns in R DataFrame?
Group by function in R using Dplyr
How to Change Axis Scales in R Plots?
R - if statement
Logistic Regression in R Programming
How to filter R DataFrame by values in a column?
Replace Specific Characters in String in R
How to import an Excel File into R ?
Joining of Dataframes in R Programming
Node.js Request Module

08 Oct, 2021
The request module is used to make HTTP calls. It is the simplest way of making HTTP calls in node.js using this request module. It follows redirects by default.
Feature of Request module:
It is easy to get started and easy to use.It is widely used and popular module for making HTTP calls.
It is easy to get started and easy to use.
It is widely used and popular module for making HTTP calls.
Installation of request module:
You can visit the link Install Request module. You can install this package by using this command.npm install requestAfter installing request module you can check your request version in command prompt using the command.npm version requestAfter that, you can 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 Install Request module. You can install this package by using this command.npm install request
npm install request
After installing request module you can check your request version in command prompt using the command.npm version request
npm version request
After that, you can 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
const request = require('request')   // Request URLvar url = 'https://jsonplaceholder.typicode.com/todos/1';  request(url, (error, response, body)=>{         // Printing the error if occurred    if(error) console.log(error)        // Printing status code    console.log(response.statusCode);          // Printing body    console.log(body);}); 
Steps to run the program:
The project structure will look like this:Make sure you have install express and request module using following commands:npm install requestnpm install expressRun index.js file using below command:node index.js
The project structure will look like this:
Make sure you have install express and request module using following commands:npm install requestnpm install express
npm install request
npm install express
Run index.js file using below command:node index.js
node index.js
So this is how you can use the request module for making HTTP calls. It is very simple and easy to use.
Node.js-Misc
Node.js
Web Technologies
Web technologies Questions
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js fs.writeFile() Method
How to install the previous version of node.js and npm ?
Difference between promise and async await in Node.js
Mongoose | findByIdAndUpdate() Function
Installation of Node.js on Windows
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Differences between Functional Components and Class Components in React
Generators in Dart

21 Jul, 2020
Generators in Dart allows the user to produce a sequence of value easily. One can generate a sequence of values in dart with the help of two generator functions :
Synchronous Generator: Returns an Iterable object.Asynchronous Generator: Returns a Stream object.
Synchronous Generator: Returns an Iterable object.
Asynchronous Generator: Returns a Stream object.
The synchronous generator returns an iterable object i.e. it returns the collection of values, or “elements”, that can be accessed sequentially. To implement synchronous generator function, mark the function body as sync*, and use yield statements to deliver value(s).
Example: Implementing a synchronous generator in Dart.
Dart
// sync* functions return an iterableIterable geeksForGeeks(int number) sync* {  int geek = number;  while (geek >= 0) {          // Checking for even number    if (geek % 2 == 0) {              // 'yield' suspends      // the function      yield geek;            }          // Decreasing the    // variable geek    geek--;  }}  // Main Functionvoid main() {   print("------- Geeks For Geeks --------");      print("Dart Synchronous Generator Example For Printing Even Numbers From 10 In        Reverse Order:");      // Printing positive even numbers  // from 10 in reverse order  geeksForGeeks(10).forEach(print);}
Output:
--------------------- Geeks For Geeks ---------------------
Dart Synchronous Generator Example For Printing Even Numbers From 10 In Reverse Order:
10
8
6
4
2
0

The asynchronous generator returns a stream object. A Stream provides a way to receive a sequence of events. Each event is either a data event, also called an element of the stream, or an error event, which is a notification that something has failed. To implement an asynchronous generator function, mark the function body as async*, and use yield statements to deliver value(s).
Example: Implementing an asynchronous generator in Dart.
Dart
// async* function(s) return an streamStream geeksForGeeks(int number) async* {  int geek = 0;      // Checking for every  // geek less than number  while (geek <= number) yield geek++;  // Incrementing geek  // after printing it}  // Main Functionvoid main() {   print("-------- Geeks For Geeks -----------");      print("Dart Asynchronous Generator Example For Printing Numbers Less Than 10:");      // Printing numbers less  // than or equal to 10  geeksForGeeks(10).forEach(print);}
 
Output:
--------------------- Geeks For Geeks ---------------------
Dart Asynchronous Generator Example For Printing Numbers Less Than 10:
0
1
2
3
4
5
6
7
8
9
10

Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Flutter - Custom Bottom Navigation Bar
ListView Class in Flutter
Flutter - Search Bar
Flutter - FutureBuilder Widget
Flutter - Flexible Widget
Flutter - Dialogs
Android Studio Setup for Flutter Development
Flutter - Pop Up Menu
Flutter - CircleAvatar Widget
Flutter - RichText Widget
Select Pandas dataframe rows between two dates

24 Feb, 2021
Prerequisites: pandas
Pandas is an open-source library that is built on top of NumPy library. It is a Python package that offers various data structures and operations for manipulating numerical data and time series. It is mainly popular for importing and analyzing data much easier. Pandas is fast and it has high-performance & productivity for users.
This article focuses on getting selected pandas data frame rows between two dates. We can do this by using a filter.
Dates can be represented initially in several ways :
string
np.datetime64
datetime.datetime
To manipulate dates in pandas, we use the pd.to_datetime() function in pandas to convert different date representations to datetime64[ns] format.
Syntax: pandas.to_datetime(arg, errors=’raise’, dayfirst=False, yearfirst=False, utc=None, box=True, format=None, exact=True, unit=None, infer_datetime_format=False, origin=’unix’, cache=False)
Parameters:
arg: An integer, string, float, list or dict object to convert in to Date time object.
dayfirst: Boolean value, places day first if True.
yearfirst: Boolean value, places year first if True.
utc: Boolean value, Returns time in UTC if True.
format: String input to tell position of day, month and year.
Import module
Create or load data
Create dataframe
Convert the dates column to datetime64[ns] data type
Define a start date and end date.
Use a filter to display the updated dataframe and store it.
Display dataframe
Example: Original dataframe
Python3
import pandas as pddata = {'Name': ['Tani', 'Saumya',                 'Ganesh', 'Kirti'],          'Articles': [5, 3, 4, 3],          'Location': ['Kanpur', 'Kolkata',                     'Kolkata', 'Bombay'],        'Dates': ['2020-08-04', '2020-08-07', '2020-08-08', '2020-06-08']}  # Create DataFramedf = pd.DataFrame(data)display(df)
Output:
Example: Selecting data frame rows between two rows
Python3
import pandas as pddata = {'Name': ['Tani', 'Saumya',                 'Ganesh', 'Kirti'],          'Articles': [5, 3, 4, 3],          'Location': ['Kanpur', 'Kolkata',                     'Kolkata', 'Bombay'],        'Dates': ['2020-08-04', '2020-08-07', '2020-08-08', '2020-06-08']}  # Create DataFramedf = pd.DataFrame(data)start_date = '2020-08-05'end_date = '2020-08-08'mask = (df['Dates'] > start_date) & (df['Dates'] <= end_date)  df = df.loc[mask]display(df)
Output:
Picked
Python pandas-dataFrame
Python Pandas-exercise
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
JavaScript Date now() Method

25 Nov, 2021
In this article, we will learn about the Date now() method in Javascript. The date.now() method is used to return the number of milliseconds elapsed since January 1, 1970, 00:00:00 UTC. Since now() is a static method of Date, it will always be used as Date.now(). 
Syntax:
var A = Date.now();
Parameters: This method does not accept any parameter. 
Return Values: It returns the number of milliseconds elapsed since January 1, 1970, 00:00:00 UTC.
Please refer to the JavaScript Get Date Methods article for other Date methods in detail.
More codes for the above method are as follows: 
Example 1: The below example illustrates the Date now() method.
Javascript
<script>   // Use of method Date.now()  var A = Date.now();   // Printing the number of millisecond elapsed  document.write("The time elapsed in millisecond is: " + A);</script>
Output:
The time elapsed in millisecond is: 1529644667834
Example 2: This example illustrates getting the current date using the Date.now() method.
Javascript
<script>   // Use of Date.now() method  var d = Date(Date.now());   // Converting the number of millisecond  // in date string  a = d.toString()   // Printing the current date                     document.write("The current date is: " + a)</script>
Output:
The current date is: Fri Jun 22 2018 10:54:33 
GMT+0530 (India Standard Time)
Example 3: The Date(Date.now()) is the same as Date(), so the same result can be achieved i.e, the current date using the following code.
Javascript
<script>  // Using Date() method  var d = Date();     // Converting the number value to string  a = d.toString()     // Printing the current date  document.write("The current date is: " + a)</script>
Output:
The current date is: Fri Jun 22 2018 11:02:01 
GMT+0530 (India Standard Time)
Supported Browsers: The browsers supported by JavaScript Date now() method are listed below:
Google Chrome 5 and above
Microsoft Edge 12 and above
Firefox 3 and above
Internet Explorer 9 and above
Opera 10.5 and above
Safari 4 and above
ysachin2314
bhaskargeeksforgeeks
javascript-date
JavaScript-Methods
JavaScript
Web Technologies
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
Hide or show elements in HTML using display property
Roadmap to Learn JavaScript For Beginners
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Java Program to Check Whether an Element Occurs in a List

07 Jan, 2021
The List Interface in Java represents an ordered collection or sequence. This Interface helps us control where to insert elements and also access elements through an integer index. This Interface is a member of the Java Collections Framework and the java.util package. The classes that implement the List Interface include ArrayList, LinkedList, Stack, and Vector. The Vector class has been deprecated since Java 5.
The classes, ArrayList, LinkedList, and Stack, all use the contains() method to check whether an element occurs in the List.
The contains() method of List interface in Java is used for checking if the specified element exists in the given list or not.
Syntax:
public boolean contains(Object obj)

object-element to be searched for
Parameters: This method accepts a single parameter obj whose presence in this list is to be tested.
Return Value: It returns true if the specified element is found in the list else it returns false.
Steps:
Import the necessary packages. In this case, we need to import the java.util package.Create an ArrayList with the help of the List Interface.Add elements to the ArrayList using the add() method.Check whether the required element occurs in the ArrayList with the help of the contains() method.
Import the necessary packages. In this case, we need to import the java.util package.
Create an ArrayList with the help of the List Interface.
Add elements to the ArrayList using the add() method.
Check whether the required element occurs in the ArrayList with the help of the contains() method.
Example:
Java
// Java program to check whether an element// is present in an ArrayList  // importing packageimport java.util.*;class GFG {    public static void main(String[] args)    {        // Creating an ArrayList of String type        List<String> GFG = new ArrayList<String>();          // Adding elements to the ArrayList        GFG.add("Welcome");        GFG.add("To");        GFG.add("Geeks");        GFG.add("For");        GFG.add("Geeks");          //  Using contains() method to check whether the        //  particular        // element is present in the List or not        System.out.println(GFG.contains("Welcome"));         System.out.println(GFG.contains("Java"));     }}
true
false
Java-Collections
java-list
Picked
Technical Scripter 2020
Java
Java Programs
Technical Scripter
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
java.net.URL Class in Java

28 Mar, 2021
URL is an acronym of Uniform resource locater. It is a pointer to locate resource in www (World Wide Web). A resource can be anything from a simple text file to any other like images, file directory etc. 
The typical URL may look like
http://www.example.com:80/index.html
The URL has the following parts:
Protocol: In this case the protocol is HTTP, It can be HTTPS in some cases
Hostname: Hostname represent the address of the machine on which resource is located, in this case, www.example.com
Port Number: It is an optional attribute. If not specified then it returns -1. In the above case, the port number is 80.
Resource name: It is the name of a resource located on the given server that we want to see
You can learn more about the URL here.
The Class structure of the URL is as shown below:
public final class java.net.URL extends java.lang.Object
The Following are constructors provided by the URL class.
Constructor
Explanation
Methods Provided by URL Class:
Demonstration 1
In this demonstration, we are going to create an object of URL class for a given String URL, and we are going to print hostname, protocol, filename and Port number for given URL.
Java
// importing package requiredimport java.net.URL;import java.util.Scanner;  class GFG {    public static void main(String[] args)    {        String url            = "https://www.geeksforgeeks.org/variables-in-java/";        // Calling method to get URL info        getUrlInfo(url);    }    static void getUrlInfo(String url_string)    {        // Creating object of URL class        try {            URL url = new URL(url_string);              System.out.println("Hostname: "                               + url.getHost());            System.out.println("Port Number: "                               + url.getPort());            System.out.println("File name: "                               + url.getFile());            System.out.println("Protocol:  "                               + url.getProtocol());        }        catch (Exception e) {        }    }}
Hostname: www.geeksforgeeks.org
Port Number: -1
File name: /variables-in-java/
Protocol:  https
Java-net-package
Java-URL
Picked
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
unordered_set bucket() function in C++ STL - GeeksforGeeks

28 Sep, 2018
The unordered_set::bucket() method is a builtin function in C++ STL which returns the bucket number of a specific element. That is, this function returns the bucket number where a specific element is stored in the unordered_set container.
The bucket is a slot in the unordered_set’s internal hash table where elements are stored.
Note: Buckets in unordered_set are numbered from 0 to n-1, where n is the total number of buckets.
Syntax:
unordered_set_name.bucket(element);

Parameter: This is a mandatory parameter and specifies the value of the element whose bucket number is needed to know in the unordered_set container.
Return Value: This function returns the bucket number of the bucket in the unordered_set container where the element with value element is stored.
Below programs illustrate the unordered_set::bucket() function:
// C++ program to illustrate the// unordered_set::bucket() function  #include <iostream>#include <unordered_set>  using namespace std;  int main(){      unordered_set<int> sampleSet;      // Inserting elements    sampleSet.insert(5);    sampleSet.insert(10);    sampleSet.insert(15);    sampleSet.insert(20);    sampleSet.insert(25);      for (auto itr = sampleSet.begin(); itr != sampleSet.end(); itr++) {        cout << "The Element " << (*itr) << " is present in the bucket: "             << sampleSet.bucket(*itr);        cout << endl;    }      return 0;}
The Element 25 is present in the bucket: 3
The Element 5 is present in the bucket: 5
The Element 10 is present in the bucket: 10
The Element 15 is present in the bucket: 4
The Element 20 is present in the bucket: 9

CPP-Functions
cpp-unordered_set
cpp-unordered_set-functions
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in C++
C++ Classes and Objects
Bitwise Operators in C/C++
Virtual Function in C++
Templates in C++ with Examples
Constructors in C++
Operator Overloading in C++
Socket Programming in C/C++
Object Oriented Programming in C++
Copy Constructor in C++
__closure__ magic function in Python - GeeksforGeeks

11 Oct, 2020
Almost everything in Python is an object, similarly function is an object too and all the function objects have a __closure__ attribute. __closure__ is a dunder/magic function i.e. methods having two underscores as prefix and suffix in the method name
A closure is a function object that remembers values in enclosing scopes even if they are not present in memory. The __closure__ attribute of a closure function returns a tuple of cell objects. This cell object also has an attribute called cell_contents, which returns returns the contents of the cell.
Syntax:
closure_function.__closure__
Example:
Python
# this is a nested functiondef gfg(raise_power_to):        def power(number):        return number ** raise_power_to     return power  raise_power_to_3 = gfg(3)print(raise_power_to_3.__closure__)  print(raise_power_to_3.__closure__[0].cell_contents)
Output:
(<cell at 0x7f34ba2725e0: int object at 0x7f34bde02720>,)
3
In the above example, the nested function power has __closure__ attribute associated with it and it returns a tuple of cell objects. The cell_contents attribute returns the value 3 as it was closed inside the cell object.
Python-Built-in-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python Classes and Objects
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
Defaultdict in Python
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()