code-rag-bench/online-tutorials huggingface dataset:
C Program to Check Whether a Number is Prime or not - GeeksforGeeks

17 Sep, 2021
Given a positive integer N. The task is to write a C program to check if the number is prime or not. 
Definition: 
A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The first few prime numbers are {2, 3, 5, 7, 11, ....}
The idea to solve this problem is to iterate through all the numbers starting from 2 to sqrt(N) using a for loop and for every number check if it divides N. If we find any number that divides, we return false. If we did not find any number between 2 and sqrt(N) which divides N then it means that N is prime and we will return True. Why did we choose sqrt(N)? The reason is that the smallest and greater than one factor of a number cannot be more than the sqrt of N. And we stop as soon as we find a factor. For example, if N is 49, the smallest factor is 7. For 15, smallest factor is 3.Below is the C program to check if a number is prime: 
C++
C
// C++ program to check if a// number is prime#include <iostream>#include <math.h>using namespace std; int main(){    int n, i, flag = 1;     // Ask user for input    cout <<"Enter a number: \n";     // Store input number in a variable    cin >> n ;     // Iterate from 2 to sqrt(n)    for (i = 2; i <= sqrt(n); i++) {         // If n is divisible by any number between        // 2 and n/2, it is not prime        if (n % i == 0) {            flag = 0;            break;        }    }     if (n <= 1)        flag = 0;     if (flag == 1) {        cout << n <<" is a prime number";    }    else {        cout << n <<" is not a prime number";    }     return 0;} // This code is contributed by shivanisinghss2110.
// C program to check if a// number is prime #include <math.h>#include <stdio.h>int main(){    int n, i, flag = 1;     // Ask user for input    printf("Enter a number: \n");     // Store input number in a variable    scanf("%d", &n);     // Iterate from 2 to sqrt(n)    for (i = 2; i <= sqrt(n); i++) {         // If n is divisible by any number between        // 2 and n/2, it is not prime        if (n % i == 0) {            flag = 0;            break;        }    }     if (n <= 1)        flag = 0;     if (flag == 1) {        printf("%d is a prime number", n);    }    else {        printf("%d is not a prime number", n);    }     return 0;}
Output: 
Enter a number: 11
11 is a prime number
Time Complexity: O(n1/2)
Auxiliary Space: O(1)
AkshatJain19
supriyoss18
neerajratnawat
harshitntiwari
subhammahato348
shivanisinghss2110
Prime Number
school-programming
C Programs
Prime Number
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
C Program to read contents of Whole File
Header files in C/C++ and its uses
Program to print ASCII Value of a character
How to return multiple values from a function in C or C++?
How to Append a Character to a String in C
C program to sort an array in ascending order
time() function in C
C Program to Swap two Numbers
Producer Consumer Problem in C
Program to find Prime Numbers Between given Interval
How to specify an alternate text for an image in HTML ?

09 Sep, 2020
The alternative text for an image is useful when the image not displayed/loaded. If the image is not loaded the its alternative text is displayed on the web page. Alternative text is the alternative information for an image.
Example 1: In this example, the image path contains the image so it will display the image.
HTML
<!DOCTYPE html> <html>   <head>     <title>         How to specify an alternate         text for an image?     </title> </head>   <body>     <h1 style="color:green;">GeeksforGeeks</h1>       <h2>        How to specify an alternate         text for an image?    </h2>       <img src= "https://media.geeksforgeeks.org/wp-content/uploads/20190506164011/logo3.png"        alt="GeeksforGeeks logo"> </body>   </html>
Output:
Example 2: In this example, the image path is not correct so it will display alternative text information.
HTML
<!DOCTYPE html> <html>   <head>     <title>         How to specify an alternate         text for an image?     </title> </head>   <body>     <h1 style="color:green;">GeeksforGeeks</h1>       <h2>        How to specify an alternate         text for an image?    </h2>       <img src= "geeks.png"        alt="GeeksforGeeks logo"> </body>   </html>
Output:
CSS-Misc
HTML-Misc
CSS
HTML
Web Technologies
Web technologies Questions
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
base64.b64decode() in Python

26 Mar, 2020
With the help of base64.b64decode() method, we can decode the binary string into normal form.
Syntax : base64.b64decode(b_string)
Return : Return the decoded string.
Example #1 :In this example we can see that by using base64.b64decode() method, we are able to get the decoded string which can be in binary form by using this method.
# import base64from base64 import b64decodefrom base64 import b64encode  s = b'GeeksForGeeks's = b64encode(s)# Using base64.b64decode() methodgfg = b64decode(s)  print(gfg)
Output :
b’GeeksForGeeks’
Example #2 :
# import base64from base64 import b64decodefrom base64 import b64encode  s = b'Hello World's = b64encode(s)# Using base64.b64decode() methodgfg = b64decode(s)  print(gfg)
Output :
b’Hello World’
Python base64-module
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Dart – Data Types

14 Jul, 2020
Like other languages (C, C++, Java), whenever a variable is created, each variable has an associated data type. In Dart language, there is the type of values that can be represented and manipulated in a programming language. The data type classification is as given below: 
1. Number: The number in Dart Programming is the data type that is used to hold the numeric value. Dart numbers can be classified as: 
The int data type is used to represent whole numbers.
The double data type is used to represent 64-bit floating-point numbers.
The num type is an inherited data type of the int and double types.
Dart
void main() {       // declare an integer   int num1 = 2;                       // declare a double value   double num2 = 1.5;       // print the values   print(num1);   print(num2);   var a1 = num.parse("1");     var b1 = num.parse("2.34");          var c1 = a1+b1;      print("Product = ${c1}"); }
 
Output: 
2
1.5
Product = 3.34

2. String: It used to represent a sequence of characters. It is a sequence of UTF-16 code units. The keyword string is used to represent string literals. String values are embedded in either single or double-quotes.  
Dart
void main() {        String string = 'Geeks''for''Geeks';     String str = 'Coding is ';     String str1 = 'Fun';     print (string);      print (str + str1);}
 
Output: 
GeeksforGeeks
Coding is Fun

3. Boolean: It represents Boolean values true and false. The keyword bool is used to represent a Boolean literal in DART.  
Dart
void main() {  String str = 'Coding is ';   String str1 = 'Fun';       bool val = (str==str1);  print (val);  }
 
Output: 
false

4. List: List data type is similar to arrays in other programming languages. A list is used to represent a collection of objects. It is an ordered group of objects.  
Dart
void main() {     List gfg = new List(3);     gfg[0] = 'Geeks';     gfg[1] = 'For';     gfg[2] = 'Geeks';         print(gfg);     print(gfg[0]); } 
 
Output:  
[Geeks, For, Geeks]
Geeks

5. Map: The Map object is a key and value pair. Keys and values on a map may be of any type. It is a dynamic collection.  
Dart
void main() {   Map gfg = new Map();   gfg['First'] = 'Geeks';   gfg['Second'] = 'For';   gfg['Third'] = 'Geeks';  print(gfg); }  
 
Output: 
{First: Geeks, Second: For, Third: Geeks}

Note: If the type of a variable is not specified, the variable’s type is dynamic. The dynamic keyword is used as a type annotation explicitly.
Dart Data-types
Dart-basics
Dart
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Flutter - DropDownButton Widget
Flutter - Custom Bottom Navigation Bar
Flutter - Row and Column Widgets
Flutter - Checkbox Widget
ListView Class in Flutter
Flutter - Stack Widget
Dart Tutorial
How to Append or Concatenate Strings in Dart?
Flutter - Search Bar
Container class in Flutter
What does built-in class attribute __name__ do  in Python?



This built-in attributes prints the name of the class, type, function, method, descriptor, or generator instance.
For example, if the python interpreter is running that module (the source file) as the main program, it sets the special __name__ variable to have a value "__main__". If this file is being imported from another module, __name__ will be set to the module's name.
The following code illustrates the use of __name__.
class Bar(object):
    def foo():

       """ This is an example of how a doc_string looks like.

          This string gives useful information about the function being defined.

            """

    pass

    print foo.__name__
print Bar.__name__
This gives the output
foo
Bar
Conversion of whole String to uppercase or lowercase using STL in C++

In this tutorial, we will be discussing a program to understand conversion of whole string to uppercase or lowercase using STL in C++.
To perform this transformation, C++ STL provides toupper() and tolower() functions to convert to uppercase and lowercase respectively.
 Live Demo
#include<bits/stdc++.h>
using namespace std;
int main(){
   string su = "Tutorials point";
   transform(su.begin(), su.end(), su.begin(), ::toupper);
   cout << su << endl;
   string sl = "Tutorials Point";
   transform(sl.begin(), sl.end(), sl.begin(), ::tolower);
   cout << sl << endl;
   return 0;
}
TUTORIALS POINT
tutorials point
Change every letter to next letter - JavaScript

We are required to write a JavaScript function that takes in a string and changes every letter of the string from the English alphabets to its succeeding element.
For example: If the string is −
const str = 'how are you';
Then the output should be −
const output = 'ipx bsf zpv'
Following is the code −
const str = 'how are you';
const isAlpha = code => (code >= 65 && code <= 90) || (code >= 97 && code
<= 122);
const isLast = code => code === 90 || code === 122;
const nextLetterString = str => {
   const strArr = str.split('');
   return strArr.reduce((acc, val) => {
      const code = val.charCodeAt(0);
      if(!isAlpha(code)){
         return acc+val;
      };
      if(isLast(code)){
         return acc+String.fromCharCode(code-25);
      };
      return acc+String.fromCharCode(code+1);
   }, '');
};
console.log(nextLetterString(str));
Following is the output in the console −
ipx bsf zpv
Updating Your Github Repository Using Python - Towards Data Science

At least twice a day I run the following commands:
>>>git fetch upstream master>>>git merge upstream/master -m 'Here we go again...again'>>>git push
At 10 words each time, run twice a day over the course of my 15 week bootcamp comes to 1500 words. To put that in perspective, that is the equivalent of three high quality blogs that I could be writing for you. Truly, something has to be done.
Git python creates a repo object that allows you to interact with either your own repositories or public repositories that your code is dependent on.
>>>pip3 install GitPython
The installation takes care to check the dependencies of the library for you. However, you should add your username and password to your git configuration.
You can simply place either of the following two code snippets at the top of your script to programmatically update your local repository.
If you want to update your code local repository from the remote origin, the code is simple:
However, if you want to update from a remote upstream repository, the code is a little bit different:
My previous article outlined how to make a command line tool using python. Let’s use that tutorial to build an “auto updater”.
>>>mv autoupdate.py autoupdate>>>chmod +x autoupdate>>>cp autoupdate ~/.local/bin/autoupdate>>>source ~/.zshrc>>>autoupdate
There we go, so much easier! New lecture? No problem. The New York Times updates their repository? My maps are updated next time I plot them.
Priority of process in Linux | nice value - GeeksforGeeks

01 Apr, 2018
The running instance of program is process, and each process needs space in RAM and CPU time to be executed, each process has its priority in which it is executed.
Now observe the below image and see column NI
top

Output:
top command output
The column NI represents nice value of a process. It’s value ranges from -20 to 20(on most unix like operating systems).
  -20                         20
most priority           least priority    
  process                  process

One important thing to note is nice value only controls CPU time assigned to process and not utilisation of memory and I/O devices.
nice and renice commandnice command is used to start a process with specified nice value, which renice command is used to alter priority of running process.
Usage of nice command :Now let’s assume the case that system has only 1GB of RAM and it’s working really slow, i.e. programs running on it(processes) are not responding quickly, in that case if you want to kill some of the processes, you need to start a terminal, if you start your bash shell normally, it will also produce lag but you can avoid this by starting the bash shell with high priority.
For example:
nice -n -5 bash

First observe output of top without setting nice value of any process in below image
nice value of top is 0
Now start a bash shell with nice value -5, if you see the highlighted line, the top command which is running on bash shell has nice value set to -5
nice value of bash shell is -5
Usage of renice command :To alter priority of running process, we use renice command.
renice value PID

value is new priority to be assignedPID is PID of process whose priority is to be changed
One thing to note is you can’t set high priority to any process without having root permissions though any normal user can set high priority to low priority of a process.
We will see one example of how you alter priority of process.
nice value of gnome terminal is 0
You can observe that nice value of process(PID = 2371) is 0, now let’s try to set the new priority of 5 to this process.
renice 5 2371

Output:
2371 (process ID) old priority 0, new priority 5

You can also see this priority using top command(see highlighted line in image).
process 2371 has nice value 5
linux-command
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ZIP command in Linux with examples
TCP Server-Client implementation in C
SORT command in Linux/Unix with examples
tar command in Linux with examples
curl command in Linux with Examples
Conditional Statements | Shell Script
'crontab' in Linux with Examples
diff command in Linux with examples
Tail command in Linux with examples
UDP Server-Client implementation in C
string.punctuation in Python - GeeksforGeeks

15 Oct, 2019
In Python3, string.punctuation is a pre-initialized string used as string constant. In Python, string.punctuation will give the all sets of punctuation.
Syntax : string.punctuation
Parameters : Doesn’t take any parameter, since it’s not a function.
Returns : Return all sets of punctuation.
Note : Make sure to import string library function inorder to use string.punctuation
Code #1 :
# import string library function import string     # Storing the sets of punctuation in variable result result = string.punctuation     # Printing the punctuation values print(result) 
Output :
!"#$%&'()*+, -./:;<=>?@[\]^_`{|}~

 Code #2 : Given code tests for punctuation.
# import string library function import string     # An input string.Sentence = "Hey, Geeks !, How are you?"  for i in Sentence:          # checking whether the char is punctuation.    if i in string.punctuation:                  # Printing the punctuation values         print("Punctuation: " + i)   
Output:
Punctuation:,
Punctuation: !
Punctuation:,
Punctuation: ?

shubham_singh
python-string
Python-string-functions
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Python String | replace()
*args and **kwargs in Python
Create a Pandas DataFrame from Lists
Convert integer to string in Python
Check if element exists in list in Python
sum() function in Python
Python | Numpy numpy.choose() - GeeksforGeeks

10 Apr, 2019
With the help of Numpy numpy.choose() method, we can select the elements from an multidimensional array by passing a parameter as an array which contain the index of row number to be selected. Output array having the same size as passed in the parameter.
Syntax : numpy.choose()
Return : Return an array of element choice
Example #1 :In this example we can see that with the help of numpy.choose() method we are able to extract an array of choices from multidimensional array.
# import the important module in pythonimport numpy as np             # make a matrix with numpygfg = [[1, 2, 3, 4], [3, 1, 5, 6]]             # applying numpy.choose() methodgeeks = np.choose([1, 0, 1, 0], gfg)       print(geeks)
array([3 2 5 4])

Example #2 :
# import the important module in pythonimport numpy as np             # make a matrix with numpygfg = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]             # applying numpy.choose() methodgeeks = np.choose([2, 0, 1], gfg)       print(geeks)
array([7 2 6])

Python numpy-arrayManipulation
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
How to drop one or multiple columns in Pandas Dataframe
Python Classes and Objects
Python | os.path.join() method
Python | Get unique values from a list
Create a directory in Python
Defaultdict in Python
Python | Pandas dataframe.groupby()
Python program to add two Octal numbers - GeeksforGeeks

26 Nov, 2020
Given two octal numbers, the task is to write a Python program to compute their sum.
Examples:
Input: a = "123", b = "456"
Output: 601

Input: a = "654", b = "321"
Output: 1175
Approach:
To add two octal values in python we will first convert them into decimal values then add them and then finally again convert them to an octal value. To convert the numbers we will make use of the oct() function. The oct() function is one of the built-in methods in Python3. The oct() method takes an integer and returns its octal representation in a string format. We will also use the int() function to convert the number to decimal form. The int() function in Python and Python3 converts a number in the given base to decimal.
Below are the implementations based on the above explanation:
Example 1:
Python3
# Python program to add two hexadecimal numbers.  # Driver code# Declaring the variablesa = "123"b = "456"  # Calculating octal value using functionsum = oct(int(a, 8) + int(b, 8))  # Printing resultprint(sum[2:])
Output:
601
 
Example 2:
Python3
# Python program to add two hexadecimal numbers.  # Driver code# Declaring the variablesa = "654"b = "321"  # Calculating octal value using functionsum = oct(int(a, 8) + int(b, 8))  # Printing resultprint(sum[2:])
Output:
1175
Numbers
Python
Python Programs
Numbers
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
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Split string into list of characters
Python | Convert a list to dictionary
How to print without newline in Python?
D3.js axis.tickValues() Function - GeeksforGeeks

07 Aug, 2020
The d3.axis.tickValues() Function in D3.js is used to generate ticks at specific values. This function returns the current tick values, which defaults to null.
Syntax:
axis.tickValues([values])
Parameters: This function accepts the following parameters.
values: This parameter is used for ticks rather than using the scale’s automatic tick generator
Return Value: This function returns ticks at specific values.
Note: The explicit tick values take precedent over the tick arguments set by axis.tickArguments.
Below programs illustrate the d3.axis.tickValues() function in D3.js:
Example 1:
<!DOCTYPE html> <html>   <head>     <title>         D3.js | D3.axis.tickValues() Function     </title>     <script type="text/javascript"        src="https://d3js.org/d3.v4.min.js">     </script>           <style>         svg text {             fill: green;             font: 15px sans-serif;             text-anchor: center;         }     </style> </head>   <body>     <script>         var width = 400, height = 400;         var svg = d3.select("body")             .append("svg")             .attr("width", width)             .attr("height", height);           var xscale = d3.scaleLinear()             .domain([0, 10])             .range([0, width - 60]);           var x_axis = d3.axisBottom(xscale)        .tickValues([2, 4, 6, 7]);           var xAxisTranslate = height / 2;           svg.append("g")             .attr("transform", "translate(50, "             + xAxisTranslate + ")")             .call(x_axis)     </script> </body> </html>
Output:
Example 2:
<!DOCTYPE html> <html>   <head>     <title>         D3.js | D3.axis.tickValues() Function     </title>     <script type="text/javascript"        src="https://d3js.org/d3.v4.min.js">     </script>           <style>         svg text {             fill: green;             font: 15px sans-serif;             text-anchor: center;         }     </style> </head>   <body>     <script>         var width = 400, height = 400;         var svg = d3.select("body")             .append("svg")             .attr("width", width)             .attr("height", height);           var yscale = d3.scaleLinear()             .domain([0, 1])             .range([height - 50, 0]);           var y_axis = d3.axisLeft()        .scale(yscale).tickValues([ 0, 0.5, 1]);             svg.append("g")             .attr("transform", "translate(100, 20)")             .call(y_axis)     </script></body> </html>
Output:
D3.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Remove elements from a JavaScript Array
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Factorial program in Java without using recursion.

Following is the required program.
Live Demo
public class Tester {
   static int factorial(int n) {
      if (n == 0)
         return 1;
      else
         return (n * factorial(n - 1));
   }
   public static void main(String args[]) {
      int i, fact = 1;
      int number = 5;
      fact = factorial(number);
      System.out.println(number + "! = " + fact);
   }
}
5! = 120
How to BIND all the packages in a collection COLLA to a plan PLANA?

The package is a database object which contains the SQL statements from DBRM in a DB2-optimized form.
The collection is a group of packages using which we can segregate the DB2 packages belonging to the different applications. For example, in a production environment for a Telecom company, we can have different collections for order handling, billing and customer service.
The package or group of packages (collections) are binded into a plan. A plan is an executable object which contains the DB2 access paths of all the SQL queries within it. We can bind a package into a plan directly or we can first generate a collection using package(s) and then bind it to a plan.
Using the below JCL step we can directly bind all the packages inside a collection using a single BIND command.
//BIND EXEC PGM=IKJEFT01
//STEPLIB DD DSN=DIS.TEST.LOADLIB,DISP=SHR
//SYSOUT DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(TB3)
BIND PLAN(PLANA) -
PKLIST(COLLA.*) -
/*
We can use BIND PLAN and PKLIST parameters for this purpose. The argument COLLA.* will take into account all the packages in collection COLLA and bind it to plan PLAN A.
C# Program to Check a Specified Type is a Value Type or Not - GeeksforGeeks

23 Nov, 2021
In C#, the value type represents a sequence of bits. It is not a class or an interface, it is referred to as a struct or enum(a special case of value type). So to check whether the specified type is Value Type or not we use the IsValueType property of the Type class. It is a read-only property. It will return true if the type is Value Type. Otherwise, it will return false. It will return true for enumeration but not return true for Enum type.
Syntax:
public bool IsValueType { get; }
Example 1:
C#
// C# program to check whether the specified// type is a value type or notusing System;using System.Reflection;  // Declare a structurestruct myStructure{          // Declaring a method     public static void display()    {        Console.WriteLine("Hello! GeeksforGeeks");    }}  // Declare a classpublic class Geeks{          // Declaring a method     public static void show()    {        Console.WriteLine("Hey! GeeksforGeeks");    }      }  public class GFG{      // Driver classpublic static void Main(string[] args){          // Checking the given type is a value type or not    // Using IsValueType Property    Console.WriteLine(typeof(myStructure).IsValueType);    Console.WriteLine(typeof(Geeks).IsValueType);}}
Output:
True
False
Example 2:
C#
// C# program to check whether the specified// type is a value type or notusing System;using System.Reflection;  // Declare a structurestruct myGFG{          // Declaring a method     public static void display()    {        Console.WriteLine("Welcome to GeeksforGeeks");    }}  public class GFG{      // Driver classpublic static void Main(string[] args){          // Checking the given type is a value type or not    // Using IsValueType Property    if (typeof(myGFG).IsValueType == true)    {        Console.WriteLine("The given type is value type");    }    else    {        Console.WriteLine("The given type is not a value type");    }}}
Output:
The given type is value type
Picked
C#
C# Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Extension Method in C#
HashSet in C# with Examples
Top 50 C# Interview Questions & Answers
C# | How to insert an element in an Array?
C# | Inheritance
Convert String to Character Array in C#
Socket Programming in C#
Program to Print a New Line in C#
Getting a Month Name Using Month Number in C#
Program to find absolute value of a given number
HTTP basic authentication URL with “@” in password.

We can do HTTP basic authentication URL with @ in password. We have to pass the credentials appended with the URL. The username and password must be added with the format − https://username:password@URL.
Let us make an attempt to handle the below browser authentication.
Once the User Name and Password are entered correctly and the OK button is clicked, we should be navigated to the actual page with the text Congratulations! You must have the proper credentials.
https://username:password@URL
https://admin:admin@the-internet.herokuapp.com/basic_auth
Here, the username and password value is admin.
URL is www.the-internet.herokuapp.com/basic_auth
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class BrwAuthnPopup{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver",
         "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String a = "admin";
      // appending username, password with URL
      String s = "https://" + a + ":" + a + "@" +
      "the-internet.herokuapp.com/basic_auth";
      driver.get(s);
      // identify text
      String m = driver.findElement(By.cssSelector("p")).getText();
      System.out.println("Text is: " + m);
      driver.close();
   }
}
Formatting day of week in EEEE format in Java

EEEEE format is used in Java Date to format day of week like Monday, Tuesday, Wednesday, etc. Let us use it −
// displaying day of week
SimpleDateFormat simpleformat = new SimpleDateFormat("EEEE");
String strDayofWeek = simpleformat.format(new Date());
System.out.println("Day of Week = "+strDayofWeek);
Above, we have used the SimpleDateFormat class, therefore the following package is imported −
import java.text.SimpleDateFormat;
The following is an example −
 Live Demo
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;
public class Demo {
   public static void main(String[] args) throws Exception {
      // displaying current date and time
      Calendar cal = Calendar.getInstance();
      SimpleDateFormat simpleformat = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z");
      System.out.println("Today's date and time = "+simpleformat.format(cal.getTime()));
      // displaying date
      simpleformat = new SimpleDateFormat("dd/MMMM/yyyy");
      String str = simpleformat.format(new Date());
      System.out.println("Current Date = "+str);
      // displaying day of week
      simpleformat = new SimpleDateFormat("EEEE");
      String strDayofWeek = simpleformat.format(new Date());
      System.out.println("Day of Week = "+strDayofWeek);
      // current time
      simpleformat = new SimpleDateFormat("HH.mm.ss Z");
      String strTime = simpleformat.format(new Date());
      System.out.println("Current Time = "+strTime);
   }
}
Today's date and time = Mon, 26 Nov 2018 09:40:25 +0000
Current Date = 26/November/2018
Day of Week = Monday
Current Time = 09.40.25 +0000
SQL - EXCEPT Clause

The SQL EXCEPT clause/operator is used to combine two SELECT statements and returns rows from the first SELECT statement that are not returned by the second SELECT statement. This means EXCEPT returns only rows, which are not available in the second SELECT statement.
Just as with the UNION operator, the same rules apply when using the EXCEPT operator. MySQL does not support the EXCEPT operator.
The basic syntax of EXCEPT is as follows.
SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]

EXCEPT

SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]

Here, the given condition could be any given expression based on your requirement.
Consider the following two tables.
Table 1 − CUSTOMERS Table is as follows.
+----+----------+-----+-----------+----------+
| ID | NAME     | AGE | ADDRESS   | SALARY   |
+----+----------+-----+-----------+----------+
|  1 | Ramesh   |  32 | Ahmedabad |  2000.00 |
|  2 | Khilan   |  25 | Delhi     |  1500.00 |
|  3 | kaushik  |  23 | Kota      |  2000.00 |
|  4 | Chaitali |  25 | Mumbai    |  6500.00 |
|  5 | Hardik   |  27 | Bhopal    |  8500.00 |
|  6 | Komal    |  22 | MP        |  4500.00 |
|  7 | Muffy    |  24 | Indore    | 10000.00 |
+----+----------+-----+-----------+----------+
Table 2 − ORDERS table is as follows.
+-----+---------------------+-------------+--------+
|OID  | DATE                | CUSTOMER_ID | AMOUNT |
+-----+---------------------+-------------+--------+
| 102 | 2009-10-08 00:00:00 |           3 |   3000 |
| 100 | 2009-10-08 00:00:00 |           3 |   1500 |
| 101 | 2009-11-20 00:00:00 |           2 |   1560 |
| 103 | 2008-05-20 00:00:00 |           4 |   2060 |
+-----+---------------------+-------------+--------+
Now, let us join these two tables in our SELECT statement as shown below.
SQL> SELECT  ID, NAME, AMOUNT, DATE
   FROM CUSTOMERS
   LEFT JOIN ORDERS
   ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID
EXCEPT
   SELECT  ID, NAME, AMOUNT, DATE
   FROM CUSTOMERS
   RIGHT JOIN ORDERS
   ON CUSTOMERS.ID = ORDERS.CUSTOMER_ID;
This would produce the following result.
+----+---------+--------+---------------------+
| ID | NAME    | AMOUNT | DATE                |
+----+---------+--------+---------------------+
|  1 | Ramesh  |   NULL | NULL                |
|  5 | Hardik  |   NULL | NULL                |
|  6 | Komal   |   NULL | NULL                |
|  7 | Muffy   |   NULL | NULL                |
+----+---------+--------+---------------------+


    42 Lectures 
     5 hours 

 Anadi Sharma

    14 Lectures 
     2 hours 

 Anadi Sharma

    44 Lectures 
     4.5 hours 

 Anadi Sharma

    94 Lectures 
     7 hours 

 Abhishek And Pukhraj

    80 Lectures 
     6.5 hours 

 Oracle Master Training | 150,000+ Students Worldwide

    31 Lectures 
     6 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
Tryit Editor v3.7

Tryit: Images without object-fit
Convert integer array to string array in JavaScript?

To convert integer array to string array, use the map(String) in JavaScript. Let’s say the following is our integer array −
var integerValues = [101,50,70,90,110,90,94,68];
Convert integer array to string array −
integerValues.map(String);
Following is the code −
var integerValues = [101,50,70,90,110,90,94,68];
console.log("The integer array value=");
console.log(integerValues);
integerValues.map(String);
console.log("The string array value=");
console.log(integerValues)
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo212.js.
The output is as follows in console −
PS C:\Users\Amit\JavaScript-code> node demo212.js
The integer array value=
[
   101, 50, 70, 90,
   110, 90, 94, 68
]
The string array value=
[
   101, 50, 70, 90,
   110, 90, 94, 68
]
json.loads() in Python - GeeksforGeeks

22 Jun, 2020
JSON stands for JavaScript Object Notation. It is a lightweight data-interchange format that is used to store and exchange data. It is a language-independent format and is very easy to understand since it is self-describing in nature. There is a built-in package in python that supports JSON data which is called as json. The data in JSON is represented as quoted-strings consisting of key-value mapping enclosed between curly brackets {}.
json.loads() method can be used to parse a valid JSON string and convert it into a Python Dictionary. It is mainly used for deserializing native string, byte, or byte array which consists of JSON data into Python Dictionary.
Syntax : json.loads(s)
Argument: it takes a string, bytes, or byte array instance which contains the JSON document as a parameter (s).
Return: It returns a Python object.
Example 1:Suppose the JSON string looks like this.
x = """{
    "Name": "Jennifer Smith",
    "Contact Number": 7867567898,
    "Email": "jen123@gmail.com",
    "Hobbies":["Reading", "Sketching", "Horse Riding"]
    }"""

In order to read the content of this string following implementation needs to be carried out:
import json  # JSON string:# Multi-line stringx = """{    "Name": "Jennifer Smith",    "Contact Number": 7867567898,    "Email": "jen123@gmail.com",    "Hobbies":["Reading", "Sketching", "Horse Riding"]    }"""  # parse x:y = json.loads(x)  # the result is a Python dictionary:print(y)
Output:
{‘Hobbies’: [‘Reading’, ‘Sketching’, ‘Horse Riding’], ‘Name’: ‘Jennifer Smith’, ‘Email’: ‘jen123@gmail.com’, ‘Contact Number’: 7867567898}
Here, the string x is parsed using json.loads() method which returns a dictionary.
Example 2:
import json     # JSON string employee ='{"id":"09", "name": "Nitin", "department":"Finance"}'    # Convert string to Python dict employee_dict = json.loads(employee) print(employee_dict)     print(employee_dict['name']) 
Output:
{'id': '09', 'department': 'Finance', 'name': 'Nitin'}
Nitin
Python-json
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Read a file line by line in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
Iterate over a list in Python
Python String | replace()
*args and **kwargs in Python
Reading and Writing to text files in Python
Create a Pandas DataFrame from Lists
JQuery | now() method - GeeksforGeeks

27 Apr, 2020
This now() Method in jQuery is used to return a number representing the current time.
Syntax:
jQuery.now()

Parameters: The now() method does not accept any parameter.
Return Value: It returns the number representing the current time.
Example 1: In this example, the now() Method a display the number of milliseconds with innerHTML function.
<!DOCTYPE html><html><head><meta charset="utf-8"><title>JQuery | now() method</title> <script src="https://code.jquery.com/jquery-3.4.1.js"></script>  </head><body style="text-align:center;">           <h1 style="color: green">         GeeksForGeeks     </h1>           <h3>JQuery | now() method</h3>    <button onclick="geek()">Try it</button>      <p id="demo"></p>          <script>    function geek() {      var n = jQuery.now();      document.getElementById("demo").innerHTML = n/3600;    }    </script></body></html>                                                                                            
Output:Before Click:After Click:
Example 2: In this example, the now() Method a display the number of milliseconds with alertfunction.
<!DOCTYPE html><html><head><meta charset="utf-8"><title>JQuery | now() method</title> <script src="https://code.jquery.com/jquery-3.4.1.js"></script>  </head><body style="text-align:center;">           <h1 style="color: green">         GeeksForGeeks     </h1>           <h3>JQuery | now() method</h3>    <button onclick="geek()">Try it</button>          <script>    function geek() {      var n = jQuery.now();      alert("Number of milliseconds : " + n);    }    </script></body></html>                                        
Output:Before Click:After Click:
jQuery-Methods
JQuery
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Show and Hide div elements using radio buttons?
How to prevent Body from scrolling when a modal is opened using jQuery ?
jQuery | ajax() Method
jQuery | removeAttr() with Examples
How to get the value in an input text box using jQuery ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Python String casefold() Method - GeeksforGeeks

03 May, 2022
Python String casefold() method is used to implement caseless string matching. It is similar to lower() string method but case removes all the case distinctions present in a string. i.e ignore cases when comparing. 
Syntax: 
string.casefold()
Parameters:
The casefold() method doesn’t take any parameters.
Return value:
It returns the case folded string the string converted to lower case.
Python3
# Python program to convert string in lower casestring = "GEEKSFORGEEKS" # print lowercase stringprint("lowercase string: ",string.casefold())
Output:
lowercase string: geeksforgeeks
Python3
# Program to check if a string#  is palindrome or not # change this value for a different outputstr = 'geeksforgeeks' # make it suitable for caseless comparisonstr = str.casefold() # reverse the stringrev_str = "".join(reversed(str))# check if the string is equal to its reverseif str == rev_str:      print("palindrome")else:      print("not palindrome")
Output:
not palindrome
Python3
# Program to count# the number of each# vowel in a string # string of vowelsv = 'aeiou' # change this value for a different resultstr = 'Hello, have you try geeksforgeeks?' # input from the user# str = input("Enter a string: ") # caseless comparisonstr = str.casefold() # make a dictionary with# each vowel a key and value 0c = {}.fromkeys(v,0) # count the vowelsfor char in str:          if char in c:                  c[char] += 1print(c)
Output:
{'a': 1, 'e': 6, 'i': 0, 'o': 3, 'u': 1}
Anamitra Musib
AmiyaRanjanRout
sroy84766
simmytarika5
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Python Dictionary
Read a file line by line in Python
Taking input in Python
How to Install PIP on Windows ?
Enumerate() in Python
Different ways to create Pandas Dataframe
C# SingleorDefault() Method

The method returns a single specific element of a sequence. If the element is not present in the sequence, then the default value is returned.
We have two string arrays here.
string[] str1 = { "one" };
string[] str2 = { };
First array is checked for a single element, whereas the second array is empty and checked using SingleorDefault.
str2.AsQueryable().SingleOrDefault();
The following is an example showing the usage of SingleorDefault() method.
 Live Demo
using System;
using System.Linq;
using System.Collections.Generic;
public class Demo {
   public static void Main() {
      string[] str1 = { "one" };
      string[] str2 = { };
      string res1 = str1.AsQueryable().Single();
      Console.WriteLine("String found: "+res1);
      string res2 = str2.AsQueryable().SingleOrDefault();
      Console.WriteLine(String.IsNullOrEmpty(res2) ? "String not found" : res2);
   }
}
String found: one
String not found
JavaTuples getKey() method

27 Aug, 2018
The getKey() method in org.javatuples is used to fetch the key from the TupleClassObject from the KeyValue Class. This method can be used with only KeyValue class object of javatuples library. It returns a Key which is the element present at the index 0 of the KeyValueClassObject. The returned Key is ensures the type-safety.
Method Declaration:
public A getKey()
Syntax:
KeyValue<A, B> KeyValueClassObject = KeyValue.with(A a, B b);
A val = KeyValueClassObject.getKey()
Return Value: This method returns a Key which is the element present at the index 0 of the KeyValueClassObject.
Below programs illustrate the various ways to use getKey() method:
Example 1:
// Below is a Java program to get// a KeyValue value  import java.util.*;import org.javatuples.KeyValue;  class GfG {    public static void main(String[] args)    {        // Creating a KeyValue object        KeyValue<Integer, String> kv            = KeyValue.with(Integer.valueOf(1),                            "GeeksforGeeks");          // Using getKey() method        int key = kv.getKey();          // Printing the Key        System.out.println(key);    }}
Output:
1

Example 2:
// Below is a Java program to get// a KeyValue value  import java.util.*;import org.javatuples.KeyValue;  class GfG {    public static void main(String[] args)    {        // Creating a KeyValue object        KeyValue<String, String> kv            = KeyValue.with("GeeksforGeeks",                            "A Computer Science Portal for Geeks");          // Using getKey() method        String key = kv.getKey();          // Printing the Key        System.out.println(key);    }}
Output:
GeeksforGeeks

Java-Functions
JavaTuples
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Program to print 2D shapes in C++

In this tutorial, we will be discussing a program to print out 2D shapes.
For this we will be provided with the various parameters required to make a shape such as radius, side length and side breadth, etc. And our task is to print a shape accordingly with no thickness.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
void print_circle(int radius){
   for (int i = 0; i <= 2 * radius; i++){
      for (int j = 0; j <= 2 * radius; j++){
         double distance = sqrt((double)(i - radius) * (i -
         radius) + (j - radius) * (j - radius));
         if (distance > radius - 0.5 &&
            distance < radius + 0.5)
            printf("*");
         else
         printf(" ");
      }
      printf("\n");
   }
}
void print_rectangle(int l, int b){
   int i, j;
   for (i = 1; i <= l; i++){
      for (j = 1; j <= b; j++)
         if (i == 1 || i == l || j == 1 || j == b)
            printf("*");
         else
            printf(" ");
         printf("\n");
   }
}
void print_triangle(int side){
   int i, j;
   for (i = 1; i <= side; i++){
      for (j = i; j < side; j++)
         printf(" ");
      for (j = 1; j <= (2 * i - 1); j++){
         if (i == side || j == 1 || j == (2 * i - 1))
            printf("*");
         else
            printf(" ");
      }
      printf("\n");
   }
}
void print_hexagon(int length){
   int l, j, i, k;
   for (i = 1, k = length, l = 2 * length - 1; i < length;
   i++, k--, l++){
      for (j = 0; j < 3 * length; j++)
         if (j >= k && j <= l)
            printf("*");
         else
            printf(" ");
            printf("\n");
      }
      for (i = 0, k = 1, l = 3 * length - 2; i < length; i++,
      k++, l--){
         for (j = 0; j < 3 * length; j++)
         if (j >= k && j <= l)
            printf("*");
         else
         printf(" ");
         printf("\n");
      }
   }
   void calc_pattern(int choice){
      int radius, length, breadth, side;
      switch (choice){
         case 1:
            radius = 4;
            print_circle(radius);
            break;
         case 2:
            length = 3, breadth = 8;
            print_rectangle(length, breadth);
            break;
         case 3:
            side = 6;
            print_triangle(side);
            break;
         case 4:
            side = 4;
            print_hexagon(side);
            break;
         default:
            printf("Invalid choice\n");
   }
}
int main(){
   int choice = 1;
   calc_pattern(choice);
   return 0;
}
      *****
     **  **
    **   **
  *        *
 *          *
 *          *
  **      **
   **    **
    *****
GATE | GATE-CS-2016 (Set 1) | Question 35

28 Jun, 2021
Which of the following is/are example(s) of stateful application layer protocols?
(i)  HTTP
(ii) FTP
(iii) TCP
(iv) POP3 
(A) (i) and (ii) only
(B) (ii) and (iii) only(C) (ii) and (iv) only(D) (iv) onlyAnswer: (C)Explanation: In computing, a stateless protocol is a communications protocol that treats each request as an independent transaction that is unrelated to any previous request so that the communication consists of independent pairs of request and response.
Examples of stateless protocols (IP) and (HTTP)
Source: https://en.wikipedia.org/wiki/Stateless_protocol
TCP is stateful as it maintains connection information across multiple transfers, but TCP is not an application layer protocol.
Of the given protocols, only FTP and POP3 are stateful application layer protocols. Quiz of this Question
GATE-CS-2016 (Set 1)
GATE-GATE-CS-2016 (Set 1)
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE-CS-2014-(Set-3) | Question 20
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE CS 2008 | Question 46
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE CS 1996 | Question 63
GATE | GATE CS 2008 | Question 40
GATE | GATE-CS-2014-(Set-1) | Question 51
GATE | GATE-CS-2001 | Question 50