code-rag-bench/online-tutorials huggingface dataset:
isocalendar() Function Of Datetime.date Class In Python

28 Jul, 2021
The isocalendar() function is used to return a tuple containing ISO Year, ISO Week Number, and ISO Weekday.
Note:
According to ISO standard 8601 and ISO standard 2015, Thursday is the middle day of a week.
Therefore, ISO years always start with Monday.
ISO years can have either 52 full weeks or 53 full weeks.
ISO years do not have any fractional weeks during the beginning of the year or at the end of the year.
Syntax: isocalendar()
Parameters: This function does not accept any parameter.
Return values: This function returns a tuple of ISO Year, ISO Week Number and ISO Weekday.
Example 1: Get  ISO Year, ISO Week Number, and ISO Weekday.
Python3
# Python3 code to demonstrate# Getting a tuple of ISO Year, # ISO Week Number and ISO Weekday  # Importing date module from datetimefrom datetime import date   # Calling the today() function# to return todays dateTodays_date = date.today()  # Printing today's dateprint(Todays_date)  # Calling the isocalendar() function# over the above today's date to return# its ISO Year, ISO Week Number# and ISO Weekdayprint(Todays_date.isocalendar())
Output:
2021-07-25
(2021, 29, 7)
Example 2:  Get ISO Year, ISO Week Number, and ISO Weekday with a specific date.
Python3
# Python3 code to demonstrate# Getting a tuple of ISO Year, # ISO Week Number and ISO Weekday  # Importing date module from datetimefrom datetime import date   # Creating an instance for # different datesA = date(2020, 10, 11)  # Calling the isocalendar() function# over the above specified dateDate = A.isocalendar()  # Printing Original date and its # ISO Year, ISO Week Number# and ISO Weekdayprint("Original date:",A)print("Date in isocalendar is:", Date)
Output:
Original date: 2020-10-11
Date in isocalendar is: (2020, 41, 7)
Picked
Python-datetime
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
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Python | datetime.timedelta() function
R program to find prime and composite numbers in an interval

03 Mar, 2021
A natural number (1, 2, 3, 4, 5 and so on) is called a prime number if it is greater than 1 and cannot be written as the product of two smaller natural numbers. The numbers greater than 1 that are not prime are called composite numbers.
A composite number is a positive integer that can be formed by multiplying two smaller positive integers. Equivalently, it is a positive integer that has at least one divisor other than 1 and itself.
Example:
Input: 2
Output: Prime
Explanation: it is divisible by only 2 so prime.
Input: 4 
Output: Composite
Explanation: it is divisible by 2 and 4 so composite.
Input: 5
Output: Prime
Explanation: it is divisible by only 5 so prime.
Algorithm:
Initialize the range till where prime and composite numbers to be displayed.
Create a separate empty lists to store prime and composite numbers.
Since 1 is neither prime nor composite,
We start checking condition for prime from 2 as i.
Starting from 2 checks each and every digit that divides i exactly
If No number divides i except that i then number gets stored in prime number list,
Else gets stored in composite number list.
It executes till n(given by us) limit reaches.
Once it exits from loop, it prints both prime and composite numbers as separate list.
Example:
R
# R code for Finding composite  and prime numbers  upto 100# initialize number nn=100  # arranging sequencex = seq(1, n)  # creating an empty place to store the numbersprime_numbers=c()  composite_numbers = c()for (i in seq(2, n)) {  if (any(x == i)) {      # prime numbers gets stored in a sequence order    prime_numbers = c(prime_numbers, i)    x = c(x[(x %% i) != 0], i)  }    else{       # composite numbers gets stored in a sequence order     composite_numbers = c(composite_numbers, i)  }}  # printing the seriesprint("prime_numbers")print(prime_numbers)  print("composite_numbers")print(composite_numbers)
Output:
[1] “prime_numbers”
 [1]  2  3  5  7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
[1] “composite_numbers”
 [1]   4   6   8   9  10  12  14  15  16  18  20  21  22  24  25  26  27  28  30
[20]  32  33  34  35  36  38  39  40  42  44  45  46  48  49  50  51  52  54  55
[39]  56  57  58  60  62  63  64  65  66  68  69  70  72  74  75  76  77  78  80
[58]  81  82  84  85  86  87  88  90  91  92  93  94  95  96  98  99 100
Prime Number
R Language
Prime Number
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?
How to filter R DataFrame by values in a column?
R - if statement
Logistic Regression in R Programming
Replace Specific Characters in String in R
How to import an Excel File into R ?
Joining of Dataframes in R Programming
Stack add(int, Object) method in Java with Example

24 Dec, 2018
The add(int, Object) method of Stack Class inserts an element at a specified index in the Stack. It shifts the element currently at that position (if any) and any subsequent elements to the right (will change their indices by adding one).
Syntax:
void add(int index, Object element)
Parameters: This method accepts two parameters as described below.
index: The index at which the specified element is to be inserted.
element: The element which is needed to be inserted.
Return Value: This method does not return any value.
Exception: The method throws IndexOutOfBoundsException if the specified index is out of range of the size of the Stack.
Below program illustrates the working of java.util.Stack.add(int index, Object element) method:
Example:
// Java code to illustrate boolean add(Object element)import java.util.*;  public class StackDemo {    public static void main(String args[])    {          // Creating an empty Stack        Stack<String> stack = new Stack<String>();          // Use add() method to add elements in the Stack        stack.add("Geeks");        stack.add("for");        stack.add("Geeks");        stack.add("10");        stack.add("20");          // Output the present Stack        System.out.println("The Stack is: " + stack);          // Adding new elements        stack.add(2, "Last");        stack.add(4, "Element");          // Printing the new Stack        System.out.println("The new Stack is: " + stack);    }}
The Stack is: [Geeks, for, Geeks, 10, 20]
The new Stack is: [Geeks, for, Last, Geeks, Element, 10, 20]

Example 2:
// Java code to illustrate// boolean add(Object element)  import java.util.*;  public class StackDemo {    public static void main(String args[])    {          // Creating an empty Stack        Stack<Integer> stack            = new Stack<Integer>();          // Use add() method        // to add elements in the Stack        stack.add(10);        stack.add(20);        stack.add(30);        stack.add(40);        stack.add(50);          // Output the present Stack        System.out.println("The Stack is: "                           + stack);          // Adding new elements        stack.add(0, 100);        stack.add(3, 200);          // Printing the new Stack        System.out.println("The new Stack is: "                           + stack);    }}
The Stack is: [10, 20, 30, 40, 50]
The new Stack is: [100, 10, 20, 200, 30, 40, 50]

Java - util package
Java-Collections
Java-Functions
Java-Stack
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Arrays in Java
Split() String method in Java with examples
Arrays.sort() in Java with examples
Reverse a string in Java
Object Oriented Programming (OOPs) Concept in Java
For-each loop in Java
How to iterate any Map in Java
Interfaces in Java
HashMap in Java with Examples
ArrayList in Java
\subseteq - Tex Command

\subseteq - Used to create subseteq symbol.
{ \subseteq}
\subseteq command draws subseteq symbol.
Oracle : ERP Software

07 Apr, 2021
An ERP system are the software tools that are used to manage Enterprise Data. ERP System helps various organizations to deal with supply chain, receiving, inventory management, production planning, finance/accounting, Human Resource Management and other business function.
Oracle ERP :Oracle Corporation was founded in the year of 1977, and it is the world’s largest software company and leading supplier for Enterprise Information Management. This is the first software company which implement internet computing model for using Enterprise software across entire product line.
It also provides database and relational services, application development tools and Enterprise Business Application.
History :
Oracle was founded in 1977 by Larry Ellison, Bob Miner and Ed Oates under the name of Software Development Laboratories. Initially they created Database by inspiring from IBM later on they started other services like providing Enterprise Software.
In 1995, they change their name to Oracle Corporation. Oracle corporation owned various ERP Companies like PeopleSoft, JD Edward, Ban ERP etc.
In 2012 Oracle shifted their ERP Software Solutions into Cloud basis. Now Oracle provide cloud based ERP Software. Oracle cloud based technology of providing ERP System had come in India in 2017.
Technology and Product :
Oracle Software runs on network computers, work station etc.
Oracle 8i is the leading database used for internet Enterprise Computing.
Oracle consist of 45 plus software Modules which is divided into following modules:
Oracle Financials –This module includes Account Payable, Account Receivable, Cash Management, Fixed Assets etc. 
Oracle Human Resource –The module of Oracle records basic demographic and address data, selection, training and development, capabilities and skills management, compensation planning records and other related activities. 
Distribution Module –This module includes sales management, purchase management, and warehouse management etc.Tools and Utilities : This includes server platform, database, Programming Language. 
Oracle Projects : This module includes –Project budget, project definition, project cost estimation, project planning etc. 
Oracle Manufacturing –This module consist of Cost price calculation, billing, Material Requirement planning etc. 
Oracle Supply Chain –This module deals with the supply of products to the consumer’s and various other components related to Supply Management.
Oracle Warehouse Technology Initiative is one of the fastest comprehensive program in data warehousing industry which provide Customers a complete data warehousing solution.
Oracle
Software Engineering
Oracle
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Software Engineering | Black box testing
Unit Testing | Software Testing
System Testing
Software Engineering | Integration Testing
Difference Between Edge Computing and Fog Computing
What is DFD(Data Flow Diagram)?
Software Engineering | Calculation of Function Point (FP)
Software Development Life Cycle (SDLC)
Software Processes in Software Engineering
Software Engineering | Testing Guidelines
Python | os.open() method

06 Sep, 2019
OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
os.open() method in Python is used to open a specified file path and set various flags according to the specified flags and its mode according to specified mode.This method returns a file descriptor for newly open file. The returned file descriptor is non-inheritable.
Syntax: os.open(path, flags, mode = 0o777, *, dir_fd = None)
Parameters:Path: A path-like object representing the file system path. This is the file path to be opened.A path-like object is a string or bytes object which represents a path.flags: This parameter specify the flags to be set for newly opened file.mode (optional): A numeric value representing the mode of the newly opened file. The default value of this parameter is 0o777 (octal).dir_fd (optional): A file descriptor referring to a directory.
Return Type: This method returns a file descriptor for newly opened file.
# Python program to explain os.open() method   # importing os module import os    # File path to be openedpath = './file9.txt'  # Mode to be set mode = 0o666  # flagsflags = os.O_RDWR | os.O_CREAT    # Open the specified file path# using os.open() method# and get the file descriptor for # opened file pathfd = os.open(path, flags, mode)  print("File path opened successfully.")    # Write a string to the file# using file descriptorstr = "GeeksforGeeks: A computer science portal for geeks."os.write(fd, str.encode())print("String written to the file descriptor.")     # Now read the file # from beginningos.lseek(fd, 0, 0)str = os.read(fd, os.path.getsize(fd))print("\nString read from the file descriptor:")print(str.decode())  # Close the file descriptoros.close(fd)print("\nFile descriptor closed successfully.")
File path opened successfully.
String written to the file descriptor.

String read from file descriptor:
GeeksforGeeks: A computer science portal for geeks.

File descriptor closed successfully.

Reference: https://docs.python.org/3/library/os.html#os.open
Akanksha_Rai
python-os-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python – Multiply all cross list element pairs

06 Mar, 2020
Sometimes, while working with Python list, we can have a problem in which we need to perform multiplication of each element of list with other list. This can have application in both web development and day-day programming. Lets discuss certain ways in which this task can be performed.
Method #1 : Using list comprehensionThis is the most straight forward method to perform this task. In this, we iterate the both the list and perform multiplication of each element with other and store result in new list.
# Python3 code to demonstrate # Multiply all cross list element pairs# using list comprehension  # Initializing liststest_list1 = [4, 5, 6]test_list2 = [6, 4, 2]  # printing original listsprint("The original list 1 is : " + str(test_list1))print("The original list 2 is : " + str(test_list2))  # Multiply all cross list element pairs# using list comprehensionres = [i * j for j in test_list1 for i in test_list2]              # printing result print ("The multiplication list is : " + str(res))
The original list 1 is : [4, 5, 6]
The original list 2 is : [6, 4, 2]
The multiplication list is : [24, 16, 8, 30, 20, 10, 36, 24, 12]

 
Method #2 : Using product()This is another way in which this task can be performed. In this, we perform the task of multiplication using product().
# Python3 code to demonstrate # Multiply all cross list element pairs# using product()from itertools import product  # Initializing liststest_list1 = [4, 5, 6]test_list2 = [6, 4, 2]  # printing original listsprint("The original list 1 is : " + str(test_list1))print("The original list 2 is : " + str(test_list2))  # Multiply all cross list element pairs# using product()res = [a * b for a, b in product(test_list1, test_list2)]              # printing result print ("The multiplication list is : " + str(res))
The original list 1 is : [4, 5, 6]
The original list 2 is : [6, 4, 2]
The multiplication list is : [24, 16, 8, 30, 20, 10, 36, 24, 12]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
PHPunit | assertEmpty() Function

31 Jul, 2019
The assertEmpty() function is a builtin function in PHPUnit and is used to assert whether the data holder specified is empty or not. This assertion will return true in the case if the data holder provided is empty else return false. In case of true the asserted test case got passed else test case got failed.
Syntax:
assertEmpty( mixed $dataHolder, string $message = '' )

Parameters: This function accepts two parameters as shown in the above syntax. The parameters are described below:
$dataHolder: This parameter is of any type which represent the data holder to be asserted.
$message: This parameter takes string value. When the testcase got failed this string message got displayed as error message.
Below programs illustrate the assertEmpty() function in PHPUnit:
Program 1:
<?phpuse PHPUnit\Framework\TestCase;  class GeeksPhpunitTestCase extends TestCase{    public function testNegativeTestcaseForAssertEmpty()    {        $dataHolder = 'test data';          // Assert function to test whether given        // data holder (variable) is empty or not        $this->assertEmpty(            $dataHolder,            "data holder is not empty"        );    }}  ?>
Output:
PHPUnit 8.2.5 by Sebastian Bergmann and contributors.

F                                                                   1 / 1 (100%)

Time: 69 ms, Memory: 10.00 MB

There was 1 failure:

1) GeeksPhpunitTestCase::testNegativeTestcaseForAssertEmpty
data holder is not empty
Failed asserting that a string is empty.

/home/shivam/Documents/geeks/phpunit/abc.php:13

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

Program 2:
<?phpuse PHPUnit\Framework\TestCase;  class GeeksPhpunitTestCase extends TestCase{    public function testPositiveTestcaseForAssertEmpty()    {        $dataHolder = '';          // Assert function to test whether given        // data holder (variable) is empty or not        $this->assertEmpty(            $dataHolder,            "data holder is not empty"        );    }}  ?>
Output:
PHPUnit 8.2.5 by Sebastian Bergmann and contributors.

.                                                                   1 / 1 (100%)

Time: 67 ms, Memory: 10.00 MB

OK (1 test, 1 assertion)

Note: To run testcases with phpunit follow steps from here. Also, assertEmpty() is supported by phpunit 7 and above.
PHP-function
PHP-PHPUnit
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Insert Form Data into Database using PHP ?
How to convert array to string in PHP ?
How to check whether an array is empty using PHP?
PHP | Converting string to Date and DateTime
Comparing two dates in PHP
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 ?
Python | Convert Numpy Arrays to Tuples

04 Oct, 2021
Given a numpy array, write a program to convert numpy array into tuples.Examples – 
Input: ([[1, 0, 0, 1, 0], [1, 2, 0, 0, 1]])
Output:  ((1, 0, 0, 1, 0), (1, 2, 0, 0, 1))

Input:  ([['manjeet', 'akshat'], ['nikhil', 'akash']])
Output:  (('manjeet', 'akshat'), ('nikhil', 'akash'))
 Given below are various methods to convert numpy array into tuples.Method #1: Using tuple and map 
Python3
# Python code to demonstrate# deletion of columns from numpy array import numpy as np # initialising numpy arrayini_array = np.array([['manjeet', 'akshat'], ['nikhil', 'akash']])                          # convert numpy arrays into tuplesresult = tuple(map(tuple, ini_array)) # print resultprint ("Resultant Array :"+str(result))
Output:  
Result:(('manjeet', 'akshat'), ('nikhil', 'akash'))
Method #2: Using Naive Approach  
Python3
# Python code to demonstrate# deletion of columns from numpy array import numpy as np # initialising numpy arrayini_array = np.array([['manjeet', 'akshat'], ['nikhil', 'akash']])                          # convert numpy arrays into tuplesresult = tuple([tuple(row) for row in ini_array]) # print resultprint ("Result:"+str(result))
Output: 
Result:(('manjeet', 'akshat'), ('nikhil', 'akash'))
anikakapoor
Python numpy-arrayManipulation
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python program to convert a list to string
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
How to write a Python regular expression to match multiple words anywhere?

The following code using Python regex matches the given multiple words in the given string
import re
s = "These are roses and lilies and orchids, but not marigolds or .."
r = re.compile(r'\broses\b | \bmarigolds\b | \borchids\b', flags=re.I | re.X)
print r.findall(s)
This gives the output
['roses', 'orchids', 'marigolds']
Java program to find smallest of the three numbers using ternary operators

The conditional operator is also known as the ternary operator. This operator consists of three operands and is used to evaluate Boolean expressions. The goal of the operator is to decide, which value should be assigned to the variable. The operator is written as −
variable x = (expression) ? value if true: value if false
Live Demo
public class SmallestOf3NumsUsingTernary {
   public static void main(String args[]) {
      int a, b, c, temp, result;
      a = 10;
      b = 20;
      c = 30;
      temp = a > b ? a:b;
      result = c > temp ? c:temp;
      System.out.println("Smallest number is ::"+result);
   }
}
Smallest number is ::10
Convert string to character array in Arduino

There are several libraries built for Arduino whose functions take in character arrays as inputs instead of strings. Thankfully, Arduino has an inbuilt method (toCharArray()) to covert a String to a Character Array. A sample implementation is given below −
void setup() {
   // put your setup code here, to run once:
   Serial.begin(9600);
   String s1 = "Hello World!";
   char buf[30];

   s1.toCharArray(buf,6);
   Serial.println(buf);

   s1.toCharArray(buf,s1.length());
   Serial.println(buf);
}
void loop() {
   // put your main code here, to run repeatedly:
}
As you can see, the toCharArray function takes in two arguments, the array in which the characters of the strings are to be stored, and the number of characters to convert. We are initially converting only the first 5 characters of the string to a char array. Please note that we have specified 6 as the length instead of 5, because the last character is reserved for the string termination character ('0'). Thus, if you want the string to contain N characters, enter N+1 in the length argument.
This means that the first print statement will print only "Hello". In the next attempt, the entire string will get printed, as we have specified the length argument to be equal to the length of the string. But, as you can notice from the output below, the exclamation mark (!) at the end is missing. Again, this is because ideally, we should have specified the length argument to be length of the string + 1. Make sure that you don't convert more characters than what your char array can store.
The Serial Monitor output is shown below −
How to get id from tr tag and display it in a new td with JavaScript?

Let’s say the following is our table −
<table>
   <tr id='StudentDetails'>
      <th>StudentName</th>
      <th>StudentCountryName</th>
   </tr>
   <tr id='FirstRow'>
      <td>JohnDoe</td>
      <td>UK</td>
   </tr>
   <tr id='SecondRow'>
      <td>DavidMiller</td>
      <td>US</td>
   </tr>
</table>
To get id from tr tag and display it in a new td, use document.querySelectorAll(table tr).
Following is the code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Document</title>
</head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<style>
   td,
   th,
   table {
      border: 1px solid black;
      margin-left: 10px;
      margin-top: 10px;
   }
</style>
<body>
   <table>
      <tr id='StudentDetails'>
         <th>StudentName</th>
         <th>StudentCountryName</th>
      </tr>
      <tr id='FirstRow'>
         <td>JohnDoe</td>
         <td>UK</td>
      </tr>
      <tr id='SecondRow'>
         <td>DavidMiller</td>
         <td>US</td>
      </tr>
   </table>
</body>
<script>
   document.querySelectorAll('table tr').forEach(trObj => {
      var tableValue = trObj.insertCell(0);
      tableValue.textContent = trObj.id;
   });
</script> 
</html>
To run the above program, save the file name “anyName.html(index.html)”. Right click on the file and select the option “Open with Live Server” in VS Code editor.
This will produce the following output on console −
JavaScript location.host vs location.hostname - GeeksforGeeks

25 Jul, 2021
In this article, we will learn about how to get information related to the webpage like hostname, port number, etc. We will also see the difference between the location.hostname and location.host.
location object is used to get information about the current web page. host and hostname are properties of location objects.
location.hostname: This property will return the domain name of the web page.
Syntax:
location.hostname
Return value: It returns a string representing the domain name or IP address.
Example:
If this is our URL,https://www.geeksforgeeks.org:8080/ds/heap
If this is our URL,
https://www.geeksforgeeks.org:8080/ds/heap
When we call location.hostname, This will return.www.geeksforgeeks.org
When we call location.hostname, This will return.
www.geeksforgeeks.org
HTML
<!DOCTYPE html><html lang="en">  <head>          <!-- using jquery library -->    <script src="https://code.jquery.com/jquery-git.js">    </script>  </head>    <body>    <script>      document.write("hostname : " + location.hostname);    </script>  </body></html>
Output:
In order to verify this thing for any webpage, open the webpage you want, then click on inspect and then write console.log(location.hostname) in the console tab. You will get the domain name of the webpage.
location.host: This property also returns the same hostname but it also includes the port number. In case, if the port number is not available, then it will just return the hostname.
Syntax: 
location.host
Return value: It returns a string representing the domain name and port number.
Example: 
If this is our URL,https://www.geeksforgeeks.org:8080/ds/heap
If this is our URL,
https://www.geeksforgeeks.org:8080/ds/heap
When we call location.host, This will return.www.geeksforgeeks.org:8080
When we call location.host, This will return.
www.geeksforgeeks.org:8080
HTML
<!DOCTYPE html><html lang="en">  <head>    <!-- using jquery library -->    <script src="https://code.jquery.com/jquery-git.js">    </script>  </head>    <body>    <script>      document.write("host : " + location.host);    </script>  </body></html>
Output:
JavaScript-Properties
JavaScript-Questions
Picked
Difference Between
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
Difference Between Method Overloading and Method Overriding in Java
Difference between Prim's and Kruskal's algorithm for MST
Difference between Internal and External fragmentation
Difference between Compile-time and Run-time Polymorphism in Java
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
How to calculate the number of days between two dates in javascript?
Differences between Functional Components and Class Components in React
SQL Query for Matching Multiple Values in the Same Column

29 Oct, 2021
In SQL, for  matching multiple values in the same column, we need to use some special words in our query. Below, 3 methods are demonstrated to achieve this using the IN, LIKE and comparison operator(>=). For this article, we will be using the Microsoft SQL Server as our database.
Step 1: Create a Database. For this use the below command to create a database named GeeksForGeeks.
Query:
CREATE DATABASE GeeksForGeeks
Output:
Step 2: Use the GeeksForGeeks database. For this use the below command.
Query:
USE GeeksForGeeks
Output:
Step 3: Create a table CARS inside the database GeeksForGeeks. This table has 3 columns namely CAR_NAME, COMPANY and COST containing the name, company and cost of various cars.
Query:
CREATE TABLE CARS(
CAR_NAME VARCHAR(10),
COMPANY VARCHAR(10),
COST INT);
Output:
Step 4: Describe the structure of the table CARS.
Query:
EXEC SP_COLUMNS CARS;
Output:
Step 5: Insert 5 rows into the CARS table.
Query:
INSERT INTO CARS VALUES('INNOVA','TOYOTA',10000);
INSERT INTO CARS VALUES('CAMRY','TOYOTA',20000);
INSERT INTO CARS VALUES('CIAZ','HONDA',30000);
INSERT INTO CARS VALUES('POLO','VOLKSWAGEN',50000);
INSERT INTO CARS VALUES('BENZ','MERCEDES',100000);
Output:
Step 6: Display all the rows of the CARS table.
Query:
SELECT * FROM CARS;
Output:
Step 7: Retrieve the details of all the cars belonging to the companies TOYOTA and HONDA.
Note – Use of IN for matching multiple values i.e. TOYOTA and HONDA in the same column i.e. COMPANY.
Syntax:
SELECT * FROM TABLE_NAME WHERE COLUMN_NAME IN (MATCHING_VALUE1,MATCHING_VALUE2);
Query:
SELECT * FROM CARS WHERE COMPANY IN ('TOYOTA','HONDA');
Output:
Step 8: Retrieve the details of all the cars whose name starts with the letter C.
Note – Use of LIKE for matching multiple values i.e. CAMRY and CIAZ in the same column i.e. CAR_NAME.
Syntax:
SELECT * FROM TABLE_NAME WHERE COLUMN_NAME LIKE 'STARTING_LETTER%';
Query:
SELECT * FROM CARS WHERE CAR_NAME LIKE 'C%';
Output:
Step 9: Retrieve the details of all the cars having cost greater than or equal to 30000.
Note – Use of comparison operator >= for matching multiple values i.e. 30000, 50000 and 100000 in the same column i.e. COST.
Syntax:
SELECT * FROM TABLE_NAME WHERE COLUMN_NAME >=VALUE;
Query:
SELECT * FROM CARS WHERE COST>=30000;
Output:
DBMS-SQL
Picked
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Update Multiple Columns in Single Update Statement in SQL?
SQL Interview Questions
SQL | Views
Difference between DELETE, DROP and TRUNCATE
MySQL | Group_CONCAT() Function
Window functions in SQL
SQL | GROUP BY
Difference between DDL and DML in DBMS
Difference between DELETE and TRUNCATE
SQL Correlated Subqueries
Set contains() method in Java with Examples

31 Dec, 2018
The Java.util.Set.contains() method is used to check whether a specific element is present in the Set or not. So basically it is used to check if a Set contains any particular element.
Syntax:
boolean contains(Object element)
Parameters: The parameter element is of the type of Set. This is the element that needs to be tested if it is present in the set or not.
Return Value: The method returns true if the element is present in the set else return False.
Below program illustrate the Java.util.Set.contains() method:
// Java code to illustrate Set.contains() methodimport java.io.*;import java.util.*;  public class HashSetDemo {    public static void main(String args[])    {        // Creating an empty Set        Set<String> set = new HashSet<String>();          // Using add() method to add elements into the Set        set.add("Welcome");        set.add("To");        set.add("Geeks");        set.add("4");        set.add("Geeks");          // Displaying the Set        System.out.println("Set: " + set);          // Check for "Geeks" in the set        System.out.println("Does the Set contains 'Geeks'? "                           + set.contains("Geeks"));          // Check for "4" in the set        System.out.println("Does the Set contains '4'? "                           + set.contains("4"));          // Check if the Set contains "No"        System.out.println("Does the Set contains 'No'? "                           + set.contains("No"));    }}
Set: [4, Geeks, Welcome, To]
Does the Set contains 'Geeks'? true
Does the Set contains '4'? true
Does the Set contains 'No'? false

Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Set.html#contains(java.lang.Object)
Java-Collections
Java-Functions
java-set
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Interfaces in Java
Queue Interface In Java
How to add an element to an Array in Java?
Multidimensional Arrays in Java
Math pow() method in Java with Example
PriorityQueue in Java
Stack Class in Java
List Interface in Java with Examples
ArrayList in Java
Different ways of Reading a text file in Java
Scala Set exists() method with example

18 Oct, 2019
The exists() method is utilized to test whether a predicate holds for some of the elements of the set or not.
Method Definition: def exists(p: (A) => Boolean): Boolean
Return Type: It returns true if the stated predicate holds true for some elements of the set else it returns false.
Example #1:
// Scala program of exists() // method   // Creating object object GfG {       // Main method     def main(args:Array[String])     {         // Creating a list         val s1 = Set(1, 2, 3, 4, 5)                   // Applying exists method         val result = s1.exists(y => {y % 3 == 0})                   // Displays output         println(result)               } } 
true

Example #2:
// Scala program of exists() // method   // Creating object object GfG {       // Main method     def main(args:Array[String])     {         // Creating a list         val s1 = Set(1, 2, 3, 4, 5)                   // Applying exists method         val result = s1.exists(y => {y % 7 == 0})                   // Displays output         println(result)               } } 
false

Scala
scala-collection
Scala-Method
Scala-Set
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to replace missing values with median in an R data frame column?

To replace missing values with median, we can use the same trick that is used to replace missing values with mean. For example, if we have a data frame df that contain columns x and y where both of the columns contains some missing values then the missing values can be replaced with median as dfx[is.na(dfx)]<-median(dfx,na.rm=TRUE)forxandforywecandothesameasdfy[is.na(dfy)]<−median(dfy,na.rm=TRUE).
 Live Demo
Consider the below data frame −
set.seed(1112)
x1<-LETTERS[1:20]
x2<-sample(c(NA,rpois(19,8)),20,replace=TRUE)
df1<-data.frame(x1,x2)
df1
 x1 x2
1 A 10
2 B 11
3 C 8
4 D 6
5 E 6
6 F NA
7 G 10
8 H 8
9 I 8
10 J 7
11 K NA
12 L 12
13 M 7
14 N 6
15 O 10
16 P 7
17 Q 7
18 R 8
19 S 11
20 T 4
median(df1$x2)
[1] 8
Replacing missing values in x2 with median of the remaining values −
df1$x2[is.na(df1$x2)]<-median(df1$x2,na.rm=TRUE)
df1
x1 x2
1 A 10
2 B 11
3 C 8
4 D 6
5 E 6
6 F 8
7 G 10
8 H 8
9 I 8
10 J 7
11 K 8
12 L 12
13 M 7
14 N 6
15 O 10
16 P 7
17 Q 7
18 R 8
19 S 11
20 T 4
Let’s have a look at another example −
ID<-1:20 Ratings<-sample(c(NA,1,2,3,4,5),20,replace=TRUE) df2<-data.frame(ID,Ratings) df2
ID Ratings
1 1 3
2 2 1
3 3 1
4 4 4
5 5 1
6 6 4
7 7 2
8 8 3
9 9 2
10 10 2
11 11 3
12 12 5
13 13 5
14 14 1
15 15 4
16 16 1
17 17 4
18 18 NA
19 19 1
20 20 NA
median(df2$Ratings,na.rm=TRUE)
[1] 2.5
Replacing missing values in Ratings with median of the remaining values −
df2$Ratings[is.na(df2$Ratings)]<-median(df2$Ratings,na.rm=TRUE)
df2
ID Ratings
1 1 3.0
2 2 1.0
3 3 1.0
4 4 4.0
5 5 1.0
6 6 4.0
7 7 2.0
8 8 3.0
9 9 2.0
10 10 2.0
11 11 3.0
12 12 5.0
13 13 5.0
14 14 1.0
15 15 4.0
16 16 1.0
17 17 4.0
18 18 2.5
19 19 1.0
20 20 2.5
Node.js urlSearchParams.get() Method

07 Oct, 2021
The urlSearchParams.get() method is an inbuilt application programming interface of class URLSearchParams within url module which is used to get the value for particular name entry present in the URL search params object.
Syntax:
const urlSearchParams.get( name )
Parameter: This method takes the name as a parameter.
Return value: This method returns the value for particular name entry present in the url search params object.
Below programs illustrates the use of urlSearchParams.get() method in Node.js:
Example 1: Filename: app.js
// Node.js program to demonstrate the // URLSearchParams.get() method   // Importing the module 'url'const http = require('url');  // Creating and initializing // URLSearchParams objectconst params = new URLSearchParams();  // Appending value in the objectparams.append('A', 'Book');params.append('B', 'Pen');params.append('C', 'Pencile');  // Getting the value for entry 'A'// by using get() apiconst value = params.get('A');  // Display the resultconsole.log("value for A is " + value);
Run app.js file using the following command:
node app.js
Output:
value for A is Book

Example 2: Filename: app.js
// Node.js program to demonstrate the // URLSearchParams.get() method    // Importing the module 'url'const http = require('url');  // Creating and initializing// URLSearchParams objectconst params = new URLSearchParams();  // Appending value in the objectparams.append('A', 'Book');params.append('B', 'Pen');params.append('C', 'Pencile');  // Getting the value for entry 'A'// by using get() apiconst value = params.get('a');  // Display the resultconsole.log("value for a is " + value);
Run app.js file using the following command:
node app.js
Output:
value for a is null

Reference: https://nodejs.org/dist/latest-v14.x/docs/api/url.html#url_urlsearchparams_get_name
Node-URL
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Node.js and React.js
JWT Authentication with Node.js
How to connect Node.js with React.js ?
Node.js fs.existsSync() Method
Express.js express.urlencoded() Function
How to insert spaces/tabs in text using HTML/CSS?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to create footer to stay at the bottom of a Web page?
How to set the default value for an HTML <select> element ?
How do you run JavaScript script through the Terminal?
Authentication using Python requests

05 Mar, 2020
Authentication refers to giving a user permissions to access a particular resource. Since, everyone can’t be allowed to access data from every URL, one would require authentication primarily. To achieve this authentication, typically one provides authentication data through Authorization header or a custom header defined by server.
Example –
# import requests moduleimport requestsfrom requests.auth import HTTPBasicAuth  # Making a get requestresponse = requests.get('https://api.github.com / user, ',            auth = HTTPBasicAuth('user', 'pass'))  # print request objectprint(response)
Replace “user” and “pass” with your username and password. It will authenticate the request and return a response 200 or else it will return error 403.If you an invalid username or password, it will return an error as –
Digest AuthenticationAnother very popular form of HTTP Authentication is Digest Authentication, and Requests supports this out of the box as well:
>>> from requests.auth import HTTPDigestAuth
>>> url = 'https://httpbin.org/digest-auth/auth/user/pass'
>>> requests.get(url, auth=HTTPDigestAuth('user', 'pass'))

OAuth 1 AuthenticationA common form of authentication for several web APIs is OAuth. The requests-oauthlib library allows Requests users to easily make OAuth 1 authenticated requests:
>>> import requests
>>> from requests_oauthlib import OAuth1

>>> url = 'https://api.twitter.com/1.1/account/verify_credentials.json'
>>> auth = OAuth1('YOUR_APP_KEY', 'YOUR_APP_SECRET',
...               'USER_OAUTH_TOKEN', 'USER_OAUTH_TOKEN_SECRET')

>>> requests.get(url, auth=auth)

For more information on how to OAuth flow works, please see the official OAuth website. For examples and documentation on requests-oauthlib, please see the requests_oauthlib repository on GitHub
OAuth 2 and OpenID Connect AuthenticationThe requests-oauthlib library also handles OAuth 2, the authentication mechanism underpinning OpenID Connect. See the requests-oauthlib OAuth2 documentation for details of the various OAuth 2 credential management flows:
Web Application Flow
Mobile Application Flow
Legacy Application Flow
Backend Application Flow
Other AuthenticationRequests is designed to allow other forms of authentication to be easily and quickly plugged in. Members of the open-source community frequently write authentication handlers for more complicated or less commonly-used forms of authentication. Some of the best have been brought together under the Requests organization, including:
Kerberos
NTLM.
If you want to use any of these forms of authentication, go straight to their GitHub page and follow the instructions.
Python-requests
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to create Pandas Dataframe
Enumerate() in Python
Python String | replace()
How to Install PIP on Windows ?
*args and **kwargs in Python
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Convert integer to string in Python
How to drop one or multiple columns in Pandas Dataframe
JavaScript | Window print() Method

22 Nov, 2021
Page print in JavaScript is a simple code in JavaScript used to print the content of the web pages.  
The print() method prints the contents of the current window.
It basically opens Print dialog box which lets you choose between various printing options.
Syntax:  
window.print()
Parameters: No parameters required Returns: This function do not return anythingThe following Javascript code shows a print button and then it shows the property of that webpage in a sheet in which you are going to print it. The JavaScript print function window.print() is used here to perform the functionality. Example :  
HTML
<!DOCTYPE html><html> <head>    <title>        HTML | DOM Window Print() method    </title>     <script type="text/javascript">    </script> </head> <body>     <h2>HI GEEKSFORGEEKS USER'S</h2>    <form>        <input type="button" value="Print"               onclick="window.print()" />    </form> </body><html>
Output : 
But the web pages are not limited to text only. There are other things too in the webpages like images consisting of different colors, etc. Printing such pages can be done by the following ways :  
Make a copy of the page and leave out unwanted text and graphics, then link that to the printer-friendly page from the original. This means that the whole page will be printed as you have seen the page it will be printed as it is without any change in it, if you will see an advertisement it will also be printed in it
If you do not want to keep an extra copy of a page, then you can mark your printable text using proper comments like PRINT STARTS HERE ..... PRINT ENDS HERE and then you can use PERL or any other script in the background to purge printable text and display for final printing. This means that the selected portion will be printed
Supported Browser: The browser supported by Window print() Method are listed below:  
Google Chrome 1 and above
Internet Explorer 5 and above
Firefox 1 and above
Opera 6 and above
Safari 1.1 and above
 
ysachin2314
javascript-functions
JavaScript-Misc
Web technologies
JavaScript
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Calendar getInstance() Method in Java with Examples

18 Feb, 2019
The getInstance() method in Calendar class is used to get a calendar using the current time zone and locale of the system.
Syntax:
public static Calendar getInstance()
Parameters: The method does not take any parameters.
Return Value: The method returns the calendar.
Below program illustrates the working of getInstance() Method of Calendar class:Example:
// Java code to illustrate// getGreatestMinimum() method  import java.util.*;public class Java_Calendar_Demo {    public static void main(String args[])    {        // Creating a calendar        Calendar calndr = Calendar.getInstance();          // Display the date and time        System.out.print("The system"                         + " date and time is: " + calndr.getTime());    }}
Reference: https://docs.oracle.com/javase/7/docs/api/java/util/Calendar.html#getInstance()
Java-Calendar
Java-Functions
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
Stream In Java
ArrayList in Java
Collections in Java
Singleton Class in Java
Multidimensional Arrays in Java
Set in Java
BinaryOperator Interface in Java

The BinaryOperator interface represents an operation upon two operands of the same type, producing a result of the same type as the operands.
Following are the methods −
Let us now see an example −
 Live Demo
import java.util.function.BinaryOperator;
public class Demo {
   public static void main(String args[])   {
      BinaryOperator<Integer>
      operator = BinaryOperator
      .maxBy(
      (x, y) -> (x > y) ? 1 : ((x == y) ? 0 : -1));
      System.out.println(operator.apply(120, 5));
   }
}
This will produce the following output −
120
Let us now see another example −
 Live Demo
import java.util.function.BinaryOperator;
public class Demo {
   public static void main(String args[]) {
      BinaryOperator<Integer> operator = (x, y) -> x * y;
      System.out.println(operator.apply(5, 7));
   }
}
This will produce the following output −
35
Adding extra axis ticks using Matplotlib

To add extra ticks in matplotlib, we can take the following Steps −
Create x and y points using numpy.
Create x and y points using numpy.
Plot x and y points over the plot, where x ticks could be from 1 to 10 (100 data points) on the curve.
Plot x and y points over the plot, where x ticks could be from 1 to 10 (100 data points) on the curve.
To add extra ticks, use xticks() method and increase the range of ticks to 1 to 20 from 1 to 10.
To add extra ticks, use xticks() method and increase the range of ticks to 1 to 20 from 1 to 10.
To display the figure, use the show() method.
To display the figure, use the show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
x = np.linspace(1, 10, 100)
y = np.sin(x)
plt.plot(x, y)
plt.xticks(range(1, 20))
plt.show()