code-rag-bench/online-tutorials huggingface dataset:
Java - Decision Making

Decision making structures have one or more conditions to be evaluated or tested by the program, along with a statement or statements that are to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false.
Following is the general form of a typical decision making structure found in most of the programming languages −
Java programming language provides following types of decision making statements. Click the following links to check their detail.
An if statement consists of a boolean expression followed by one or more statements.
An if statement can be followed by an optional else statement, which executes when the boolean expression is false.
You can use one if or else if statement inside another if or else if statement(s).
A switch statement allows a variable to be tested for equality against a list of values.
We have covered conditional operator ? : in the previous chapter which can be used to replace if...else statements. It has the following general form −
Exp1 ? Exp2 : Exp3;

Where Exp1, Exp2, and Exp3 are expressions. Notice the use and placement of the colon.
To determine the value of the whole expression, initially exp1 is evaluated.
If the value of exp1 is true, then the value of Exp2 will be the value of the whole expression.
If the value of exp1 is true, then the value of Exp2 will be the value of the whole expression.
If the value of exp1 is false, then Exp3 is evaluated and its value becomes the value of the entire expression.
If the value of exp1 is false, then Exp3 is evaluated and its value becomes the value of the entire expression.
In the next chapter, we will discuss about Number class (in the java.lang package) and its subclasses in Java Language.
We will be looking into some of the situations where you will use instantiations of these classes rather than the primitive data types, as well as classes such as formatting, mathematical functions that you need to know about when working with Numbers.

    16 Lectures 
     2 hours 

 Malhar Lathkar

    19 Lectures 
     5 hours 

 Malhar Lathkar

    25 Lectures 
     2.5 hours 

 Anadi Sharma

    126 Lectures 
     7 hours 

  Tushar Kale

    119 Lectures 
     17.5 hours 

 Monica Mittal

    76 Lectures 
     7 hours 

 Arnab Chakraborty
 Print
 Add Notes
 Bookmark this page
Golang Program to convert an integer into binary representation

For example, n = 1 (Binary Representation of 1: 1)
For example, n = 5 (Binary Representation of 5: 101)
For example, n = 20 (Binary Representation of 5: 10100)
For example, n = 31 (Binary Representation of 31: 11111)
Approach to solve this problem
Step 1 − Define a method that accepts an integer, n.
Step 2 − Convert n into binary representation using golang package
Step 3 − Return the converted binary representation.
 Live Demo
package main
import (
   "fmt"
   "strconv"
)
func IntegerToBinary(n int) string {
   return strconv.FormatInt(int64(n), 2)
}
func main(){
   n := 1
   fmt.Printf("Binary Representation of %d is %s.\n", n, IntegerToBinary(n))
   n = 5
   fmt.Printf("Binary Representation of %d is %s.\n", n, IntegerToBinary(n))
   n = 20
   fmt.Printf("Binary Representation of %d is %s.\n", n, IntegerToBinary(n))
   n = 31
   fmt.Printf("Binary Representation of %d is %s.\n", n, IntegerToBinary(n))
}
Binary Representation of 1 is 1.
Binary Representation of 5 is 101.
Binary Representation of 20 is 10100.
Binary Representation of 31 is 11111.
Scala Stack diff() method with example - GeeksforGeeks

03 Nov, 2019
In Scala Stack class, the diff() method is used to find the difference between the two stacks. It deletes elements that are present in one stack from the other one.
Method Definition: def diff[B >: A](that: collection.Seq[B]): Stack[A]
Return Type: It returns a new stack which consists of elements after the difference between the two stacks.
Example #1:
// Scala program of diff() // method   // Import Stack import scala.collection.mutable._  // Creating object object GfG {       // Main method     def main(args:Array[String])     {               // Creating stacks          val s1 = Stack(1, 2, 3, 4, 5)                      val s2 = Stack(3, 4, 5)                      // Print the stack         println("Stack_1: " + s1)                     println("Stack_2: " + s2)                     // Applying diff method          val result = s1.diff(s2)                      // Displays output          print("(Stack_1 - Stack_2): " + result)    } } 
Stack_1: Stack(1, 2, 3, 4, 5)
Stack_2: Stack(3, 4, 5)
(Stack_1 - Stack_2): Stack(1, 2)

Example #2:
// Scala program of diff() // method   // Import Stack import scala.collection.mutable._  // Creating object object GfG {       // Main method     def main(args:Array[String])     {               // Creating stacks          val s1 = Stack(1, 2, 3, 4, 5)                      val s2 = Stack(3, 4, 5, 6, 7, 8)                      // Print the stack         println("Stack_1: " + s1)                     println("Stack_2: " + s2)                     // Applying diff method          val result = s2.diff(s1)                      // Displays output          print("(Stack_2 - Stack_1): " + result)    } } 
Stack_1: Stack(1, 2, 3, 4, 5)
Stack_2: Stack(3, 4, 5, 6, 7, 8)
(Stack_2 - Stack_1): Stack(6, 7, 8)

Scala
scala-collection
Scala-Method
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Scala Tutorial – Learn Scala with Step By Step Guide
Class and Object in Scala
Type Casting in Scala
Operators in Scala
Inheritance in Scala
Throw Keyword in Scala
Hello World in Scala
Scala String substring() method with example
Scala Constructors
Scala | Option
Python String rjust() Method

Python string  method rjust() returns the string right justified in a string of length width. Padding is done using the specified fillchar (default is a space). The original string is returned if width is less than len(s).
Following is the syntax for rjust() method −
str.rjust(width[, fillchar])

width − This is the string length in total after padding.
width − This is the string length in total after padding.
fillchar − This is the filler character, default is a space.
fillchar − This is the filler character, default is a space.
This method returns the string right justified in a string of length width. Padding is done using the specified fillchar (default is a space). The original string is returned if width is less than len(s).
The following example shows the usage of rjust() method.
#!/usr/bin/python

str = "this is string example....wow!!!";
print str.rjust(50, '0')
When we run above program, it produces following result −
000000000000000000this is string example....wow!!!


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
arg() function for Complex Number in C++

A complex number is a number that is expressed in the form of a + bi, where a and b are real numbers. i is the imaginary part of number.
The argument is the angle between the positive axis and the vector of the complex number. For a complex number
z = x + iy denoted by arg(z),
For finding the argument of a complex number there is a function named arg() of a complex number in the complex header file.
arg(complex_number);
The function accepts a complex number as input to calculate the value of the argument for that complex number.
The function returns the argument of the complex number.
 Live Demo
#include<iostream>
#include<complex.h>
using namespace std;
int main (){
   double a = 12.0, b = 56.0;
   complex<double> complexnumber (a, b);
   cout<<"The argument of complex number "<<a<<" + i"<<b<< " is: ";
   cout<<arg(complexnumber)<<endl;
   return 0;
}
The argument of complex number 12 + i56 is: 1.3597
What is the difference between a definition and a declaration in C++?

In C++, declaration and definition are often confused. A declaration means (in C) that you are telling the compiler about type, size and in case of function declaration, type and size of its parameters of any variable, or user-defined type or function in your program. No space is reserved in memory for any variable in case of the declaration.
The Definition on the other hand means that in additions to all the things that declaration does, space is additionally reserved in memory. You can say "DEFINITION = DECLARATION + SPACE RESERVATION".
Following are examples of declarations −
extern int a;                           // Declaring a variable a without defining it
struct _tagExample { int a; int b; };   // Declaring a struct
int myFunc (int a, int b);              // Declaring a function
While following are examples of definition −
int a;
int b = 0;
int myFunc (int a, int b) { return a + b; }
struct _tagExample example;
export command in Linux with Examples

15 May, 2019
export is bash shell BUILTINS commands, which means it is part of the shell. It marks an environment variables to be exported to child-processes.
Export is defined in POSIX as The shell shall give the export attribute to the variables corresponding to the specified names, which shall cause them to be in the environment of subsequently executed commands. If the name of a variable is followed by = word, then the value of that variable shall be set to the word.
In simple terms, environment variables are set when you open a new shell session. at any time if you change any of the variable values, the shell has no way of picking that change. The export command, on the other hand, provides the ability to update the current shell session about the change you made to the exported variable. You don’t have to wait until new shell session to use the value of the variable you changed.
Syntax :
export [-f] [-n] [name[=value] ...] or export -p

Options of export command
1. Without any argument : To view all the exported variables.
EXAMPLE :
2. -p : To view all exported variables on current shell.
SYNTAX :
$ export -p

EXAMPLE :
3. -f: It must be used if the names refer to functions. If -f is not used, the export will assume the names are variables.
SYNTAX :
$ export -f function_name

EXAMPLE : To export shell function:
Note: Bash command is used for showing that in the child shell, the shell function got exported.
4. name[=value]: You can assign value before exporting using the following syntax.
SYNTAX :
$ export name[=value]

EXAMPLE : To set vim as a text editor
Note: No output will be seen on screen, to see exported variable grep from exported ones is used.
5. -n: Named variables (or functions, with -f) will no longer be exported.
SYNTAX :
$ export -n variable_name

EXAMPLE :
Note: No output will be seen on screen, to see exported variable grep from exported ones is used.
linux-command
Linux-misc-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ZIP command in Linux with examples
tar command in Linux with examples
curl command in Linux with Examples
TCP Server-Client implementation in C
Conditional Statements | Shell Script
Tail command in Linux with examples
UDP Server-Client implementation in C
Docker - COPY Instruction
scp command in Linux with Examples
Cat command in Linux with examples
How to rotate an element using CSS ?

31 Aug, 2020
The purpose of this article is to rotate an HTML element by using CSS transform property. This property is used to move, rotate, scale and to perform various kinds of transformation of elements.
The rotate() function can be used to rotate any HTML element or used for transformations. It takes one parameter which defines the rotation angle. The rotation angle consists of two parts, the value of the rotation followed by the unit of rotation. The unit can be defined in degrees (deg), gradient (grad), radians (rad) and turns.
Syntax:
transform: rotate(90deg);
Example: The following example demonstrates rotation of an image by 45 degree.
HTML
    <!DOCTYPE html> <html>   <head>         <style>         body {             text-align:center;         }         h1 {             color:green;         }         .rotate_image {             transform: rotate(45deg);         }     </style> </head>   <body>     <h1>GeeksforGeeks</h1>     <h2>        How to rotate an element using CSS?    </h2>            <img class="rotate_image" src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"          alt="GeeksforGeeks logo"> </body>   </html>
Supported Browsers:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
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.
Sets intersection() function | Guava | Java

14 Nov, 2018
Guava’s Sets.intersection() returns an unmodifiable view of the intersection of two sets. The returned set contains all elements that are contained by both backing sets. The iteration order of the returned set matches that of set1.
Syntax:
public static <E> 
    Sets.SetView<E> 
        intersection(Set<E> set1, Set<?> set2)

Return Value: This method returns an unmodifiable view of the intersection of two sets.
Below examples illustrate the working of Sets intersection method:
Example 1:
// Java code to show implementation// of Guava's Sets.intersection() method  import com.google.common.collect.Sets;import java.util.Set;  class GFG {      // Driver's code    public static void main(String[] args)    {        // Creating first set        Set<Integer>            set1 = Sets.newHashSet(10, 20, 30, 40, 50);          // Creating second set        Set<Integer>            set2 = Sets.newHashSet(30, 50, 70, 90);          // Using Guava's Sets.intersection() method        Set<Integer>            answer = Sets.intersection(set1, set2);          // Displaying the intersection of set1 and set2        System.out.println("Set 1: "                           + set1);        System.out.println("Set 2: "                           + set2);        System.out.println("Set 1 intersection Set 2: "                           + answer);    }}
Set 1: [40, 10, 50, 20, 30]
Set 2: [50, 90, 30, 70]
Set 1 intersection Set 2: [50, 30]

Example 2:
// Java code to show implementation// of Guava's Sets.intersection() method  import com.google.common.collect.Sets;import java.util.Set;  class GFG {      // Driver's code    public static void main(String[] args)    {        // Creating first set        Set<String>            set1 = Sets.newHashSet("G", "e", "e", "k", "s");          // Creating second set        Set<String>            set2 = Sets.newHashSet("g", "f", "G", "e");          // Using Guava's Sets.intersection() method        Set<String>            answer = Sets.intersection(set1, set2);          // Displaying the intersection of set1 and set2        System.out.println("Set 1: "                           + set1);        System.out.println("Set 2: "                           + set2);        System.out.println("Set 1 intersection Set 2: "                           + answer);    }}
Set 1: [k, s, e, G]
Set 2: [e, f, g, G]
Set 1 intersection Set 2: [e, G]

Note: The returned view performs slightly better when set1 is the smaller of the two sets. If you have reason to believe one of your sets will generally be smaller than the other, pass it first.
java-guava
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Interfaces in Java
Stream In Java
ArrayList in Java
Collections in Java
Singleton Class in Java
Multidimensional Arrays in Java
Stack Class in Java
Initializing a List in Java
Introduction to Java
Multithreading in Java
Python | Pandas dataframe.select_dtypes()

23 Nov, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas dataframe.select_dtypes() function return a subset of the DataFrame’s columns based on the column dtypes. The parameters of this function can be set to include all the columns having some specific data type or it could be set to exclude all those columns which has some specific data types.
Syntax : DataFrame.select_dtypes(include=None, exclude=None)
Parameters :include, exclude : A selection of dtypes or strings to be included/excluded. At least one of these parameters must be supplied.
Return : The subset of the frame including the dtypes in include and excluding the dtypes in exclude.
For link to the CSV file used in the code, click here
Example #1: Use select_dtypes() function to select all the columns which are having floating data types.
# importing pandas as pdimport pandas as pd  # Creating the dataframe df = pd.read_csv("nba.csv")  # Print the dataframedf
Let’s use the dataframe.select_dtypes() function to select all columns having float data type in the dataframe.
# select all columns having float datatypedf.select_dtypes(include ='float64')
Output : Example #2: Use select_dtypes() function to select all the columns in the dataframe except those columns which are of float data type.
# importing pandas as pdimport pandas as pd  # Creating the dataframe df = pd.read_csv("nba.csv")  # select all columns except float baseddf.select_dtypes(exclude ='float64')
Output :
Python pandas-dataFrame
Python pandas-dataFrame-methods
Python-pandas
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
Enumerate() in Python
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
Iterate over a list in Python
Underscore.js | _.pick() Function

27 Apr, 2020
The _.pick() function is used to return a copy of the object that filtered using the given key. This function accepts a predicate indicating which keys are picked from the object.
Syntax:
_.pick(object, *keys)
Parameters: This function accept two parameters as mentioned above and described below:
object: This parameter holds the value of an object.
keys: It is an optional parameter. It contains the key name that value need to be picked.
Return Value: It returns a copy of the object that filtered using the given key.
Example 1:
<!DOCTYPE html><html>  <head>    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js">    </script></head>  <body>    <script type="text/javascript">          var info = {            Company: 'GeeksforGeeks',            Address: 'Noida',            Contact: '+91 9876543210'        };          console.log(_.pick(info, 'Company', 'Address'));    </script></body>  </html>
Output:
Example 2:
<!DOCTYPE html><html>  <head>    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.1/underscore-min.js">    </script></head>  <body>    <script type="text/javascript">          var info = {            key1: 10,            key2: 20,            key3: 30,            key4: 40,            key5: 50        };          console.log(_.pick(info, function (value, key, info) {            return value == 10 || value == 50;        }));    </script></body>  </html>
Output:
JavaScript - Underscore.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Create a gauss pulse using scipy.signal.gausspulse

03 Jan, 2021
Prerequisites: Scipy
The impulse response of a Gaussian Filter is written as a Gaussian Function as follows: 
Its result is also Gaussian. In this article, we will plot the gauss pulse at 3Hz using scipy and matplotlib Python library. Gauss pulse is used in digital filters for motion analysis.  To create a gauss pulse scipy’s gausspulse() method is used. gausspulse() returns a unit-amplitude Gaussian-modulated sinusoidal pulse at the times indicated in array t, with a center frequency ‘fc’ in hertz(Hz).
Syntax: scipy.signal.gausspulse(t, fc retquad, retenv)
Parameter:
t: Input array.
fc: Center frequency.
retquad: If True, return the imaginary as well as the real part of the signal. Default is False.
retenv: If True, return the envelope of the signal. Default is False.
Returns
yI: The real part of the signal. Always returned.
yQ:  Imaginary part of signal. Only returned if retquad is True.
yenv:  The envelope of the signal. Only returned if retenv is True.
Import required module.
Create an array of data using np.linespace.
Create a gauss pulse at 3 Hz.
Label the Graph.
Show the resultant Graph.
Implementation using the above approach is depicted below:
Python3
from scipy import signalimport matplotlib.pyplot as pltimport numpy as np  t = np.linspace(-1, 1, 200)  i, q, e = signal.gausspulse(t, fc=3, retquad=True, retenv=True)  plt.plot(i, color='green')plt.plot(q, color='black')plt.plot(e, '--', color='red')  plt.title('Gauss pulse for a 3 Hz - Geeksforgeeks')plt.ylabel("Normalized magnitude [dB]")plt.xlabel("Normalized frequency [cycles per sample]")plt.margins(0, 0.1)plt.grid(which='both', axis='both')plt.legend(['Inphase', 'Quadrature', 'Envelope'])  plt.show()
Output:
Python-scipy
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
DAX Aggregation - COUNTAX function

Counts nonblank results when evaluating the result of an expression over a table. That is, it works just like the COUNTA function, however it is used to iterate through the rows in a table and count rows where the specified expressions result in a nonblank result.
COUNTAX (<table>, <expression>)

table
The table containing the rows for which the expression will be evaluated.
expression
The expression to be evaluated for each row of the table.
A whole number.
The COUNTAX function counts the cells containing any type of information, including other expressions. For example, if the column contains an expression that evaluates to an empty string, the COUNTAX function treats that result as nonblank. Usually, the COUNTAX function does not count empty cells but in this case the cell contains a formula, so it is counted.
Whenever the function finds no rows to aggregate, the function returns a blank. However, if there are rows, but none of them meet the specified criteria, the function returns 0.
Medal Count Summer Sports:= COUNTAX ( 
   FILTER (Results, Results[Season] = "Summer"), Results[Medal]
How to plot a graph in R using CSV file ?

26 Mar, 2021
To plot a graph in R using a CSV file, we need a CSV file with two-column, the values in the first column will be considered as the points at the x-axis and the values in the second column will be considered as the points at the y-axis. In this article, we will be looking at the way to plot a graph using a CSV file in R language.
Approach
Import csv file
Pass required parameters to plot function
Plot graph
Display plot
Functions Used:
To import/read the CSV file to the R console, the user must need to use the read.csv() function in R.This function will read a CSV file available in your current working directory.
Syntax:
read.csv(file)
plot() function for plotting of R objects. With the provided parameters this function returns a scatter plot by default.
Syntax:
plot(x,y,main,xlab,ylab,sub,asp)
Parameters:
x:-the x coordinates of points in the plot
y:-the y coordinates of points in the plot
main:-an overall title for the plot
sub:-a subtitle for the plot
xlab:-a title for the x-axis
ylab:-a title for the y-axis
asp:-the y/x aspect ratio
Return:
Scatter plot of the given x and y values.
Example:
R
data=read.csv('input_gfg.csv')  print(data)  plot(x = data$x,y = data$y,     xlab = "x-axis",     ylab = "y-axis",     main = "Plot")
Output:
Picked
R-Charts
R-Graphs
R-plots
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Convert HTML to Markdown in Python?

03 Mar, 2021
Markdown is a way of writing a formatted text on the web. This article discusses how an HTML text can be converted to Markdown. We can easily convert HTML to markdown using markdownify package. So let’s see how to download markdownify package and convert our HTML to markdown in python. 
This module does not come in-built with Python. To install it type the below command in the terminal.
pip install markdownify
Import module
Create HTML text
Use markdownify() function and pass the text to it
Display markdowned text
Example 1:
Python3
# import markdownifyimport markdownify    # create htmlhtml = """           <h1> <strong>Geeks</strong>         for<br>         Geeks         </h1>        """  # print HTMLprint(html)  # convert html to markdownh = markdownify.markdownify(html, heading_style="ATX")  print(h)
Output:
         <h1> <strong>Geeks</strong>
        for<br>
        Geeks
        </h1>
       
#  **Geeks**
for
Geeks
Example 2:
Python
# import markdownifyimport markdownify    # create htmlhtml = """  <h1>Fruits</h1>         <ul>             <li>  apple  </li>             <li>  banana </li>             <li>  orange </li>        </ul>                  """  # print HTMLprint(html)  # convert html to markdownh = markdownify.markdownify(html, heading_style="ATX")  # print markdownprint(h)
Output:
<h1>Fruits</h1>
         <ul>
             <li>  apple  </li>
             <li>  banana </li>
             <li>  orange </li>
        </ul>
        
        
 # Fruits
*  apple 
*  banana 
*  orange 
Picked
python-modules
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
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
Introduction To PYTHON
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list
How to select multiple options at once in dropdown list in HTML5?

25 Mar, 2021
Dropdown lists are one of the most flexible elements in HTML. It is similar to that of the radio input, that is, only one item can be selected from a group of items by default. However, when the multiple attribute is used with the <select> element, we can enable the selection of multiple options from the list. The multiple attribute is a boolean attribute that specifies whether multiple options can be selected at once.
The process of selecting multiple options vary in different operating systems and browsers as mentioned below:
Windows: We need to hold down the CTRL button to select multiple options.
Mac: We need to hold down the command button to select multiple options.
Note that, because of the different ways of approaching this, and because one has to inform the user that multiple selections is available, it is more user-friendly to use checkboxes instead.
The below example demonstrates the use of the multiple attribute:
Example 1:
HTML
<html><body>  <h1 style="color: green;">    GeeksforGeeks  </h1>    <p>    The below list does not allow     multiple selection.  </p>    <form id="form1">    <select width=300             style="width: 350px">      <option value='blue'>Blue</option>      <option value='green'>Green</option>      <option value='red'>Red</option>      <option value='yellow'>Yellow</option>      <option value='' selected>Select a Color</option>    </select>  </form>    <p>    The below list does allows    multiple selections.  </p>    <form id="form2">    <select width=300 style="width: 350px"            size="8" multiple>      <option value='blue'>Blue</option>      <option value='green'>Green</option>      <option value='red'>Red</option>      <option value='yellow'>Yellow</option>      <option value='orange'>Orange</option>    </select>  </form></body></html>
Output:
Example 2:
<html>  <body>    <center>        <h1 style="color:green; font-style:italic;">          Geeksforgeeks      </h1>        <h2 style="font-style:italic; color:green;">          HTML select multiple Attribute      </h2>        <form action=" ">            <select name="Bikes" multiple>                <option value="HeroHonda">HeroHonda</option>                <option value="Splender">Splender</option>                <option value="Ninja">Ninja</option>                <option value="Pulsav">Pulsav</option>            </select>            <input type="submit">        </form>          <p>Hold down the Ctrl (windows) /           Command (Mac) button to select multiple options.</p>    </center></body>  </html>
Output:
HTML-Attributes
HTML-Questions
Picked
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java Program to Sort the Array Elements in Descending Order

09 Oct, 2021
Sort the given array in descending order, i.e., arrange the elements from largest to smallest. 
Example:
Input :Array = {2, 6, 23, 98, 24, 35, 78}
Output:[98, 78, 35, 24, 23, 6, 2]

Input :Array = {1, 2, 3, 4, 5}
Output:[5, 4, 3, 2, 1]
Sorting is a process of arranging items systematically. sort() is an inbuilt function from java.util.Arrays which is used to sort an array of elements in optimized complexity.
There are numerous approaches to sort the given array in descending order in Java. A few of them are listed below.
Using Collections.reverseOrder() method
Using Sorting and reversing
Array elements can be sorted in descending order by passing in the array and Collections.reverseOrder() as parameters to Arrays.sort().
Note: One thing to keep in mind is that when sorting in descending order, Arrays.sort() does not accept an array of the primitive data type.
Implementation:
Java
// Java program to sort the elements in descending orderimport java.util.*;  class GFG {    public static void main(String[] args)    {          // Initializing the array        Integer array[] = { 1, 2, 3, 4, 5 };          // Sorting the array in descending order        Arrays.sort(array, Collections.reverseOrder());          // Printing the elements        System.out.println(Arrays.toString(array));    }}
[5, 4, 3, 2, 1]
Time Complexity:O(N log N)
Sort the given array.
Reverse the sorted array.
Below is the implementation of the above approach:  
Java
// Java program to sort the elements in descending orderimport java.util.*;  class GFG {    public static void main(String[] args)    {          // Initializing the array        int array[] = { 1, 2, 3, 4, 5, 6 };          // Sorting the array in ascending order        Arrays.sort(array);          // Reversing the array        reverse(array);          // Printing the elements        System.out.println(Arrays.toString(array));    }      public static void reverse(int[] array)    {          // Length of the array        int n = array.length;          // Swaping the first half elements with last half        // elements        for (int i = 0; i < n / 2; i++) {              // Storing the first half elements temporarily            int temp = array[i];              // Assigning the first half to the last half            array[i] = array[n - i - 1];              // Assigning the last half to the first half            array[n - i - 1] = temp;        }    }}
[6, 5, 4, 3, 2, 1]
Time Complexity: O(N log N) 
kashishsoda
nishkarshgandhi
Java-Array-Programs
Picked
Technical Scripter 2020
Java
Java Programs
Technical Scripter
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Node.js fs.createWriteStream() Method - GeeksforGeeks

04 May, 2022
The createWriteStream() method is an inbuilt application programming interface of fs module which allows to quickly make a writable stream for the purpose of writing data to a file. This method may be a smarter option compared to methods like fs.writeFile when it comes to very large amounts of data.
Syntax:
fs.createReadStream( path, options )

Parameters: This method accept two parameters as mentioned above and described below:
path: This parameter holds the path of the file where to read the file. It can be String, Buffer or URL.
options: It is an optional parameter that holds string or object.
Return Value: This method returns the fs.writeStream object.
Following example illustrates the createWriteStream() method in Node.js:
Example 1: This example uses fs.createWriteStream() method to write some content into the file.
Node.js
// Node.js program to demonstrate the // fs.createWriteStream() method   // Include fs module let fs = require('fs'),   // Use fs.createWriteStream() method // to write the file let writer = fs.createWriteStream('test_gfg.txt')   // Read and display the file data on console writer.write('GeeksforGeeks');
Output:
test_gfg.txt file data:
GeeksforGeeks

Example 2:  Piping from readable streams.
Node.js
// Node.js program to demonstrate the  // fs.createWriteStream() method   // Include fs module let fs = require('fs');   let writer = fs.createWriteStream('test_gfg.txt', {        flags: 'w'    });   // Use fs.createReadStream() method // to read the file let reader = fs.createReadStream('test_gfg.txt')         .pipe(writer);
With writable streams such as the streams created with fs.createWriteStream, data can be piped from a readable stream.
simranarora5sos
sathishs10
Node.js-fs-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to install the previous version of node.js and npm ?
Difference between promise and async await in Node.js
How to use an ES6 import in Node.js?
Express.js res.render() Function
Mongoose | findByIdAndUpdate() Function
Remove elements from a JavaScript Array
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 var, let and const keywords in JavaScript
Creating Series from list, dictionary, and numpy array in Pandas - GeeksforGeeks

08 Jun, 2020
Pandas Series is a one-dimensional labeled array capable of holding data of any type (integer, string, float, python objects, etc.). The axis labels are collectively called index. Pandas Series is nothing but a column in an excel sheet. In this article, we will see various ways of creating a series using different data types.
The list of some values form the series of that values uses list index as series index.
Python
# import pandas as pdimport pandas as pd  # simple listlst = ['G','E','E','K','S','F',       'O','R','G','E','E','K','S']  # forming seriess = pd.Series(lst)  # outputprint(s)
Output :
0     G
1     E
2     E
3     K
4     S
5     F
6     O
7     R
8     G
9     E
10    E
11    K
12    S
dtype: object

Dictionary of some key and value pair for the series of values taking keys as index of series.
Python3
# import pandas as pdimport pandas as pd  # simple dictdct = {'G':2,'E':4,'K':2,'S':2,       'F':1,'O':1,'R':1}  # forming seriess = pd.Series(dct)  # outputprint(s)
Output :
G    2
E    4
K    2
S    2
F    1
O    1
R    1
dtype: int64

The 1-D Numpy array  of some values form the series of that values uses array index as series index.
Python3
# import pandas as pdimport pandas as pd  # import numpy as npimport numpy as np  # numpy arrayarr = np.array(['G','E','E','K','S','F',                'O','R','G','E','E','K','S'])  # forming seriess = pd.Series(arr)  # outputprint(s)
Output :
0     G
1     E
2     E
3     K
4     S
5     F
6     O
7     R
8     G
9     E
10    E
11    K
12    S
dtype: object

pandas-series-program
Python pandas-series
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 | Get unique values from a list
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python | Pandas dataframe.groupby()
Python | Pandas Timestamp.hour - GeeksforGeeks

08 Jan, 2019
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas Timestamp.hour attribute return the value of the hour for the given Timestamp object.
Syntax : Timestamp.hour
Parameters : None
Return : hour
Example #1: Use Timestamp.hour attribute to find out the hour value in the given Timestamp object.
# importing pandas as pdimport pandas as pd  # Create the Timestamp objectts = pd.Timestamp(2017, 2, 15, 12)  # Print the Timestamp objectprint(ts)
Output :
Now we will use the Timestamp.hour attribute to find out hour value in the given Timestamp object.
# return the hour valuets.hour
Output :
As we can see in the output, the Timestamp.hour attribute has returned 12 as the hour value for the given Timestamp object.
 Example #2: Use Timestamp.hour attribute to find out the hour value in the given Timestamp object.
# importing pandas as pdimport pandas as pd  # Create the Timestamp objectts = pd.Timestamp(year = 2009, month = 10, day = 21,                     hour = 4, tz = 'Europe/Berlin')  # Print the Timestamp objectprint(ts)
Output :
Now we will use the Timestamp.hour attribute to find out hour value in the given Timestamp object.
# return the hour valuets.hour
Output :
As we can see in the output, the Timestamp.hour attribute has returned 4 as the hour value for the given Timestamp object.
Python Pandas-Timestamp
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
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()
numpy.binary_repr() in Python - GeeksforGeeks

29 Nov, 2018
numpy.binary_repr(number, width=None) function is used to represent binary form of the input number as a string.
For negative numbers, if width is not given, a minus sign is added to the front. If width is given, the two’s complement of the number is returned, with respect to that width.In a two’s-complement system, negative numbers are represented by the two’s complement of the absolute value. This is the most common method of representing signed integers on computers.
Syntax : numpy.binary_repr(number, width=None)
Parameters :number : Input number. Only an integer decimal number can be used as input.width : [int, optional] The length of the returned string if number is positive, or the length of the two’s complement if number is negative, provided that width is at least a sufficient number of bits for number to be represented in the designated form.If the width value is insufficient, it will be ignored, and number will be returned in binary (number > 0) or two’s complement (number < 0) form with its width equal to the minimum number of bits needed to represent the number in the designated form.
Return : binary string representation of the input number.
Code #1 : Working
# Python program explaining# binary_repr() function  import numpy as geekin_num = 10  print ("Input  number : ", in_num)  out_num = geek.binary_repr(in_num) print ("binary representation of 10 : ", out_num) 
Output :
Input  number :  10
binary representation of 10 :  1010

 Code #2 :
# Python program explaining# binary_repr() functionimport numpy as geek  in_arr = [5, -8 ]   print ("Input array : ", in_arr)   # binary representation of first array  # element without using width parameterout_num = geek.binary_repr(in_arr[0])print("Binary representation of 5")print ("Without using width parameter : ", out_num)   # binary representation of first array# element using width parameterout_num = geek.binary_repr(in_arr[0], width = 5)print ("Using width parameter: ", out_num)   print("\nBinary representation of -8")  # binary representation of 2nd array# element without using width parameterout_num = geek.binary_repr(in_arr[1])print ("Without using width parameter : ", out_num)   # binary representation of 2nd array# element  using width parameterout_num = geek.binary_repr(in_arr[1], width = 5)print ("Using width parameter : ", out_num) 
Output :
Input array :  [5, -8]
Binary representation of 5 
Without using width parameter :  101
Using width parameter:  00101

Binary representation of -8  
Without using width parameter :  -1000
Using width parameter :  11000
Python numpy-Binary Operation
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()
PyQt5 - Getting the role of selected item in ComboBox - GeeksforGeeks

22 Apr, 2020
In this article we will see how we can get the role of selected item in the combo box. Role is basically additional data provided with the item, in order get the role of selected item we use currentData method.
Syntax : combo_box.currentData()
Argument : It takes no argument
Return : It return string i.e role of selected item
Below is the implementation –
# importing librariesfrom PyQt5.QtWidgets import * from PyQt5 import QtCore, QtGuifrom PyQt5.QtGui import * from PyQt5.QtCore import * import sys    class Window(QMainWindow):      def __init__(self):        super().__init__()          # setting title        self.setWindowTitle("Python ")          # setting geometry        self.setGeometry(100, 100, 600, 400)          # calling method        self.UiComponents()          # showing all the widgets        self.show()      # method for widgets    def UiComponents(self):          # creating a combo box widget        self.combo_box = QComboBox(self)          # setting geometry of combo box        self.combo_box.setGeometry(200, 150, 120, 30)          # geek list        geek_list = ["Geek", "Geeky Geek", "Legend Geek", "Ultra Legend Geek"]          # adding list of items to combo box        self.combo_box.addItems(geek_list)          # setting roles to the items        self.combo_box.setItemData(0, "First role")        self.combo_box.setItemData(1, "Second role")        self.combo_box.setItemData(2, "Third role")        self.combo_box.setItemData(3, "Forth role")          # create push button        button = QPushButton("Show", self)          # adding action to the button        button.pressed.connect(self.show_role)          # creating label        self.label = QLabel(self)          # setting geometry of the label        self.label.setGeometry(200, 200, 200, 30)      def show_role(self):          # getting the role of selected item        role = self.combo_box.currentData()          # showing the role throw label        self.label.setText(role)  # create pyqt5 appApp = QApplication(sys.argv)  # create the instance of our Windowwindow = Window()  # start the appsys.exit(App.exec())
Output :
Python PyQt5-ComboBox
Python-gui
Python-PyQt
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
Node.js fsPromises.mkdir() Method - GeeksforGeeks

08 Oct, 2021
The fsPromises.mkdir() method is used to asynchronously create a directory then resolves the Promise with either no arguments, or the first directory path created if recursive is true.
Syntax:
fsPromises.mkdir(path, options)
Parameters: This method accept two parameters as mentioned above and described below:
path: This parameter is a String, Buffer or URL and holds the path of the directory has to be created.options: It is an Object or an Integerrecursive: This parameter holds the recursive boolean value. By default it is false.mode: The mode option is used to set the directory permission, by default it is 0777. It is a String or an Integer
path: This parameter is a String, Buffer or URL and holds the path of the directory has to be created.
options: It is an Object or an Integerrecursive: This parameter holds the recursive boolean value. By default it is false.mode: The mode option is used to set the directory permission, by default it is 0777. It is a String or an Integer
recursive: This parameter holds the recursive boolean value. By default it is false.
mode: The mode option is used to set the directory permission, by default it is 0777. It is a String or an Integer
Return Value: It returns the Promise object which represents the eventual completion (or failure) of an asynchronous operation, and its resulting value.
Below example illustrates the use of fsPromises.mkdir() method in Node.js.
Example:
// Node.js program to demonstrate // the fsPromises.mkdir() Method     // Include fs and path module const fs = require('fs');const fsPromises = fs.promises;  fsPromises.mkdir('fs_test2').then(function() {    console.log('Directory created successfully');}).catch(function() {    console.log('failed to create directory');});
Output:
Directory created successfully!
Node.js-fs-module
Node.js
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to connect Node.js with React.js ?
Node.js Export Module
Difference between dependencies, devDependencies and peerDependencies
Mongoose Populate() Method
Mongoose find() Function
Remove elements from a JavaScript Array
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
Difference between var, let and const keywords in JavaScript