code-rag-bench/online-tutorials huggingface dataset:
Python String find() method

08 Jul, 2022
Python String find() method returns the lowest index or first occurrence of the substring if it is found in a given string. If it is not found then it returns -1. 
Syntax:
str.find(sub, start, end)
Parameters: 
sub: It is the substring that needs to be searched in the given string. 
start: Starting position where the substring needs to be checked within the string. 
end: End position is the index of the last value for the specified range. It is excluded while checking. 
Note #1: If start and end indexes are not provided then by default it takes 0 and length-1 as starting and ending indexes where ending indexes are not included in our search. 
Returns: 
Returns the lowest index of the substring if it is found in a given string. If it’s not found then it returns -1.
Note #2: The find() method is similar to index(). The only difference is find() returns -1 if the searched string is not found and index() throws an exception in this case.
Python3
word = 'geeks for geeks'  # returns first occurrence of Substringresult = word.find('geeks')print("Substring 'geeks' found at index:", result)  result = word.find('for')print("Substring 'for ' found at index:", result)  # How to use find()if (word.find('pawan') != -1):    print("Contains given substring ")else:    print("Doesn't contains given substring")
Substring 'geeks' found at index: 0
Substring 'for ' found at index: 6
Doesn't contains given substring

Python3
word = 'geeks for geeks'  # Substring is searched in 'eks for geeks' print(word.find('ge', 2))   # Substring is searched in 'eks for geeks' print(word.find('geeks ', 2))   # Substring is searched in 's for g' print(word.find('g', 4, 10))   # Substring is searched in 's for g' print(word.find('for ', 4, 11))
10
-1
-1
6

Explanation:
In the first statement, the output is 10 as the start value is given which is 2, so the substring is checked from the second index which is ‘eks for geeks’.
In the second statement, the start value is given as 2 and the substring is given ‘geeks’, so the index position of ‘geeks’ is 10 but due to the last value is being excluded it will only find ‘geek’ which doesn’t matches with the original string, that is why the output is -1.
In the third statement, start value=4, end value=10, and substring = ‘g’ is given, the index position from 4 will be checked for the given substring which is at position 10, which is being excluded as it is the end index.
In the fourth statement, start value =4, end value=11, and substring=’for’ is given, the index position from 4 till 11 will be checked for the given substring and the specified substring is present at index 6, so the output is obtained.
dubey._.ji
AmiyaRanjanRout
sheetal18june
python-string
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Test Internet on Linux Using speedtest-cli?

28 Jul, 2020
While troubleshooting your system for slow internet access, the best way to figure is to measure the internet speed first. To check Internet speed on Linux we will be using third party tool speedtest_cli. It is a simple command-line client based on python for measuring internet bandwidth using speedtest.net infrastructure. 
Test Download/Upload speed in Linux: You can use this command to test the download and upload speed from the Linux command line, it is a one-time usage command:  
wget -O - https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python

Install Speedtest_cli: The above command was a one-time use command, so every time you want to test you need to put a long command in. So you can Install the speedtest_cli in your system using these commands:  
wget https://raw.github.com/sivel/speedtest-cli/master/speedtest.py
chmod a+rx speedtest.py
sudo mv speedtest.py /usr/local/bin/speedtest
sudo chown root:root /usr/local/bin/speedtest

 
Once the installation is done you can simply type “speedtest in the terminal and your results will be there  
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
Docker - COPY Instruction
chown command in Linux with Examples
SED command in Linux | Set 2
nohup Command in Linux with Examples
chmod command in Linux with examples
Array Basics in Shell Scripting | Set 1
mv command in Linux with examples
Introduction to Linux Operating System
Basic Operators in Shell Scripting
numpy.random.poisson() in Python

15 Jul, 2020
With the help of numpy.random.poisson() method, we can get the random samples from poisson distribution and return the random samples by using this method.
poisson distribution
Syntax : numpy.random.poisson(lam=1.0, size=None)
Return : Return the random samples as numpy array.
Example #1 :
In this example we can see that by using this numpy.random.poisson() method, we are able to get the random samples from poisson distribution by using this method.
Python3
# import numpyimport numpy as npimport matplotlib.pyplot as plt  # Using poisson() methodgfg = np.random.poisson(10, 1000)  count, bins, ignored = plt.hist(gfg, 14, density = True)plt.show()
Output :
Example #2 :
Python3
# import numpyimport numpy as npimport matplotlib.pyplot as plt  # Using poisson() methodgfg = np.random.poisson(4.5, 500)  count, bins, ignored = plt.hist(gfg, 14, density = True)plt.show()
Output :
Python numpy-Random
Python-numpy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Properties of Window Object

31 Aug, 2021
The window object is the topmost object of DOM hierarchy. It represents a browser window or frame that displays the contents of the webpage. Whenever a window appears on the screen to display the contents of document, the window object is created. The properties and methods of Window object that are commonly used are listed in the below table:
Properties of the Window Object
Purpose
To access the properties of the window object, you will specify object name followed by a period symbol (.) and the property name.  
Syntax:
window.property_name
Example:
HTML
<!DOCTYPE html><html> <head>    <script language="JavaScript">        function winopen() {            window.open("https://www.geeksforgeeks.org")        }        function showstatus() {            window.status =                "Opening GeeksforGeeks Home page";        }    </script></head> <body onload="showstatus()">    <input type="button" name="btn"        value="Open GeeksforGeeks"        onclick="winopen()"></body> </html>
Output:
Before Click the Button:
After Click the button:
gabaa406
JavaScript-Properties
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ascii() in Python program

In this tutorial, we are going to learn about the ascii() function.
ascii(object) function takes one argument and returns a printable representation of the object.
Let's see some examples.
# intializing non printable characters
string = '¢'
# printing the above character using ascii(object)
print(ascii(string))
If you run the above code, you will get the following results.
'\xa2'

# intializing non printable characters
name = 'HÃFÆËŽ'
# printing the above character using ascii(object)
print(ascii(name))
If you run the above code, you will get the following results.
'H\xc3F\xc6\xcb\u017d'

# intializing non printable characters
strings = ['HÃFÆËŽ', '®', '©Òpy']
# printing the above character using ascii(object)
print(ascii(strings))
If you run the above code, you will get the following results.
['H\xc3F\xc6\xcb\u017d', '\xae', '\xa9\xd2py']

If you have any doubts in the tutorial, mention them in the comment section.
JavaScript - Array join() Method

Javascript array join() method joins all the elements of an array into a string.
Its syntax is as follows −
array.join(separator);

separator  − Specifies a string to separate each element of the array. If omitted, the array elements are separated with a comma.
Returns a string after joining all the array elements.
Try the following example.
<html>
   <head>
      <title>JavaScript Array join Method</title>
   </head>
   
   <body>   
      <script type = "text/javascript">
         var arr = new Array("First","Second","Third");
         
         var str = arr.join();
         document.write("str : " + str ); 
         
         var str = arr.join(", ");
         document.write("<br />str : " + str ); 
         
         var str = arr.join(" + ");
         document.write("<br />str : " + str ); 
      </script>      
   </body>
</html>
str : First,Second,Third
str : First, Second, Third
str : First + Second + Third  


    25 Lectures 
     2.5 hours 

 Anadi Sharma

    74 Lectures 
     10 hours 

 Lets Kode It

    72 Lectures 
     4.5 hours 

 Frahaan Hussain

    70 Lectures 
     4.5 hours 

 Frahaan Hussain

    46 Lectures 
     6 hours 

 Eduonix Learning Solutions

    88 Lectures 
     14 hours 

 Eduonix Learning Solutions
 Print
 Add Notes
 Bookmark this page
Const vs Static vs Readonly in C#

Constant fields are the fields that cannot be modified. At the time of declaration, you need to assign a value to it.
const int a = 5;
If the static modifier is applied to a class then you cannot instantiate the class using the new keyword. You can use the static keyword on methods, properties, classes, constructors, etc.
static int a = 10;
A Readonly field is initialized at the time of declaration or you can also set it within the constructor.
Let us see an example in which the readonly field is initialized inside the constructor.
class Demo {
   readonly int a;
   public Demo( ) {
      a = 5;
   }
}
JavaScript Strings

JavaScript strings are for storing and manipulating text.
A JavaScript string is zero or more characters written inside quotes.
You can use single or double quotes:
You can use quotes inside a string, as long as they don't match the quotes 
surrounding the string:
To find the length of a string, use the built-in length property:
Because strings must be written within quotes, JavaScript will misunderstand this string:
The string will be chopped to "We are the so-called ".
The solution to avoid this problem, is to use the backslash escape character.
The backslash (\) escape character turns special characters into string characters:
The sequence \"  inserts a double quote in a string:


The sequence \'  inserts a single quote in a string:


The sequence \\  inserts a backslash in a string:


Six other escape sequences are valid in JavaScript:
The 6 escape characters above were originally designed to control 
typewriters, teletypes, and fax machines. They do not make any sense in HTML. 
For best readability, programmers often like to avoid code lines longer than 
80 characters.
If a JavaScript statement does not fit on one line, the best place to break 
it is after an operator:
You can also break up a code line within a text string with a single backslash:
The \ method is not the preferred method. It might not have universal support.Some browsers do 
not allow spaces behind the \ character.
A safer way to break up a string, is to use string 
addition:
You cannot break up a code line with a backslash:
Normally, JavaScript strings are primitive values, created from literals:
But strings can also be defined as objects with the keyword new:
Do not create Strings objects.
The new keyword complicates the code and slows down execution speed.
String objects can produce unexpected results:
 When using the == operator, x and y are equal:
When using the === operator, x and y are not equal:


Note the difference between (x==y) and (x===y).
(x == y) true or false?
(x === y) true or false?
Comparing two JavaScript objects always returns false.
For a complete String reference, go to our:
Complete JavaScript String Reference.
The reference contains descriptions and examples of all string properties and methods.
Use the length property to alert the length of txt.
let txt = "Hello World!";
let x = ;
alert(x);

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
C++ Library - <bitset>

Bitset represents a fixed-size sequence of N bits and stores values either 0 or 1. Zero means value is false or bit is unset and one means value is true or bit is set. Bitset class emulates space efficient array of boolean values, where each element occupies only one bit.
As it emulates array, its index also starts from 0th position. Individual bit from bitset can be accessed using subscript operator. For instance to access first element of bitset foo use foo[0].
Bitset class provides constructors to create bitset from integer as well as from strings. The size of the bitset is fixed at compile time. STL provides vector<bool> class that provides dynamic resize functionality.
Below is definition of std::bitset from <bitset> header file
template <size_t N> class bitset;
N − Size of the bitset.
Following member types can be used as parameters or return type by member functions.
Below is list of all methods from <bitset> header.
Constructs bitset container and initialize it with zero.
Constructs bitset container and initialize it with the bit value of val.
Constructs and initializes a bitset container from C++ string object.
Constructs and initializes a bitset container from c-style string.
This is embedded class which provides l-value that can be returned from std::bitset::operator[].
Performs bitwise AND operation on current bitset object.
Performs bitwise OR operation on current bitset object.
Performs bitwise XOR operation on current bitset object.
Performs bitwise left SHIFT operation on current bitset object.
Performs bitwise right SHIFT operation on current bitset object.
Performs bitwise NOT operation on bitset.
Performs bitwise left SHIFT operation on bitset.
Performs bitwise right SHIFT operation on bitset.
Test whether two bitsets are equal or not.
Test whether two bitsets are equal or not.
Performs bitwise AND operation on bitset.
Performs bitwise OR operation on bitset.
Performs bitwise XOR operation on bitset.
Extracts upto N bits from is and stores into another bitset x.
Inserts bitset x to the character stream os.
Tests whether all bits from bitset are set or not.
Tests whether at least one bit from bitset is set or not.
Count number of set bits from bitset.
Toggles all bits from bitset.
Toggles single bit from bitset.
Tests whether all bits are unset or not.
Returns the value of bit at position pos.
Returns the reference of bit at position pos.
Reset all bits of bitset to zero.
Reset single bit of bitset to zero.
Set all bits from bitset to one.
Set single bit from bitset to either one or zero.
Reports the size of the bitset.
Tests whether Nth bit is set or not.
Converts bitset object to string object.
Convert bitset to unsigned long long.
Convert bitset to unsigned long.
Returns hash value based on the provided bitset.
 Print
 Add Notes
 Bookmark this page
How to find exponential value in Python?

Exponential value of a x is xth power of e, Euler's constant which is an irrational number called Euler's number and is equal to 2.718281.
There are two ways to calculate it.
Using ** operator
>>> import math
>>> math.e**2 #math.e is defined constant in math module
7.3890560989306495
Using exp() function
>>>import math
>>> math.exp(2)
7.38905609893065
MongoDB Aggregate JSON array field for the matching field of other collection?

For this, create two collections and add some document. After that, use $lookup for match. Let us create a collection with documents −
> db.demo101.insertOne(
... { "_id" : "1", "Details" : [ { "PId" : "200" }, { "PId" : "201" }, { "PId" : "201" } ] }
... )
{ "acknowledged" : true, "insertedId" : "1" }
Display all documents from a collection with the help of find() method −
> db.demo101.find();
This will produce the following output −
{ "_id" : "1", "Details" : [ { "PId" : "200" }, { "PId" : "201" }, { "PId" : "201" } ] }
Following is the query to create second collection with some documents −
> db.demo102.insertOne(
... { "_id" : "201", "CustEmailId" : "Carol@gmail.com" }
... );
{ "acknowledged" : true, "insertedId" : "201" }
Display all documents from a collection with the help of find() method −
> db.demo102.find();
This will produce the following output −
{ "_id" : "200", "CustEmailId" : "John@gmail.com" }
{ "_id" : "201", "CustEmailId" : "Carol@gmail.com" }
Following is the query to aggregate JSON array field for the matching field of other collection −
> db.demo101.aggregate(
... [
...    {$unwind:"$Details"},
...    {$lookup : {from : "demo102", "localField":"Details.PId", "foreignField":"_id", as :"out"}},
...    {$project : {"_id":1, "Details.PId":{$arrayElemAt:["$out.CustEmailId",0]}}},
...    {$group:{_id:"$_id", Details : {$push : "$Details"}}}
... ]
... ).pretty()
This will produce the following output −
{
   "_id" : "1",
   "Details" : [
      {
         "PId" : "John@gmail.com"
      },
      {
         "PId" : "Carol@gmail.com"
      },
      {
         "PId" : "Carol@gmail.com"
      }
   ]
}
Unix / Linux - Using Shell Arrays

In this chapter, we will discuss how to use shell arrays in Unix. A shell variable is capable enough to hold a single value. These variables are called scalar variables.
Shell supports a different type of variable called an array variable. This can hold multiple values at the same time. Arrays provide a method of grouping a set of variables. Instead of creating a new name for each variable that is required, you can use a single array variable that stores all the other variables.
All the naming rules discussed for Shell Variables would be applicable while naming arrays.
The difference between an array variable and a scalar variable can be explained as follows.
Suppose you are trying to represent the names of various students as a set of variables. Each of the individual variables is a scalar variable as follows −
NAME01="Zara"
NAME02="Qadir"
NAME03="Mahnaz"
NAME04="Ayan"
NAME05="Daisy"
We can use a single array to store all the above mentioned names. Following is the simplest method of creating an array variable. This helps assign a value to one of its indices.
array_name[index]=value

Here array_name is the name of the array, index is the index of the item in the array that you want to set, and value is the value you want to set for that item.
As an example, the following commands −
NAME[0]="Zara"
NAME[1]="Qadir"
NAME[2]="Mahnaz"
NAME[3]="Ayan"
NAME[4]="Daisy"
If you are using the ksh shell, here is the syntax of array initialization −
set -A array_name value1 value2 ... valuen

If you are using the bash shell, here is the syntax of array initialization −
array_name=(value1 ... valuen)

After you have set any array variable, you access it as follows −
${array_name[index]}

Here array_name is the name of the array, and index is the index of the value to be accessed. Following is an example to understand the concept −
#!/bin/sh

NAME[0]="Zara"
NAME[1]="Qadir"
NAME[2]="Mahnaz"
NAME[3]="Ayan"
NAME[4]="Daisy"
echo "First Index: ${NAME[0]}"
echo "Second Index: ${NAME[1]}"
The above example will generate the following result −
$./test.sh
First Index: Zara
Second Index: Qadir

You can access all the items in an array in one of the following ways −
${array_name[*]}
${array_name[@]}

Here array_name is the name of the array you are interested in. Following example will help you understand the concept −
#!/bin/sh

NAME[0]="Zara"
NAME[1]="Qadir"
NAME[2]="Mahnaz"
NAME[3]="Ayan"
NAME[4]="Daisy"
echo "First Method: ${NAME[*]}"
echo "Second Method: ${NAME[@]}"
The above example will generate the following result −
$./test.sh
First Method: Zara Qadir Mahnaz Ayan Daisy
Second Method: Zara Qadir Mahnaz Ayan Daisy


    129 Lectures 
     23 hours 

 Eduonix Learning Solutions

    5 Lectures 
     4.5 hours 

 Frahaan Hussain

    35 Lectures 
     2 hours 

 Pradeep D

    41 Lectures 
     2.5 hours 

 Musab Zayadneh

    46 Lectures 
     4 hours 

 GUHARAJANM

    6 Lectures 
     4 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
TensorFlow - Installation

To install TensorFlow, it is important to have “Python” installed in your system. Python version 3.4+ is considered the best to start with TensorFlow installation.
Consider the following steps to install TensorFlow in Windows operating system.
Step 1 − Verify the python version being installed.
Step 2 − A user can pick up any mechanism to install TensorFlow in the system. We recommend “pip” and “Anaconda”. Pip is a command used for executing and installing modules in Python.
Before we install TensorFlow, we need to install Anaconda framework in our system.
After successful installation, check in command prompt through “conda” command. The execution of command is displayed below −
Step 3 − Execute the following command to initialize the installation of TensorFlow −
conda create --name tensorflow python = 3.5

It downloads the necessary packages needed for TensorFlow setup.
Step 4 − After successful environmental setup, it is important to activate TensorFlow module.
activate tensorflow

Step 5 − Use pip to install “Tensorflow” in the system. The command used for installation is mentioned as below −
pip install tensorflow

And,
pip install tensorflow-gpu

After successful installation, it is important to know the sample program execution of TensorFlow.
Following example helps us understand the basic program creation “Hello World” in TensorFlow.
The code for first program implementation is mentioned below −
>> activate tensorflow
>> python (activating python shell)
>> import tensorflow as tf
>> hello = tf.constant(‘Hello, Tensorflow!’)
>> sess = tf.Session()
>> print(sess.run(hello))


    61 Lectures 
     9 hours 

 Abhishek And Pukhraj

    57 Lectures 
     7 hours 

 Abhishek And Pukhraj

    52 Lectures 
     7 hours 

 Abhishek And Pukhraj

    52 Lectures 
     6 hours 

 Abhishek And Pukhraj

    29 Lectures 
     3.5 hours 

 Mohammad Nauman

    82 Lectures 
     4 hours 

 Anis Koubaa
 Print
 Add Notes
 Bookmark this page
Bootstrap 4 | Jumbotron - GeeksforGeeks

28 Apr, 2022
A jumbotron is a big grey box used to indicate some text which requires extra attention. Any text that seems to be important can be written inside a jumbotron to make it appear big and noticeable.
Steps to add jumbotron:
Use a jumbotron class inside a div element.
Write any text inside the div tag.
Close the div element.
Syntax:
<div class="jumbtron"> Contents... <div>
Example:
HTML
<!DOCTYPE html><html lang="en"><head>    <title>Bootstrap Jumbotron</title>    <meta charset="utf-8">    <meta name="viewport"        content="width=device-width, initial-scale=1">    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js">    </script>    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js">    </script></head><body style="text-align:center;">    <div class="container">        <div class="jumbotron">            <h1 style="color:green;">                GeeksforGeeks            </h1>             <p>A computer science portal for geeks</p>         </div>    </div></body></html>
Output:
Full-width Jumbotron: The .jumbotron-fluid and .container or .container-fluid classes is used to create a full-width jumbotron without rounded borders.
Syntax:
<div class="jumbotron jumbotron-fluid">
    <div class="container"> Contents... <div>
<div>
Example:
HTML
<!DOCTYPE html><html lang="en"><head>    <title>Bootstrap Jumbotron</title>    <meta charset="utf-8">    <meta name="viewport"        content="width=device-width, initial-scale=1">    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">    </script>    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js">    </script>    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js">    </script></head><body style="text-align:center;">    <div class="container">        <div class="jumbotron">            <h1 style="color:green;">                GeeksforGeeks            </h1>             <p>A computer science portal for geeks</p>         </div>    </div></body></html>
Output:
Supported Browser:
Google Chrome
Internet Explorer
Firefox
Opera
Safari
ysachin2314
sahilintern
Bootstrap-4
Bootstrap
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Form validation using jQuery
How to change navigation bar color in Bootstrap ?
How to pass data into a bootstrap modal?
How to align navbar items to the right in Bootstrap 4 ?
How to set Bootstrap Timepicker using datetimepicker library ?
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?
Difference between Iterator and Enumeration in Java with Examples - GeeksforGeeks

28 Jan, 2021
Iterator: It is a universal iterator as we can apply it to any Collection object. By using Iterator, we can perform both read and remove operations. It is an improved version of Enumeration with the additional functionality of remove-ability of an element. 
Iterator must be used whenever we want to enumerate elements in all Collection framework implemented interfaces like Set, List, Queue, Deque and also in all implemented classes of Map interface. Iterator is the only cursor available for entire collection framework. 
Syntax:  
// Here "c" is any Collection object. itr is of
// type Iterator interface and refers to "c"
Iterator itr = c.iterator();
Enumeration: Enumeration (or enum) is a user-defined data type. It is mainly used to assign names to integral constants, the names make a program easy to read and maintain. In Java (from 1.5), enums are represented using the enum data type. Java enums are more powerful than C/C++ enums. In Java, we can also add variables, methods and constructors to it. The main objective of the enum is to define our own data types(Enumerated Data Types). 
Syntax:  
// A simple enum example where enum is declared 
// outside any class (Note enum keyword instead of 
// class keyword) 
enum Color 
{ 
    RED, GREEN, BLUE; 
}
Difference between Iterator and Enumeration: 
The functionality of Enumeration and the Iterator are same. Using Enumeration you can only traverse and fetch the objects, where as using Iterator we can also add and remove the objects. So Iterator can be useful if you want to manipulate the list and Enumeration is for read-only access.  
 
gautambalachandran
Picked
Difference Between
Java
Java
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 Process and Thread
Stack vs Heap Memory Allocation
Difference Between Method Overloading and Method Overriding in Java
Differences between JDK, JRE and JVM
Arrays in Java
Split() String method in Java with examples
For-each loop in Java
Arrays.sort() in Java with examples
Reverse a string in Java
MySQL select query to fetch data with null value?

Let us first create a table −
mysql> create table DemoTable
(
   CustomerName varchar(100),
   CustomerCountryName varchar(100)
);
Query OK, 0 rows affected (0.95 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Chris','US');
Query OK, 1 row affected (0.18 sec)
mysql> insert into DemoTable values('Bob','UK');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable values('Carol',NULL);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('David','AUS');
Query OK, 1 row affected (0.32 sec)
mysql> insert into DemoTable values('Mike',NULL);
Query OK, 1 row affected (0.18 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+--------------+---------------------+
| CustomerName | CustomerCountryName |
+--------------+---------------------+
| Chris        | US                  |
| Bob          | UK                  |
| Carol        | NULL                |
| David        | AUS                 |
| Mike         | NULL                |
+--------------+---------------------+
5 rows in set (0.00 sec)
Following is the query to fetch data with null value −
mysql> select *from DemoTable where CustomerCountryName IS NULL;
This will produce the following output −
+--------------+---------------------+
| CustomerName | CustomerCountryName |
+--------------+---------------------+
| Carol        | NULL                |
| Mike         | NULL                |
+--------------+---------------------+
2 rows in set (0.00 sec)
java.lang.reflect.Proxy.newProxyInstance() Method Example

The java.lang.reflect.Proxy.newProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler h) method returns an instance of a proxy class for the specified interfaces that dispatches method invocations to the specified invocation handler.
Following is the declaration for java.lang.reflect.Proxy.newProxyInstance(ClassLoader loader, Class<?>[] interfaces,
   InvocationHandler h) method.
public static Object newProxyInstance(ClassLoader loader, Class<?>[] interfaces,
   InvocationHandler h)
      throws IllegalArgumentException

loader − the class loader to define the proxy class.
loader − the class loader to define the proxy class.
interfaces − the list of interfaces for the proxy class to implement.
interfaces − the list of interfaces for the proxy class to implement.
h − the invocation handler to dispatch method invocations to.
h − the invocation handler to dispatch method invocations to.
A proxy instance with the specified invocation handler of a proxy class that is defined by the specified class loader and that implements the specified interfaces.
IllegalArgumentException − if any of the restrictions on the parameters that may be passed to getProxyClass are violated.
IllegalArgumentException − if any of the restrictions on the parameters that may be passed to getProxyClass are violated.
NullPointerException − if the interfaces array argument or any of its elements are null, or if the invocation handler, h, is null.
NullPointerException − if the interfaces array argument or any of its elements are null, or if the invocation handler, h, is null.
The following example shows the usage of java.lang.reflect.Proxy.newProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler h) method.
package com.tutorialspoint;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class ProxyDemo {
   public static void main(String[] args) throws IllegalArgumentException {
      InvocationHandler handler = new SampleInvocationHandler() ;
      SampleInterface proxy = (SampleInterface) Proxy.newProxyInstance(
         SampleInterface.class.getClassLoader(),
         new Class[] { SampleInterface.class },
         handler);
      Class invocationHandler = Proxy.getInvocationHandler(proxy).getClass();

      System.out.println(invocationHandler.getName());
   }
}

class SampleInvocationHandler implements InvocationHandler {

   @Override
   public Object invoke(Object proxy, Method method, Object[] args)
      throws Throwable {
      System.out.println("Welcome to TutorialsPoint");   
      return null;
   }
}

interface SampleInterface {
   void showMessage();
}

class SampleClass implements SampleInterface {
   public void showMessage(){
      System.out.println("Hello World");   
   }
}
Let us compile and run the above program, this will produce the following result −
com.tutorialspoint.SampleInvocationHandler

 Print
 Add Notes
 Bookmark this page
How I can change the style of alert box using JavaScript?

You will not be able to change the style of a standard alert box in JavaScript. To change the style, use the following custom alert box. We’re using JavaScript library, jQuery to achive this.
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
      </script>
      <script>
         function functionAlert(msg, myYes) {
            var confirmBox = $("#confirm");
            confirmBox.find(".message").text(msg);
            confirmBox.find(".yes").unbind().click(function() {
               confirmBox.hide();
            });
            confirmBox.find(".yes").click(myYes);
            confirmBox.show();
         }
      </script>
      <style>
         #confirm {
            display: none;
            background-color: #514E61;
            color: #FFFFFF;
            border: 1px solid #aaa;
            position: fixed;
            width: 250px;
            left: 50%;
            margin-left: -100px;
            padding: 6px 8px 8px;
            box-sizing: border-box;
            text-align: center;
         }
         #confirm button {
            background-color: #48E5DA;
            display: inline-block;
            border-radius: 5px;
            border: 1px solid #aaa;
            padding: 5px;
            text-align: center;
            width: 80px;
            cursor: pointer;
         }
         #confirm .message {
            text-align: left;
         }
      </style>
   </head>
   <body>
      <div id="confirm">
         <div class="message">This is a warning message.</div>
         <button class="yes">OK</button>
      </div>
      <input type="button" value="Click Me" onclick="functionAlert();" />
   </body>
</html>
PriorityQueue clear() Method in Java

10 Dec, 2018
The Java.util.PriorityQueue.clear() method is used to remove all the elements from a PriorityQueue. Using the clear() method only clears all the element from the queue and does not delete the queue. In other words, we can say that the clear() method is used to only empty an existing PriorityQueue.
Syntax:
Priority_Queue.clear()
Parameters: The method does not take any parameter
Return Value: The function does not returns any value.
Below programs illustrate the Java.util.PriorityQueue.clear() method:
Program 1:
// Java code to illustrate clear()import java.util.PriorityQueue;  public class PriorityQueueDemo {    public static void main(String args[])    {        // Creating an empty PriorityQueue        PriorityQueue<String> queue = new PriorityQueue<String>();          // Use add() method to add elements into the Queue        queue.add("Welcome");        queue.add("To");        queue.add("Geeks");        queue.add("4");        queue.add("Geeks");          // Displaying the PriorityQueue        System.out.println("PriorityQueue: " + queue);          // Clearing the PriorityQueue using clear() method        queue.clear();          // Displaying the final Queue after clearing;        System.out.println("The final Queue: " + queue);    }}
PriorityQueue: [4, Geeks, To, Welcome, Geeks]
The final Queue: []

Program 2:
// Java code to illustrate clear()import java.util.*;  public class PriorityQueueDemo {    public static void main(String args[])    {        // Creating an empty PriorityQueue        PriorityQueue<Integer> queue = new PriorityQueue<Integer>();          // Use add() method to add elements into the Queue        queue.add(10);        queue.add(15);        queue.add(30);        queue.add(20);        queue.add(5);          // Displaying the PriorityQueue        System.out.println("PriorityQueue: " + queue);          // Clearing the PriorityQueue using clear() method        queue.clear();          // Displaying the final Queue after clearing;        System.out.println("The final Queue: " + queue);    }}
PriorityQueue: [5, 10, 30, 20, 15]
The final Queue: []

Java - util package
Java-Collections
Java-Functions
java-priority-queue
Java
Java
Java-Collections
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
PLSQL | LOWER Function

24 Sep, 2019
The PLSQL LOWER function is used for converting all letters in the specified string to lowercase. If there are characters in the string that are not letters, they are unaffected by this function.
The char to be converted can be any of the datatypes such as CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. The value returned by the LOWER function is the same datatype as char. The database sets the case of the characters based on the binary mapping defined for the underlying character set.
Syntax:
LOWER( string )
Parameters Used:
string – It is used to specify the string which needs to be converted.
Supported Versions of Oracle/PLSQL:
Oracle 12cOracle 11gOracle 10gOracle 9iOracle 8i
Oracle 12c
Oracle 11g
Oracle 10g
Oracle 9i
Oracle 8i
Example-1:
DECLARE 
   Test_String string(20) := 'Geeksforgeeks';
   
BEGIN 
   dbms_output.put_line(LOWER(Test_String)); 
   
END;  
Output:
geeksforgeeks 
Example-2:
DECLARE 
   Test_String string(20) := 'GEEKSFORGEEKS';
      
BEGIN 
   dbms_output.put_line(LOWER(Test_String)); 
   
END; 
Output:
geeksforgeeks 
Example-3:
DECLARE 
   Test_String varchar2(30) := 'GEEKSFORGEEKS12345';
      
BEGIN 
   dbms_output.put_line(LOWER(Test_String)); 
   
END; 
Output:
geeksforgeeks12345 
SQL-PL/SQL
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Different ways to Invert the Binary bits in Python

20 Aug, 2020
We know how binary value for numbers look like. For example, the binary value for 10 (Number Ten) is 1010 (binary value).
Sometimes it is required to inverse the bits i.e., 0’s to 1’s ( zeros to ones) and 1’s to 0’s (ones to zeros). Here are there few ways by which we can inverse the bits in Python.
1) Using Loops: By iterating each and every bit we can change the bit 1 to bit 0 and vice-versa.
Python3
bit_s = '1010'inverse_s = ''  for i in bit_s:        if i == '0':        inverse_s += '1'              else:        inverse_s += '0'          print("Inversed string is ",      inverse_s)
Output:
Inversed string is 0101

2) Using Dictionary: Dictionaries are very fast in accessing an element, which it takes O(1) time complexity.
Python3
# create a dictionaryb_dict = {'0': '1', '1': '0'}  bit_s = '1010'  inverse_s = ''  for i in bit_s:        inverse_s += b_dict[i]      print("Inversed string is",      inverse_s)
Output:
Inversed string is 0101

3) Using List comprehension: List comprehensions are the short hand notations of accessing, adding, manipulating a list.
Python3
bit_s = '1010'  # using ternary operator with # list comprehensioninverse_s = ''.join(['1' if i == '0' else '0'                     for i in bit_s])  print("Inversed string is",       inverse_s)
Output:
Inversed string is 0101

4) Using replace() method of strings: In python, strings has a built-in method i.e., string.replace(existing_characters, new_characters), which replaces all the existing_characters with new_characters.
Python3
bit_s = '1010'  # replace "1" with "2" # output : "2020"inverse_s = bit_s.replace('1', '2')  # replace "0" with "1" # output : "2121"inverse_s = inverse_s.replace('0', '1')  # replace "0" with "1" # output : "0101"inverse_s = inverse_s.replace('2', '0')  print("Inversed string is",       inverse_s)
Output:
Inversed string is 0101

5) Using bit-wise XOR operator: XOR operator Returns 1 if one of the bit is 1 and other is 0 else returns false.
Python3
bit_s = '1010'  # convert binary string # into integertemp = int(bit_s, 2)  # applying Ex-or operator# b/w 10 and 31inverse_s = temp ^ (2 ** (len(bit_s) + 1) - 1)  # convert the integer result # into binary result and then # slicing of the '0b1' # binary indicatorrslt = bin(inverse_s)[3 : ]  # print the resultprint("Inversed string is",       rslt )
Output:
Inversed string is  0101

binary-string
python-string
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python Dictionary
Different ways to create Pandas Dataframe
Read a file line by line 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
Install Tensorflow on MacOS

23 May, 2021
TensorFlow is an open-source software library developed by the Google brain team. It widely used to implement deep learning models which helps in solving real world problems. In this article, we learn how to install TensorFlow on macOS using Homebrew.
Requirements:
Python 3.6–3.8macOS 10.12.6 (Sierra) or later (no GPU support)
Python 3.6–3.8
macOS 10.12.6 (Sierra) or later (no GPU support)
Step 1: Verify the python version:
$ python3 --version
Step 2: Verify if the brew is installed:
$ brew --version
Step 3: Create the virtual environment:
$ brew install virtualenv
Step 4: After creating a new virtual environment, create a  ./pythonenv directory to hold it.
$ virtualenv --system-site-packages -p python3 ./pythonenv
Step 5: Go inside ./pythonenv
$ cd ./pythonenv
Step 6: Activate the virtual environment
source bin/activate
Step 7: Install TensorFlow.
brew install tensorflow
Step 8: Create a new folder inside /pythonenv called tfdemo. Create a new file inside tfdemo called tfdemofile.py.
Step 9: Run the file:
$ python3 tfdemofile.py
Python3
# importing tensorflowimport tensorflow as tf    # creating nodes in computation graphnode1 = tf.constant(3, dtype = tf.int32)node2 = tf.constant(5, dtype = tf.int32)node3 = tf.add(node1, node2)    # create tensorflow session objectsess = tf.Session()    # evaluating node3 and printing the resultprint("Sum of node1 and node2 is:", sess.run(node3))    # closing the sessionsess.close()
Output:
Picked
Python-Tensorflow
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function
ES6 - switchâ¦case Statement

The switch statement evaluates an expression, matches the expression’s value to a case clause and executes the statements associated with that case.
Following is the syntax.
switch(variable_expression) {
   case constant_expr1: {
      //statements;
      break;
   }
   case constant_expr2: {
      //statements;
      break;
   }
   default: {
      //statements;
      break;
   }
}

The value of the variable_expression is tested against all cases in the switch. If the variable matches one of the cases, the corresponding code block is executed. If no case expression matches the value of the variable_expression, the code within the default block is associated.
The following rules apply to a switch statement −
There can be any number of case statements within a switch.
The case statements can include only constants. It cannot be a variable or an expression.
The data type of the variable_expression and the constant expression must match.
Unless you put a break after each block of code, the execution flows into the next block.
The case expression must be unique.
The default block is optional.
var grade="A";
switch(grade) {
   case "A": {
      console.log("Excellent");
      break;
   }
   case "B": {
      console.log("Good");
      break;
   }
   case "C": {
      console.log("Fair");
      break;
   }
   case "D": {
      console.log("Poor");
      break;
   }
   default: {
      console.log("Invalid choice");
      break;
   }
}
The following output is displayed on successful execution on the above code.
Excellent

The example verifies the value of the variable grade against the set of constants (A, B, C, D, and E) and executes the corresponding blocks. If the value in the variable doesn’t match any of the constants mentioned above, the default block will be executed.
Python | Split Sublist Strings

01 May, 2019
Yet another variation of splitting strings is splitting the strings that are an element of the sublist. This is quite peculiar problem, but one can get the data in this format and knowledge of splitting it anyways quite useful. Let’s discuss certain ways in which this particular task can be performed.
Method #1 : Using list comprehension + split()
This method is the shorthand version of the longer loop version that one could choose to solve this particular problem. We just split the strings fetching the sublist using the loop in list comprehension using split function.
# Python3 code to demonstrate# Split Sublist Strings# using split() + list comprehension  # initializing listtest_list = [['GfG is best'], ['All love Gfg'], ['Including me']]  # printing original listprint("The original list : " + str(test_list))  # using split() + list comprehension# Split Sublist Stringsres = [sub.split() for subl in test_list for sub in subl]  # print resultprint("The list after splitting strings : " + str(res))
The original list : [[‘GfG is best’], [‘All love Gfg’], [‘Including me’]]The list after splitting strings : [[‘GfG’, ‘is’, ‘best’], [‘All’, ‘love’, ‘Gfg’], [‘Including’, ‘me’]]
 
Method #2 : Using map() + lambda + split()
This task can also be performed using the combination of above 3 functions. The map function binds the splitting logic to each element which is written using the lambda function that uses split function to perform the split.
# Python3 code to demonstrate# Split Sublist Strings# using map() + lambda + split()  # initializing listtest_list = [['GfG is best'], ['All love Gfg'], ['Including me']]  # printing original listprint("The original list : " + str(test_list))  # using map() + lambda + split()# Split Sublist Stringsres = list(map(lambda sub: sub[0].split(' '), test_list))  # print resultprint("The list after splitting strings : " + str(res))
The original list : [[‘GfG is best’], [‘All love Gfg’], [‘Including me’]]The list after splitting strings : [[‘GfG’, ‘is’, ‘best’], [‘All’, ‘love’, ‘Gfg’], [‘Including’, ‘me’]]
Python list-programs
Python string-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 | os.path.join() method
Introduction To PYTHON
Python OOPs Concepts
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