code-rag-bench/online-tutorials huggingface dataset:
LeafletJS - Event Handling

The Leaflet JavaScript program can respond to various events generated by the user. In this chapter, we will provide a few examples demonstrating how to perform event handling while working with Leaflet.
Follow the steps given below to add events to the map.
Step 1 − Create a Map object by passing a <div> element (String or object) and map options (optional).
Step 2 − Create a Layer object by passing the URL of the desired tile.
Step 3 − Add the layer object to the map using the addLayer() method of the Map class.
Step 4 − Add the handler to the map, as shown below.
map.on("click", function(e){
   new L.Marker([e.latlng.lat, e.latlng.lng]).addTo(map);
})

The following code demonstrates even handling using Leaflet. When executed, if you click on the map, a marker will be created on that particular location.
<!DOCTYPE html>
<html>
   <head>
      <title>Leaflet Polygons</title>
      <link rel = "stylesheet" href = "http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"/>
      <script src = "http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
   </head>
   
   <body>
      <div id = "map" style = "width: 900px; height: 580px"></div>
      <script>
         // Creating map options
         var mapOptions = {
            center: [16.506174, 80.648015],
            zoom: 7
         }
         var map = new L.map('map', mapOptions);    // Creating a map object
         
         // Creating a Layer object
         var layer = new L.TileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');
         map.addLayer(layer); // Adding layer to the map
         
         map.on("click", function(e){
            new L.Marker([e.latlng.lat, e.latlng.lng]).addTo(map);
         })
      </script>
   </body>
   
</html>
It generates the following output −
 Print
 Add Notes
 Bookmark this page
Merging Arrays in Perl

Because an array in Perl is just a comma-separated sequence of values, you can combine them together as shown below −
 Live Demo
#!/usr/bin/perl
@numbers = (1,3,(4,5,6));
print "numbers = @numbers\n";
This will produce the following result −
numbers = 1 3 4 5 6
The embedded arrays just become a part of the main array as shown below −
 Live Demo
#!/usr/bin/perl
@odd = (1,3,5);
@even = (2, 4, 6);
@numbers = (@odd, @even);
print "numbers = @numbers\n";
This will produce the following result −
numbers = 1 3 5 2 4 6
Human-like mouse movements with Selenium.

We can do human-like mouse movements with Selenium. This can be done with the help of the Actions class. The human-like mouse movements include right-click, double-click, mouse movement, drag and drop, and so on.
To do the mouse movement, the moveToElement method is used. To perform a right-click, the contextClick method is used. Finally, to actually execute the actions, build and perform methods should be added.
Once we right-click on an element, various options get displayed. We have to add the import org.openqa.selenium.interactions.Actions package for implementing Actions.
Code Implementation.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
public class RightClick{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
      String u = " https://www.tutorialspoint.com/about/about_careers.htm";
      driver.get(u);
      // identify element
      WebElement m=driver.findElement(By.xpath("//*[text()='Careers']"));
      // moveToElement and contextClick
      Actions act = new Actions(driver);
      act.moveToElement(m).contextClick().build().perform();
   }
}
Count of common multiples of two numbers in a range in C++

We are given two numbers A and B. Also provided two numbers START and END to define a range of numbers. The Ath tile has paint white and Bth tile has paint black. If the tile is painted both black and white then it turns grey. The goal is to find the total number of grey tiles .
We will do this by traversing numbers from START to END and for each number we will check if the number is multiple of both A and B. If yes increment count.
Let’s understand with examples.
Input 
START=10 END=20 A=3 B=6
Output 
Common multiples of A and B ( grey tiles ): 2
Explanation 
Numbers 12, 18 are multiples of 3 and 6.
Input 
START=1 END=100 A=10 B=11
Output 
Common multiples of A and B ( grey tiles ): 0
Explanation 
No common multiple of 10 and 11 in range.
We take an integers START and END as range variables.
We take an integers START and END as range variables.
We take A and B as two variables.
We take A and B as two variables.
Function countGrey(int start, int end, int a, int b) takes range variables, a, b and returns the count of multiples of a and b.
Function countGrey(int start, int end, int a, int b) takes range variables, a, b and returns the count of multiples of a and b.
Take the initial variable count as 0 for such numbers.
Take the initial variable count as 0 for such numbers.
Traverse range of numbers using for loop. i=start to i=end
Traverse range of numbers using for loop. i=start to i=end
If i%a==0 && i%b==0. Then ‘i’ is multiple of both a and b.
If i%a==0 && i%b==0. Then ‘i’ is multiple of both a and b.
At the end of all loops count will have a total numbers which are multiples of ‘a’ and ‘b’
At the end of all loops count will have a total numbers which are multiples of ‘a’ and ‘b’
Return the count as result.
Return the count as result.
 Live Demo
#include <bits/stdc++.h>
using namespace std;
int countGrey(int start, int end, int a, int b){
   int count = 0;
   for (int i = start; i <= end; i++){
      if(i%a==0 && i%b==0) //tile is grey
         { count++; }
   }
   return count;
}
int main(){
   int START =10, END = 30;
   int A=4, B=3;
   cout <<"Common multiples of A and B ( grey tiles ): "<<
   countGrey(START,END, A, B);
   return 0;
}
If we run the above code it will generate the following output −
Common multiples of A and B ( grey tiles ): 2
Java program to find the area of a square

A square is a rectangle whose length and breadth are same. Therefore, Area of a rectangle is the square of its length. so, to calculate the area of a square
Get the length of the square form the user.
Calculate its square.
Print the square.
import java.util.Scanner;
public class AreaOfSquare {
   public static void main(String args[]){
      int length, area;
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the length of the square ::");
      length = sc.nextInt();
      area = length* length;
      System.out.println("Area of the square is ::"+area);
   }
}
Enter the length of the square ::
55
Area of the square is ::3025
How to create a row sum and a row product column in an R data frame?

To create a row sum and a row product column in an R data frame, we can use rowSums function and the star sign (*) for the product of column values inside the transform function. For example, if we have a data frame df that contains x, y, z then the column of row sums and row product can be created as:
transform(df,RowSums=rowSums(df),RowProducts=x*y*z)
Consider the below data frame:
Live Demo
> set.seed(3251)
> x1<-rpois(20,2)
> y1<-rpois(20,5)
> z1<-rpois(20,6)
> a1<-rpois(20,8)
> b1<-rpois(20,7)
> df1<-data.frame(x1,y1,z1,a1,b1)
> df1
x1 y1 z1 a1 b1
1 2 4 10 10 5
2 0 9 5 5 8
3 4 7 6 12 9
4 2 3 3 11 2
5 2 5 11 8 6
6 2 4 9 9 12
7 1 8 3 7 6
8 2 7 7 6 3
9 3 9 10 13 8
10 1 8 7 12 5
11 0 3 9 7 7
12 2 4 9 10 5
13 3 5 5 8 7
14 3 6 4 4 10
15 1 5 11 11 4
16 0 6 7 6 6
17 3 2 10 10 5
18 2 5 4 7 14
19 4 6 3 4 7
20 1 7 6 13 6
Creating row sums and row products column in df1:
> transform(df1,RowSums=rowSums(df1),RowProducts=x1*y1*z1*a1*b1)
x1 y1 z1 a1 b1 RowSums RowProducts
1 2 4 10 10 5 31 4000
2 0 9 5 5 8 27 0
3 4 7 6 12 9 38 18144
4 2 3 3 11 2 21 396
5 2 5 11 8 6 32 5280
6 2 4 9 9 12 36 7776
7 1 8 3 7 6 25 1008
8 2 7 7 6 3 25 1764
9 3 9 10 13 8 43 28080
10 1 8 7 12 5 33 3360
11 0 3 9 7 7 26 0
12 2 4 9 10 5 30 3600
13 3 5 5 8 7 28 4200
14 3 6 4 4 10 27 2880
15 1 5 11 11 4 32 2420
16 0 6 7 6 6 25 0
17 3 2 10 10 5 30 3000
18 2 5 4 7 14 32 3920
19 4 6 3 4 7 24 2016
20 1 7 6 13 6 33 3276
Let’s have a look at another example:
Live Demo
> x2<-sample(0:9,20,replace=TRUE)
> y2<-sample(0:9,20,replace=TRUE)
> z2<-sample(0:9,20,replace=TRUE)
> a2<-sample(0:9,20,replace=TRUE)
> b2<-sample(0:9,20,replace=TRUE)
> df2<-data.frame(x2,y2,z2,a2,b2)
> df2
x2 y2 z2 a2 b2
1 3 2 9 5 9
2 9 9 3 3 8
3 7 7 9 0 3
4 8 0 2 1 8
5 7 5 3 0 8
6 4 5 3 8 2
7 2 2 0 7 0
8 7 7 9 5 9
9 2 9 3 0 2
10 4 4 5 8 6
11 3 1 0 6 7
12 6 1 5 1 9
13 0 3 1 6 3
14 3 3 3 2 4
15 6 7 8 3 1
16 7 1 7 4 4
17 3 3 8 4 5
18 2 6 1 8 1
19 0 2 1 7 6
20 8 6 2 8 6
Creating row sums and row products column in df2:
> transform(df2,RowSums=rowSums(df2),RowProducts=x2*y2*z2*a2*b2)
x2 y2 z2 a2 b2 RowSums RowProducts
1 3 2 9 5 9 28 2430
2 9 9 3 3 8 32 5832
3 7 7 9 0 3 26 0
4 8 0 2 1 8 19 0
5 7 5 3 0 8 23 0
6 4 5 3 8 2 22 960
7 2 2 0 7 0 11 0
8 7 7 9 5 9 37 19845
9 2 9 3 0 2 16 0
10 4 4 5 8 6 27 3840
11 3 1 0 6 7 17 0
12 6 1 5 1 9 22 270
13 0 3 1 6 3 13 0
14 3 3 3 2 4 15 216
15 6 7 8 3 1 25 1008
16 7 1 7 4 4 23 784
17 3 3 8 4 5 23 1440
18 2 6 1 8 1 18 96
19 0 2 1 7 6 16 0
20 8 6 2 8 6 30 4608
How to uninstall the MSI package using PowerShell?

To uninstall the MSI package using PowerShell, we need the product code and then the product code can be used with msiexec file to uninstall the particular application.
Product code can be retrieved using the Get-Package or Get-WmiClass method. In this example, we will uninstall the 7-zip package.
$product = Get-WmiObject win32_product | `
where{$_.name -eq "7-Zip 19.00 (x64 edition)"}
$product.IdentifyingNumber
The above command will retrieve the product code. To uninstall the product using msiexec, use /x switch with the product id. The below command will uninstall the 7-zip using the above-retrieved code.
msiexec /x $product.IdentifyingNumber /quiet /noreboot
This is the cmd command but we can run in PowerShell, however we can’t control the execution of this command. For example, the next command after this would be executed immediately. To wait until the uninstall completes, we can use the Start-Process in PowerShell which uses the -Wait argument.
Start-Process "C:\Windows\System32\msiexec.exe" `
-ArgumentList "/x $($product.IdentifyingNumber) /quiet /noreboot" -Wait
To run the same commands on the remote computers, use Invoke-Command.
Invoke-Command -ComputerName TestComp1, TestComp2 `
   -ScriptBlock {
      $product = Get-WmiObject win32_product | where{$_.name -eq "7-Zip 19.00 (x64 edition)"}
      $product.IdentifyingNumber
      Start-Process "C:\Windows\System32\msiexec.exe" `
      -ArgumentList "/x $($product.IdentifyingNumber) /quiet /noreboot" -Wait
   }
Incremental Programming in Python - GeeksforGeeks

02 Feb, 2022
In incremental systems, every measurement refers to a previously dimensioned position (point-to-point). Incremental dimensions are the distances between two adjacent points. An incremental movement moves A distance based on your current position.
Start Small – First of all, start your program small and kept that working instead of writing many lines without having the idea of whether the program is correctly working or there is some error in it.
Keep It Working – Now as our small part is working fine then we should start adding another small part of the program to our main program and check whether it works fine or not. If there is any error you can find it at the first. Once there is no error the keep repeating the second step until our problem is met.
By doing this we can avoid lots of error at the last time when we are compiling the entire code and we will be confused by the whole lots of error showing. Because we will be eliminating all the errors side by side when we add a small part of the program to our main code.
Basically we follow this method of programming unknowingly. It is one of the best method of programming that the programmers can practice in their daily code.
We will see a simple example of how the incremental programming works with a simple program in Python by constructing a house, as it the best example that we can see in our day to day life. We will be using the turtle module.
Python3
# importing the moduleimport turtle  wn = turtle.Screen()house = turtle.Turtle()
2. First let us draw a vertical line
Python3
house.right(90)house.forward(50)house.left(90)house.forward(50)
3. We add a horizontal line at the bottom
Python3
house.left(90)house.forward(50)
4. In this we can add one vertical and horizontal line so that we can get a shape of a box.
Python3
house.left(90)house.forward(50)house.left(90)house.forward(50)
5. Now we have to add the roof to make the house complete.
Python3
house.left(180)house.left(60)house.forward(50)house.right(120)house.forward(50
Another example you can see is that the CNC machines also use this technique for the process. Like shown above if we divide our program into small parts it will be very helpful for us to write an error-free code.
as5853535
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Selecting rows in pandas DataFrame based on conditions
Create a directory in Python
Python | Pandas dataframe.groupby()
Ruby - Environment Variables

Ruby interpreter uses the following environment variables to control its behavior. The ENV object contains a list of all the current environment variables set.
DLN_LIBRARY_PATH
Search path for dynamically loaded modules.
HOME
Directory moved to when no argument is passed to Dir::chdir. Also used by File::expand_path to expand "~".
LOGDIR
Directory moved to when no arguments are passed to Dir::chdir and environment variable HOME isn't set.
PATH
Search path for executing subprocesses and searching for Ruby programs with the -S option. Separate each path with a colon (semicolon in DOS and Windows).
RUBYLIB
Search path for libraries. Separate each path with a colon (semicolon in DOS and Windows).
RUBYLIB_PREFIX
Used to modify the RUBYLIB search path by replacing prefix of library path1 with path2 using the format path1;path2 or path1path2.
RUBYOPT
Command-line options passed to Ruby interpreter. Ignored in taint mode (Where $SAFE is greater than 0).
RUBYPATH
With -S option, search path for Ruby programs. Takes precedence over PATH. Ignored in taint mode (where $SAFE is greater than 0).
RUBYSHELL
Specifies shell for spawned processes. If not set, SHELL or COMSPEC are checked.
For Unix, use env command to see a list of all the environment variables.
HOSTNAME = ip-72-167-112-17.ip.secureserver.net
RUBYPATH = /usr/bin
SHELL = /bin/bash
TERM = xterm
HISTSIZE = 1000
SSH_CLIENT = 122.169.131.179 1742 22
SSH_TTY = /dev/pts/1
USER = amrood
JRE_HOME = /usr/java/jdk/jre
J2RE_HOME = /usr/java/jdk/jre
PATH = /usr/local/bin:/bin:/usr/bin:/home/guest/bin
MAIL = /var/spool/mail/guest
PWD = /home/amrood
INPUTRC = /etc/inputrc
JAVA_HOME = /usr/java/jdk
LANG = C
HOME = /root
SHLVL = 2
JDK_HOME = /usr/java/jdk
LOGDIR = /usr/log/ruby
LOGNAME = amrood
SSH_CONNECTION = 122.169.131.179 1742 72.167.112.17 22
LESSOPEN = |/usr/bin/lesspipe.sh %s
RUBYLIB = /usr/lib/ruby
G_BROKEN_FILENAMES = 1
_ = /bin/env


    46 Lectures 
     9.5 hours 

 Eduonix Learning Solutions

    97 Lectures 
     7.5 hours 

 Skillbakerystudios

    227 Lectures 
     40 hours 

 YouAccel

    19 Lectures 
     10 hours 

 Programming Line

    51 Lectures 
     5 hours 

 Stone River ELearning

    39 Lectures 
     4.5 hours 

 Stone River ELearning
 Print
 Add Notes
 Bookmark this page
HTML | <hr> size Attribute

28 May, 2019
The HTML <hr> size Attribute is used to specify the height of the horizontal line in terms of pixels.
Syntax:
<hr size="pixels">
Attribute Values: It contains single value pixels which specify the height in terms of pixels.
Note: The <hr> size Attribute is not supported by HTML 5.
Example:
<!DOCTYPE html><html>  <head>    <title>        HTML hr size Attribute    </title></head>  <body style="text-align:center;">    <h1>GeeksforGeeks</h1>    <hr width="500px;"         size="10">    <p>Computer science portal</p>    <hr width="70%"         size="20"></body>  </html>
Output:
Supported Browsers: The browser supported by HTML <hr> size Attribute are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to use multiple ternary operators in a single statement in JavaScript ?

08 Mar, 2021
In this article, we will see how we can use multiple ternary operators in a single statement in JavaScript. Sometimes using conditional statements like if, else, else if stretch the code unnecessarily and make the code even more lengthy. One trick to avoid them can be the use of ternary operators. But what if we are to use multiple if-else statements? Such issues can be tackled using multiple ternary operators in a single statement.
Syntax:
condition1 ? condition2 ? Expression1 : Expression2 : Expression3
In the above syntax, we have tested 2 conditions in a single statement using the ternary operator. In the syntax, if condition1 is incorrect then Expression3 will be executed else if condition1 is correct then the output depends on the condition2. If condition2 is correct, then the output is Expression1. If it is incorrect, then the output is Expression2.
In the above syntax, we can see how we can use more than one ternary operator in a single statement. Below is an example explaining how we can use 2 ternary operators in a single statement.
Example 1:
Javascript
<script>  const age = 45; age > 30 ? age > 70 ?   console.log("You are getting old") :  console.log("You are between 30 and 69") :   console.log("You are bellow 30");</script>;
Output:
You are between 30 and 69
Example 2:
Javascript
<script>  const num = 12; num != 0 ? num > 0 ?   console.log("Entered number is positive") :   console.log("Entered number is negative") :   console.log("You entered zero");</script>
Output:
Entered number is positive
javascript-operators
JavaScript-Questions
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Remove elements from a JavaScript Array
Difference Between PUT and PATCH Request
Roadmap to Learn JavaScript For Beginners
JavaScript | Promises
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Python Indexerror: list assignment index out of range Solution

04 Jan, 2022
In python, lists are mutable as the elements of a list can be modified. But if you try to modify a value whose index is greater than or equal to the length of the list then you will encounter an Indexerror: list assignment index out of range.  
If ‘fruits’ is a list, fruits=[‘Apple’,’ Banana’,’ Guava’]and you try to modify fruits[5] then you will get an index error since the length of fruits list=3 which is less than index asked to modify for which is 5.
Python3
# list of fruitsfruits = ['Apple', 'Banana', 'Guava']    # to check type of fruitsprint("Type is", type(fruits))  fruits[5] = 'Mango'
Output:
Traceback (most recent call last):
 File "/example.py", line 3, in <module>
   fruits[5]='Mango'
IndexError: list assignment index out of range
So, as you can see in the above example, we get an error when we try to modify an index that is not present in the list of fruits.
The insert(index, element) function takes two arguments, index and element, and adds a new element at the specified index.
Let’s see how you can add Mango to the list of fruits on index 1.
Python3
fruits = ['Apple', 'Banana', 'Guava']print("Original list:", fruits)  fruits.insert(1, "Mango")print("Modified list:", fruits)
Output:
Original list: ['Apple', 'Banana', 'Guava']
Modified list: ['Apple', 'Mango', 'Banana', 'Guava']
It is necessary to specify the index in the insert(index, element) function, otherwise, you will an error that the insert(index, element) function needed two arguments.
The append(element) function takes one argument element and adds a new element at the end of the list.
Let’s see how you can add Mango to the end of the list using the append(element) function.
Python3
fruits = ['Apple', 'Banana', 'Guava']print("Original list:", fruits)  fruits.append("Mango")print("Modified list:", fruits)
Output:
Original list: ['Apple', 'Banana', 'Guava']
Modified list: ['Apple', 'Banana', 'Guava', 'Mango']
Python How-to-fix
python-list
Python
python-list
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Python | datetime.timedelta() function
How to embed JavaScript in HTML file?

Following is the code to embed JavaScript in html file −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="script.js" defer></script>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .result {
      font-size: 18px;
      font-weight: 500;
      color: rebeccapurple;
   }
</style>
</head>
<body>
<h1>Embed javascript in html file</h1>
<div class="result"></div>
<script>
   let resEle = document.querySelector(".result");
   resEle.innerHTML += "Inline javaScript loaded" + "<br>";
</script>
</body>
</html>
script.js
resEle.innerHTML += 'External JavaScript loaded ';
The above code will produce the following output −
How to create HTML form that accept user name and display it using PHP ?

24 Jun, 2021
Through HTML forms various data can be collected from the user and can be sent directly to the server through PHP scripting. There are basically two methods for sending data to the server one is “GET” and the other one is “POST”.
In GET method, the data goes through the browser’s URL and can be seen by anyone using the browser, and it is not very safe when sending crucial or highly confidential data. But with the POST method, the data is directly sent to the server, and it can’t be seen by anyone, and it is considered the most secure way to send the information to the server. 
Generally, the GET method is used by the search engines because it reads the data but for the data to be maintained or changed, the POST method is used for it.
Approach: We will see one example of the HTML form collecting the first and last name of the person and sending the data to the DOM which eventually displays the data on the screen using PHP script. 
 
Example:
HTML
<!DOCTYPE html><html>  <body>    <!-- Heading -->    <h3> HTML input form </h3>      <!-- HTML form  -->    <form method="POST">        <h4>Please enter your First Name : </h4>        <input type="text" name="f_name"><br>        <h4>Please enter your Last Name : </h4>        <input type="text" name="l_name"><br><br>          <input type="submit" value="Display" name="submit">    </form></body>  </html><?php          // When the submit button is clicked    if (isset($_POST['submit'])) {              // Creating variables and         // storing values in it        $f_name = $_POST['f_name'];        $l_name = $_POST['l_name'];          echo "<h1><i> Good Morning, $f_name $l_name </i></h1>";    }?>
Output:
HTML-Questions
PHP-function
PHP-Questions
Picked
HTML
PHP
Web Technologies
HTML
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
REST API (Introduction)
Design a Tribute Page using HTML & CSS
Build a Survey Form using HTML and CSS
Design a web page using HTML and CSS
Angular File Upload
How to execute PHP code using command line ?
PHP in_array() Function
How to delete an array element based on key in PHP?
How to convert array to string in PHP ?
How to pop an alert message box using PHP ?
Difference between for and do-while loop in C, C++, Java

27 Jun, 2019
for loop:
for loop provides a concise way of writing the loop structure. Unlike a while loop, a for statement consumes the initialization, condition and increment/decrement in one line thereby providing a shorter, easy to debug structure of looping.
Syntax:
for (initialization condition; testing condition; 
                              increment/decrement)
{
    statement(s)
}

Flowchart:
Example:
C
C++
Java
#include <stdio.h>  int main(){      int i = 0;      for (i = 5; i < 10; i++) {        printf("GFG\n");    }      return 0;}
#include <iostream>using namespace std;  int main(){      int i = 0;      for (i = 5; i < 10; i++) {        cout << "GFG\n";    }      return 0;}
import java.io.*;  class GFG {    public static void main(String[] args)    {          int i = 0;          for (i = 5; i < 10; i++) {            System.out.println("GfG");        }    }}
GFG
GFG
GFG
GFG
GFG

do-while loop:
do while loop is similar to while loop with the only difference that it checks for the condition after executing the statements, and therefore is an example of Exit Control Loop.
Syntax:
do
{
    statements..
}
while (condition);

Flowchart:
Example:
C
C++
Java
#include <stdio.h>  int main(){      int i = 5;      do {        printf("GFG\n");        i++;    } while (i < 10);      return 0;}
#include <iostream>using namespace std;  int main(){      int i = 5;      do {        i++;        cout << "GFG\n";    } while (i < 10);      return 0;}
import java.io.*;  class GFG {    public static void main(String[] args)    {          int i = 5;          do {            i++;            System.out.println("GfG");        } while (i < 10);    }}
GFG
GFG
GFG
GFG
GFG

Here is the difference table:
loop
Loops & Control Structure
Difference Between
Programming Language
School Programming
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
JavaScript | Math.ceil( ) function

02 Feb, 2022
The Math.ceil() function in JavaScript is used to round the number passed as a parameter to its nearest integer in Upward direction of rounding i.e towards the greater value.Syntax  
Math.ceil(value)
Parameters: This function accepts a single parameter is the number to be rounded to its the nearest integer in upward rounding method. Returns: Result after rounding the number passed as parameter to the function.Examples:  
Input  : Math.ceil(4.23)
Output : 5

Input  : Math.ceil(0.8)
Output : 1
Errors and Exceptions:  
A non-numeric string passed as parameter returns NaN
An array with more than 1 integer passed as parameter returns NaN
An empty variable passed as parameter returns NaN
An empty string passed as parameter returns NaN
An empty array passed as parameter returns NaN
Below are some examples that illustrate the Math.ceil() function in JavaScript: 
Example: 1  
HTML
<!-- NEGATIVE NUMBER EXAMPLE --><script type="text/javascript">    document.write(Math.ceil(-2) + "<br>");    document.write(Math.ceil(-2.56));         </script>
Output: 
-2
-2
Example:2  
HTML
<!-- POSITIVE NUMBER EXAMPLE --><script type="text/javascript">    document.write(Math.ceil(2) + "<br>");    document.write(Math.ceil(2.56));         </script>
Output: 
2
3
Example 2: 
HTML
<!-- STRING EXAMPLE --><script type="text/javascript">    document.write(Math.ceil("Geeksforgeeks"));         </script>
Output: 
NaN
Example:3 
HTML
<!-- ADDITION INSIDE FUNCTION EXAMPLE --><script type="text/javascript">    document.write(Math.ceil(7+9));          </script>
Output:  
16
Supported Browsers: The browsers supported by JavaScript Math.ceil( ) function are listed below: 
Google Chrome 1 and above
Internet Explorer 12 and above
Firefox 1 and above
Opera 3 and above
Safari 1 and above
ysachin2314
javascript-math
JavaScript
Mathematical
Mathematical
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between var, let and const keywords in JavaScript
Differences between Functional Components and Class Components in React
Remove elements from a JavaScript Array
Hide or show elements in HTML using display property
Difference Between PUT and PATCH Request
Program for Fibonacci numbers
Set in C++ Standard Template Library (STL)
Write a program to print all permutations of a given string
C++ Data Types
Merge two sorted arrays
Python | Creating Multidimensional dictionary

22 Jun, 2021
Sometimes, while working with Python dictionaries we need to have nested dictionaries. But the issue is that, we have to declare before initializing a value in nested dictionary. Let’s resolve this particular problem via methods discussed in this article.
Method #1 : Using setdefault() This function is used to define an empty dictionary on 1st nested level of dictionary to make it 2D. In this case there is no need to define explicit dictionaries at that level of dictionary. 
Python3
# Python3 code to demonstrate working of# Creating Multidimensional dictionary# Using setdefault() # Initialize dictionarytest_dict = {} # printing original dictionaryprint("The original dictionary : " +  str(test_dict)) # Using setdefault()# Creating Multidimensional dictionarytest_dict.setdefault(1, {})[4] = 7 # printing resultprint("Dictionary after nesting : " + str(test_dict))
The original dictionary : {}
Dictionary after nesting : {1: {4: 7}}
 
Method #2 : Using defaultdict() One can achieve the creation of multi nesting using defaultdict(). Not only at one level, but till N level the nesting can be achieved using this. Drawback is that it creates the defaultdict objects.
Python3
# Python3 code to demonstrate working of# Creating Multidimensional dictionary# Using defaultdict()from collections import defaultdict # Utility function to create dictionarydef multi_dict(K, type):    if K == 1:        return defaultdict(type)    else:        return defaultdict(lambda: multi_dict(K-1, type)) # Initialize dictionarytest_dict = {} # printing original dictionaryprint("The original dictionary : " +  str(test_dict)) # Using defaultdict()# Creating Multidimensional dictionary# calling functiontest_dict = multi_dict(3, int)test_dict[2][3][4] = 1 # printing resultprint("Dictionary after nesting : " + str(dict(test_dict)))
The original dictionary : {}
Dictionary after nesting : {2: defaultdict(<function multi_dict.<locals>.<lambda> at 0x7f8707a54158>, {3: defaultdict(<class 'int'>, {4: 1})})}
 
simmytarika5
Python dictionary-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Tryit Editor v3.7

Tryit: HTML comment out sections
Program to convert HashMap to TreeMap in Java

At first create a HashMap −
Map<String, String> map = new HashMap<>();
map.put("1", "One");
map.put("2", "Two");
map.put("3", "Three");
map.put("4", "Four");
map.put("5", "Five");
map.put("6", "Six");
Now, convert the above HashMap to TreeMap −
Map<String, String> treeMap = new TreeMap<>();
treeMap.putAll(map);
Following is the program to convert HashMap to TreeMap in Java −
import java.util.*;
import java.util.stream.*;
public class Demo {
   public static void main(String args[]) {
      Map<String, String> map = new HashMap<>();
      map.put("1", "One");
      map.put("2", "Two");
      map.put("3", "Three");
      map.put("4", "Four");
      map.put("5", "Five");
      map.put("6", "Six");
      map.put("7", "Seven");
      map.put("8", "Eight");
      map.put("9", "Nine");
      System.out.println("HashMap = " + map);
      Map<String, String> treeMap = new TreeMap<>();
      treeMap.putAll(map);
      System.out.println("TreeMap (HashMap to TreeMap) " + treeMap);
   }
}
HashMap = {1=One, 2=Two, 3=Three, 4=Four, 5=Five, 6=Six, 7=Seven, 8=Eight, 9=Nine}
TreeMap (HashMap to TreeMap) {1=One, 2=Two, 3=Three, 4=Four, 5=Five, 6=Six, 7=Seven, 8=Eight, 9=Nine}
Longest Palindrome in C++

Suppose we have a string which consists of lowercase or uppercase letters, we have to find the length of the longest palindromes that can be built with those letters. Now the string is case sensitive, so "Aa" is not considered a palindrome here.
So, if the input is like "abccccdd", then the output will be 7, as one longest palindrome that can be built is "dccaccd", whose length is 7.
To solve this, we will follow these steps −
Define one map mp
Define one map mp
for each character i in s(increase mp[i] by 1)
for each character i in s
(increase mp[i] by 1)
(increase mp[i] by 1)
ma := 0, c := 0, ans := 0
ma := 0, c := 0, ans := 0
for each key-value pair i in mpif value of imod 2 is same as 1, then −(increase ma by 1)c := c + value of i
for each key-value pair i in mp
if value of imod 2 is same as 1, then −(increase ma by 1)
if value of imod 2 is same as 1, then −
(increase ma by 1)
(increase ma by 1)
c := c + value of i
c := c + value of i
if ma > 0, then −(decrease ma by 1)
if ma > 0, then −
(decrease ma by 1)
(decrease ma by 1)
ans := c - ma
ans := c - ma
return ans
return ans
Let us see the following implementation to get a better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
   int longestPalindrome(string s) {
      unordered_map<char, int> mp;
      for (auto i : s)
         mp[i]++;
      int ma = 0, c = 0, ans = 0;
      for (auto i : mp) {
         if ((i.second) % 2 == 1)
            ma++;
         c += i.second;
      }
      if (ma > 0)
         ma--;
      ans = c - ma;
      return ans;
   }
};
main(){
   Solution ob;
   cout << (ob.longestPalindrome("abccccdd"));
}
"abccccdd"
7
CSS | brightness() Function - GeeksforGeeks

07 Aug, 2019
The brightness() function is an inbuilt function which is used to apply a filter to set the brightness of the image. This function uses the linear multiplier to the image to increase or decrease brightness.
Syntax:
brightness( amount )
Parameters: This function accepts single parameter amount which holds the amount of brightness. The value of brightness is set in terms of number and percentage. The value 0% represents completely black image and 100% represents the original image.
Below example illustrates the brightness() function in CSS:
Example:
<!DOCTYPE html> <html>   <head>     <title>CSS brightness() Function</title>           <style>        h1 {            color:green;        }        body {            text-align:center;        }        .brightness_effect {            filter: brightness(10%);        }    </style></head>   <body>     <h1>GeeksforGeeks</h1>           <h2>CSS brightness() function</h2>          <img class="brightness_effect" src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"        alt="GeeksforGeeks logo"> </body>   </html>
Output:
Supported Browsers: The browsers supported by brightness() function are listed below:
Google Chrome
Internet Explorer
Firefox
Safari
Opera
CSS-Functions
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to create footer to stay at the bottom of a Web page?
Types of CSS (Cascading Style Sheet)
How to position a div at the bottom of its container using CSS?
Design a web page using HTML and CSS
Create a Responsive Navbar using ReactJS
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
C library function - isxdigit()

The C library function int isxdigit(int c) checks whether the passed character is a hexadecimal digit.
Following is the declaration for isxdigit() function.
int isxdigit(int c);
c − This is the character to be checked.
c − This is the character to be checked.
This function returns a non-zero value(true) if c is a hexadecimal digit else, zero (false).
The following example shows the usage of isxdigit() function.
#include <stdio.h>
#include <ctype.h>

int main () {
   char var1[] = "tuts";
   char var2[] = "0xE";
  
   if( isxdigit(var1[0]) ) {
      printf("var1 = |%s| is hexadecimal character\n", var1 );
   } else {
      printf("var1 = |%s| is not hexadecimal character\n", var1 );
   }
   
   if( isxdigit(var2[0] )) {
      printf("var2 = |%s| is hexadecimal character\n", var2 );
   } else {
      printf("var2 = |%s| is not hexadecimal character\n", var2 );
   }
   
   return(0);
}
Let us compile and run the above program to produce the following result −
var1 = |tuts| is not hexadecimal character
var2 = |0xE| is hexadecimal character


    12 Lectures 
     2 hours 

 Nishant Malik

    12 Lectures 
     2.5 hours 

 Nishant Malik

    48 Lectures 
     6.5 hours 

 Asif Hussain

    12 Lectures 
     2 hours 

 Richa Maheshwari

    20 Lectures 
     3.5 hours 

 Vandana Annavaram

    44 Lectures 
     1 hours 

 Amit Diwan
 Print
 Add Notes
 Bookmark this page
GATE | GATE CS 2012 | Question 28

27 Sep, 2021
What is the minimal form of the Karnaugh map shown below? Assume that X denotes a don’t care term.
(A) b’d’(B) b’d’ + b’c’(C) b’d’ + a’b’c’d’(D) b’d’ + b’c’ + c’d’Answer: (B)Explanation: There are two prime implicants in the following K-Map-Prime Implicant higlighted in Green = Prime Implicant higlighted in Orange = So the Boolean expression is- 
Therefore option (B) is correct.
This explanation is provided by Chirag Manwani.
Boolean Functions and Canonical Forms continued With Rishabh Setiya | GeeksforGeeks GATE - YouTubeGeeksforGeeks GATE Computer Science17.5K subscribersBoolean Functions and Canonical Forms continued With Rishabh Setiya | GeeksforGeeks GATEWatch laterShareCopy linkInfoShoppingTap to unmuteIf playback doesn't begin shortly, try restarting your device.You're signed outVideos you watch may be added to the TV's watch history and influence TV recommendations. To avoid this, cancel and sign in to YouTube on your computer.CancelConfirmMore videosMore videosSwitch cameraShareInclude playlistAn error occurred while retrieving sharing information. Please try again later.Watch on0:000:0026:20 / 29:56•Live•<div class="player-unavailable"><h1 class="message">An error occurred.</h1><div class="submessage"><a href="https://www.youtube.com/watch?v=rnyA7f5qTm0" target="_blank">Try watching this video on www.youtube.com</a>, or enable JavaScript if it is disabled in your browser.</div></div>Quiz of this Question
GATE-CS-2012
GATE-GATE CS 2012
Computer Organization and Architecture
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Pipelining in ARM
External Memory Interfacing in 8051 Microcontroller
Difference Between ALU and CU
Difference between MCU and SoC
What is POST(Power-On-Self-Test)?
4 Bit Binary Incrementer
Advanced RISC Machine (ARM) Processor
8086 program to find Square Root of a number
Python program to represent floating number as hexadecimal by IEEE 754 standard
Difference between Cache Coherence and Memory Consistency
How to create a List with Constructor in C++ STL

18 Jan, 2019
Lists are sequence containers that allow non-contiguous memory allocation. As compared to vector, list has slow traversal, but once a position has been found, insertion and deletion are quick. Normally, when we say a List, we talk about doubly linked list. For implementing a singly linked list, we use forward list.
A list can be created with the help of constructor in C++. The syntax to do it is:Syntax:
list<type> list_name(size_of_list, value_to_be_inserted);
Below programs show how to create a List with Constructor in C++.
Program 1:
#include <iostream>#include <list>using namespace std;  // Function to print the listvoid printList(list<int> mylist){      // Get the iterator    list<int>::iterator it;      // printing all the elements of the list    for (it = mylist.begin(); it != mylist.end(); ++it)        cout << ' ' << *it;    cout << '\n';}  int main(){    // Create a list with the help of constructor    // This will insert 100 10 times in the list    list<int> myList(10, 100);      printList(myList);      return 0;}
100 100 100 100 100 100 100 100 100 100

Program 2:
#include <bits/stdc++.h>using namespace std;  // Function to print the listvoid printList(list<string> mylist){      // Get the iterator    list<string>::iterator it;      // printing all the elements of the list    for (it = mylist.begin(); it != mylist.end(); ++it)        cout << ' ' << *it;    cout << '\n';}  int main(){    // Create a list with the help of constructor    // This will insert Geeks 5 times in the list    list<string> myList(5, "Geeks");      printList(myList);      return 0;}
Geeks Geeks Geeks Geeks Geeks

cpp-list
STL
C++
STL
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Set in C++ Standard Template Library (STL)
Priority Queue in C++ Standard Template Library (STL)
vector erase() and clear() in C++
unordered_map in C++ STL
Substring in C++
Object Oriented Programming in C++
C++ Classes and Objects
Sorting a vector in C++
C++ Data Types
Virtual Function in C++
Rest and Spread operators in JavaScript

The rest operator (...) allows us to call a function with any number of arguments and then access those excess arguments as an array. The rest operator also allows us in destructuring array or objects.
The spread operator (...) allows us to expand an iterable like array into its individual elements.
Following is the code showing the rest and spread operator in JavaScript −
 Live Demo
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
   .sample, .result {
      font-size: 20px;
      font-weight: 500;
   }
</style>
</head>
<body>
<h1>JavaScript Rest and spread operator</h1>
<div class="sample"></div>
<div style="color: green;" class="result"></div&g;
<button class="btn">Spread Operator</button>
<h3>
Click on the above button to concatenate array using spread operator
</h3>
<button class="btn">Rest Operator</button>
<div style="color: green;" class="result"></div>
<h3>
Click on the above button to add some numbers using rest operator
</h3>
<script>
   let sampleEle = document.querySelector(".sample");
   let btnEle = document.querySelectorAll(".btn");
   let resEle = document.querySelectorAll(".result");
   let arr = [2, 3, 4, 5];
   let arr1 = ["a", "b", "c", "d"];
   sampleEle.innerHTML = "arr = " + arr + "<br> arr1 = " + arr1;
   function addArr(num, ...ar) {
      let sum = num;
      ar.forEach((item) => {
         sum += item;
      });
      resEle[1].innerHTML = "Sum of the elements = " + sum;
   }
   btnEle[0].addEventListener("click", () => {
      resEle[0].innerHTML = "Concatenated array = " + [...arr, ...arr1];
   });
   btnEle[1].addEventListener("click", () => {
      addArr(44, 11, 35, 44, 22, 99);
   });
</script>
</body>
</html>
The above code will produce the following output −
On clicking the “Spread Operator” button −
On clicking the “Rest Operator” button −
Python | Pandas Timedelta.nanoseconds

14 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.
Timedelta is a subclass of datetime.timedelta, and behaves in a similar manner. It is the pandas equivalent of python’s datetime.timedelta and is interchangeable with it in most cases. Timedelta.nanoseconds property in pandas.Timedelta is used to return Number of nanoseconds.
Syntax: Timedelta.nanoseconds
Parameters: None
Returns: return the Number of nanoseconds.
Code #1:
# importing pandas as pd import pandas as pd   # Create the Timedelta object td = pd.Timedelta('3 days 06:05:01.000000111')   # Print the Timedelta object print(td)   print(td.nanoseconds)
3 days 06:05:01.000000
111

Code #2:
# importing pandas as pd import pandas as pd   # Create the Timedelta object td = pd.Timedelta('7 days 15 min 3 s 42 ns')   # Print the Timedelta object print(td)   print(td.nanoseconds)
7 days 00:15:03.000000
42

Code #3:
# importing pandas as pd import pandas as pd import datetime  # Create the Timedelta object td = pd.Timedelta(133, unit ='ns')  # Print the Timedelta object print(td)   print(td.nanoseconds)
0 days 00:00:00.000000
133

Python pandas-timedelta
Python-pandas
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Create a directory in Python
GATE | GATE CS 2013 | Question 65

19 Nov, 2018
A RAM chip has a capacity of 1024 words of 8 bits each (1K × 8). The number of 2 × 4 decoders with enable line needed to construct a 16K × 16 RAM from 1K × 8 RAM is(A) 4(B) 5(C) 6(D) 7Answer: (B)Explanation:
RAM chip size = 1k ×8[1024 words of 8 bits each]
RAM to construct =16k ×16
Number of chips required = (16k x 16)/ ( 1k x 8)
                         = (16 x 2)
[16 chips vertically with each having 2 chips
horizontally]
So to select one chip out of 16 vertical chips, 
we need 4 x 16 decoder.

Available decoder is  2 x 4 decoder
To be constructed is 4 x 16 decoder

Hence 4 + 1 = 5 decoders are required.
Quiz of this Question
GATE-CS-2013
GATE-GATE CS 2013
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Does C++ compiler create default constructor when we write our own?

03 Jun, 2022
No, the C++ compiler doesn’t create a default constructor when we initialize our own, the compiler by default creates a default constructor for every class; But, if we define our own constructor, the compiler doesn’t create the default constructor. This is so because the default constructor does not take any argument and if two default constructors are created, it is difficult for the compiler which default constructor should be called.
Example 1 compiles without any error, but the compilation of program 2 fails with the error “no matching function for call to `myInteger::myInteger()’ ” 
Example 1: 
CPP
// C++ program to demonstrate a program without any error#include <iostream> using namespace std; class myInteger {private:    int value;     //...other things in class}; int main(){    myInteger I1;    getchar();    return 0;}
Example 2:
CPP
// C++ program to demonstrate a program which will throw an// error#include <iostream> using namespace std; class myInteger {private:    int value; public:    myInteger(int v) // parameterized constructor    {        value = v;    }     //...other things in class}; int main(){    myInteger I1;    getchar();    return 0;}
tiwarisakshi1302
anikaseth98
chhabradhanvi
harsh_shokeen
C Language
C++
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Unordered Sets in C++ Standard Template Library
What is the purpose of a function prototype?
Operators in C / C++
Exception Handling in C++
TCP Server-Client implementation in C
Vector in C++ STL
Map in C++ Standard Template Library (STL)
Initialize a vector in C++ (7 different ways)
Set in C++ Standard Template Library (STL)
vector erase() and clear() in C++