code-rag-bench/online-tutorials huggingface dataset:
Scrapy - Environment

In this chapter, we will discuss how to install and set up Scrapy. Scrapy must be installed with Python.
Scrapy can be installed by using pip. To install, run the following command −
pip install Scrapy

Note − Python 3 is not supported on Windows OS.
Step 1 − Install Python 2.7 from Python
Set environmental variables by adding the following paths to the PATH −
C:\Python27\;C:\Python27\Scripts\; 

You can check the Python version using the following command −
python --version

Step 2 − Install  OpenSSL.
Add C:\OpenSSL-Win32\bin in your environmental variables.
Note − OpenSSL comes preinstalled in all operating systems except Windows.
Step 3 − Install Visual C++ 2008 redistributables.
Step 4 − Install pywin32.
Step 5 − Install pip for Python versions older than 2.7.9.
You can check the pip version using the following command −
pip --version

Step 6 − To install scrapy, run the following command −
pip install Scrapy

If you have anaconda or miniconda installed on your machine, run the below command to install Scrapy using conda −
conda install -c scrapinghub scrapy 

Scrapinghub company supports official conda packages for Linux, Windows, and OS X.
Note − It is recommended to install Scrapy using the above command if you have issues installing via pip.
The latest version of Python is pre-installed on Ubuntu OS. Use the Ubuntu packages aptgettable provided by Scrapinghub. To use the packages −
Step 1 − You need to import the GPG key used to sign Scrapy packages into APT keyring −
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 627220E7

Step 2 − Next, use the following command to create /etc/apt/sources.list.d/scrapy.list file −
echo 'deb http://archive.scrapy.org/ubuntu scrapy main' | sudo tee 
/etc/apt/sources.list.d/scrapy.list

Step 3 − Update package list and install scrapy −
sudo apt-get update && sudo apt-get install scrapy

You can install Scrapy from AUR Scrapy package using the following command −
yaourt -S scrapy

Use the following command to install Xcode command line tools −
xcode-select --install 

Instead of using system Python, install a new updated version that doesn't conflict with the rest of your system.
Step 1 − Install homebrew.
Step 2 − Set environmental PATH variable to specify that homebrew packages should be used before system packages −
echo "export PATH = /usr/local/bin:/usr/local/sbin:$PATH" >> ~/.bashrc

Step 3 − To make sure the changes are done, reload .bashrc using the following command −
source ~/.bashrc 

Step 4 − Next, install Python using the following command −
brew install python

Step 5 − Install Scrapy using the following command −
pip install Scrapy


    27 Lectures 
     3.5 hours 

 Attreya Bhatt
 Print
 Add Notes
 Bookmark this page
Circular Queue Data Structure in C++

A queue is an abstract data structure that contains a collection of elements. Queue implements the FIFO mechanism i.e the element that is inserted first is also deleted first.
Queue cane be one linear data structure. But it may create some problem if we implement queue using array. Sometimes by using some consecutive insert and delete operation, the front and rear position will change. In that moment, it will look like the queue has no space to insert elements into it. Even if there are some free spaces, that will not be used due to some logical problems. To overcome this problem, we will use the circular queue data structure.
A circular queue is a type of queue in which the last position is connected to the first position to make a circle.
#include <iostream>
using namespace std;
int cqueue[5];
int front = -1, rear = -1, n=5;
void insertCQ(int val) {
   if ((front == 0 && rear == n-1) || (front == rear+1)) {
      cout<<"Queue Overflow \n";
      return;
   }
   if (front == -1) {
      front = 0;
      rear = 0;
   }
   else {
      if (rear == n - 1)
         rear = 0;
      else
         rear = rear + 1;
   }
   cqueue[rear] = val ;
}
void deleteCQ() {
   if (front == -1) {
      cout<<"Queue Underflow\n";
      return ;
   }
   cout<<"Element deleted from queue is : "<<cqueue[front<<endl;
   if (front == rear) {
      front = -1;
      rear = -1;
   }
   else {
      if (front == n - 1)
         front = 0;
      else
         front = front + 1;
      }
   }
   void displayCQ() {
      int f = front, r = rear;
      if (front == -1) {
         cout<<"Queue is empty"<<endl;
         return;
      }
      cout<<"Queue elements are :\n";
      if (f <= r) {
         while (f <= r){
            cout<<cqueue[f]<<" ";
            f++;
         }
      }
       else {
         while (f <= n - 1) {
            cout<<cqueue[f]<<" ";
            f++;
         }
         f = 0;
         while (f <= r) {
            cout<<cqueue[f]<<" ";
            f++;
         }
      }
      cout<<endl;
}
int main() {
   int ch, val;
   cout<<"1)Insert\n";
   cout<<"2)Delete\n";
   cout<<"3)Display\n";
   cout<<"4)Exit\n";
   do {
      cout<<"Enter choice : "<<endl;
      cin>>ch;
      switch(ch) {
         case 1:
            cout<<"Input for insertion: "<<endl;
            cin>>val;
            insertCQ(val);
            break;
         case 2:
            deleteCQ();
            break;
         case 3:
            displayCQ();
            break;
         case 4:
            cout<<"Exit\n";
            break;
            default: cout<<"Incorrect!\n";
      }
   }
   while(ch != 4);
      return 0;
}
1)Insert
2)Delete
3)Display
4)Exit
Enter choice :
1
Input for insertion:
10
Enter choice :
1
Input for insertion:
20
Enter choice :
1
Input for insertion:
30
Enter choice :
1
Input for insertion:
40
Enter choice :
1
Input for insertion:
50
Enter choice :
3
Queue elements are :
10 20 30 40 50
Enter choice :
2
Element deleted from queue is : 10
Enter choice :
2
Element deleted from queue is : 20
Enter choice :
3
Queue elements are :
30 40 50
Enter choice :
4
Exit
Display all the values of an array in p tag on a web page with JavaScript

For this, you can use .data(anyArrayObject). Following is the code −
 Live Demo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initialscale=1.0">
<title>Document</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="https://d3js.org/d3.v5.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fontawesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<script>
   const arrayValues = [1000000001,"John","Smith",100, 200, 3000]
   var originalData = d3.select("body").selectAll("p")
   .data(arrayValues)
   .enter()
   .append("p")
   .text(function(allValuesOfArray){
      console.log(allValuesOfArray+" ");
      return allValuesOfArray;
   })
</script>
</body>
</html>
To run the above program, just save the file name anyName.html(index.html) and right click on
the file and select the option open with live server in VS Code editor.
This will produce the following output −
C library function - log10()

The C library function double log10(double x) returns the common logarithm (base-10 logarithm) of x.
Following is the declaration for log10() function.
double log10(double x)
x − This is the floating point value.
x − This is the floating point value.
This function returns the common logarithm of x, for values of x greater than zero.
The following example shows the usage of log10() function.
#include <stdio.h>
#include <math.h>

int main () {
   double x, ret;
   x = 10000;
  
   /* finding value of log1010000 */
   ret = log10(x);
   printf("log10(%lf) = %lf\n", x, ret);
   
   return(0);
}
Let us compile and run the above program that will produce the following result −
log10(10000.000000) = 4.000000


    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
Swing Examples - Add Border to JPanel

Following example showcase how to add border to a JPanel in a Java Swing application.
We are using the following APIs.
BorderFactory.createLineBorder() − To create a line border.
BorderFactory.createLineBorder() − To create a line border.
JPanel.setBorder(border) − To set the desired border to the JPanel.
JPanel.setBorder(border) − To set the desired border to the JPanel.
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.LayoutManager;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.Border;

public class SwingTester {
   public static void main(String[] args) {
      createWindow();
   }

   private static void createWindow() {    
      JFrame frame = new JFrame("Swing Tester");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      createUI(frame);
      frame.setSize(560, 200);      
      frame.setLocationRelativeTo(null);  
      frame.setVisible(true);
   }

   private static void createUI(JFrame frame){
      //Create a border
      Border blackline = BorderFactory.createLineBorder(Color.black);
      JPanel panel = new JPanel();
      LayoutManager layout = new FlowLayout();  
      panel.setLayout(layout);       
      JPanel panel1 = new JPanel();
      String spaces = "                   ";
      panel1.add(new JLabel(spaces + "Border to JPanel" + spaces));  
      panel1.setBorder(blackline);
      panel.add(panel1);
      frame.getContentPane().add(panel, BorderLayout.CENTER);    
   }
}
 Print
 Add Notes
 Bookmark this page
Matplotlib.axes.Axes.cla() in Python - GeeksforGeeks

19 Apr, 2020
Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
The Axes.cla() function in axes module of matplotlib library is used to clear the current axes.
Syntax: Axes.cla(self)
Parameters: This method does not accept any parameters.
Returns:This method does not returns any values.
Below examples illustrate the matplotlib.axes.Axes.cla() function in matplotlib.axes:
Example 1:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt  np.random.seed(19)data = np.random.random((5, 10, 10))  fig, ax = plt.subplots()  for i in range(len(data)):    ax.cla()    ax.imshow(data[i])    ax.set_title("Axes {}".format(i))    plt.pause(0.1)
Output:
Example 2:
# Implementation of matplotlib functionimport numpy as npimport matplotlib.pyplot as plt     t = np.linspace(0.0, 2.0, 201)s = np.sin(2 * np.pi * t)  fig, [ax, ax1] = plt.subplots(2, 1)  ax.set_ylabel('y-axis')ax.plot(t, s)ax.grid(True)ax.set_title('matplotlib.axes.Axes.cla() Example\n\n Sample Example',             fontsize = 12, fontweight ='bold')  ax1.set_ylabel('y-axis')ax1.set_xlabel('x-axis')ax1.plot(t, s)ax1.grid(True)ax1.cla()ax1.set_title('Above example with cla()\ function', fontsize = 12, fontweight ='bold')plt.show()
Output:
Python-matplotlib
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?
Selecting rows in pandas DataFrame based on conditions
Check if element exists in list in Python
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()
C library function - fgetpos()

The C library function int fgetpos(FILE *stream, fpos_t *pos) gets the current file position of the stream and writes it to pos.
Following is the declaration for fgetpos() function.
int fgetpos(FILE *stream, fpos_t *pos)
stream − This is the pointer to a FILE object that identifies the stream.
stream − This is the pointer to a FILE object that identifies the stream.
pos − This is the pointer to a fpos_t object.
pos − This is the pointer to a fpos_t object.
This function returns zero on success, else non-zero value in case of an error.
The following example shows the usage of fgetpos() function.
#include <stdio.h>

int main () {
   FILE *fp;
   fpos_t position;

   fp = fopen("file.txt","w+");
   fgetpos(fp, &position);
   fputs("Hello, World!", fp);
  
   fsetpos(fp, &position);
   fputs("This is going to override previous content", fp);
   fclose(fp);
   
   return(0);
}
Let us compile and run the above program to create a file file.txt which will have the following content. First of all we get the initial position of the file using fgetpos() function and then we write Hello, World!in the file, but later we have used fsetpos() function to reset the write pointer at the beginning of the file and then over-write the file with the following content −
This is going to override previous content

Now let us see the content of the above file using the following program −
#include <stdio.h>

int main () {
   FILE *fp;
   int c;
   int n = 0;

   fp = fopen("file.txt","r");
   
   while(1) {
      c = fgetc(fp);
      if( feof(fp) ) {
         break ;
      }
      printf("%c", c);
   }

   fclose(fp);

   return(0);
}
Let us compile and run above program to produce the following result −
This is going to override previous content


    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
What is the keyword used in instantiating a class in Java?

An object is created from a class. In Java, the new keyword is used to create new objects.
There are three steps when creating an object from a class −
Declaration − A variable declaration with a variable name with an object type.
Declaration − A variable declaration with a variable name with an object type.
Instantiation − The 'new' keyword is used to create the object.
Instantiation − The 'new' keyword is used to create the object.
Initialization − The 'new' keyword is followed by a call to a constructor. This call initializes the new object.
Initialization − The 'new' keyword is followed by a call to a constructor. This call initializes the new object.
Following is an example of creating an object −
 Live Demo
public class Puppy {
   public Puppy(String name) {
      // This constructor has one parameter, name.
      System.out.println("Passed Name is :" + name );
   }
   
   public static void main(String []args) {
      // Following statement would create an object myPuppy
      Puppy myPuppy = new Puppy( "tommy" );
   }
}
Passed Name is :tommy
NumPy Array Shape

The shape of an array is the number of elements in each dimension.
NumPy arrays have an attribute called shape that returns a tuple with each index having the number of corresponding elements.
Print the shape of a 2-D array:
The example above returns (2, 4), which means that the array has 2 dimensions, 
where the first dimension has 2 elements and the second has 4.
Create an array with 5 dimensions using ndmin using a vector with values 1,2,3,4 and verify that last dimension has value 4:
Integers at every index tells about the number of elements the corresponding dimension has.
In the example above at index-4 we have value 4, so we can say that 5th ( 4 + 1 th) dimension has 4 elements.
Use the correct NumPy syntax to check the shape of an array.
arr = np.array([1, 2, 3, 4, 5])

print(arr.)

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

Suppose we have an even number of people n that stand around a circle and each person shakes hands with someone else, so that there will be n / 2 handshakes total. We have to find the number of ways these handshakes could occur such that none of the handshakes cross. The answers may be very large so return the answer mod 10^9 + 7.
So, if the input is like n = 2, then the output will be 1
To solve this, we will follow these steps −
m := 10^9 + 7
m := 10^9 + 7
Define an array dp of size (n+1)
Define an array dp of size (n+1)
dp[0] := 1
dp[0] := 1
for initialize i := 0, when i <= n, update i := i + 2, do −for initialize j := 0, when j <= i-2, update j := j + 2, do −dp[i] := dp[i] + (dp[j] mod m * dp[i - 2 - j] mod m)dp[i] := dp[i] mod m
for initialize i := 0, when i <= n, update i := i + 2, do −
for initialize j := 0, when j <= i-2, update j := j + 2, do −dp[i] := dp[i] + (dp[j] mod m * dp[i - 2 - j] mod m)dp[i] := dp[i] mod m
for initialize j := 0, when j <= i-2, update j := j + 2, do −
dp[i] := dp[i] + (dp[j] mod m * dp[i - 2 - j] mod m)
dp[i] := dp[i] + (dp[j] mod m * dp[i - 2 - j] mod m)
dp[i] := dp[i] mod m
dp[i] := dp[i] mod m
return dp[n] mod m
return dp[n] mod m
Let us see the following implementation to get better understanding −
 Live Demo
#include <bits/stdc++.h>
using namespace std;
const int m = 1e9+7;
typedef long long int lli;
class Solution {
   public:
   int numberOfWays(int n) {
      vector <lli> dp(n+1);
      dp[0] = 1;
      for(int i = 0; i <= n; i+=2 ){
         for(int j =0 ; j <= i-2; j+=2){
            dp[i] += (dp[j]%m * dp[i-2-j]%m)%m;
            dp[i]%=m;
         }
      }
      return dp[n]%m;
   }
};
main(){
   Solution ob;
   cout << (ob.numberOfWays(2));
}
2
1
HTML | InputElement.setSelectionRange() method

31 Jul, 2019
The InputElement.setSelectionRange() method is used to set the start and end positions of the current index value to select text in an input or textarea element.
Syntax:
element.setSelectionRange( Start, End, Direction );
Parameters: This function accepts three parameters as mentioned above and described below:
Start: This parameter holds the index of the first selected character. The index value greater than the length of the element pointing to the end value.
End: This parameter holds the index of the character after the last selected character. The index value greater than the length of the element pointing to the end value.
Direction: This parameter holds the direction to perform selection operation. The possible value of direction are: forward, backward and None.
Example:
<!DOCTYPE html> <html>   <head>     <title>        HTML | InputElement.setSelectionRange() method    </title> </head>   <body style="text-align:center;">           <h1 style="color:green;">         GeeksforGeeks     </h1>                   <h2>        HTML InputElement.setSelectionRange() method    </h2>               <input type="text" id="geeks" size="50"        value="Welcome to GeeksforGeeks">          <button onclick="myGeeks()">        Select text content    </button>                   <script>         function myGeeks() {            const input = document.getElementById('geeks');             input.focus();            input.setSelectionRange(11, 24);        }    </script> </body>  </html>
Output:Before Clicking the Button:After Clicking the Button:
Supported Browsers: The browser supported by HTML InputElement.setSelectionRange() method are listed below:
Google Chrome 1.0
Internet Explorer 9.0
Firefox 1.0
Safari
Opera 8.0
HTML-Methods
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Python | Remove random element from list

27 Sep, 2019
Sometimes, while working with Python lists, we can have a problem or part of it, in which we desire to convert a list after deletion of some random element. This can have it’s application in gaming domain or personal projects. Let’s discuss certain way in which this task can be done.
Method : Using randrange() + pop()In this, we just combine the functionality of above functions into one and achieve this task. The random element is chosen by randrange() and then is accessed and removed from the list using pop()
# Python3 code to demonstrate working of# Remove random element from list# Using randrange() + pop()import random  # initializing list test_list = [6, 4, 8, 9, 10]  # printing list print("The original list : " + str(test_list))  # Remove random element from list# Using randrange() + pop()test_list.pop(random.randrange(len(test_list)))  # Printing resultprint("List after removal of random number : " + str(test_list))
 
The original list : [6, 4, 8, 9, 10]
List after removal of random number : [6, 4, 8, 10]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
jQuery change() with Example

The change() method in jQuery is used to trigger the change event. It occurs when the value of an element has been changed.
The syntax is as follows −
$(selector).change()
Let us now see an example to implement the jQuery change() method −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
   $(document).ready(function() {
      $(".demo").change(function() {
         $(this).css("background-color", "red");
      });
   });
</script>
</head>
<body>
<h2>Login</h2>
Enter Username:
<input type="text" class="demo"><br>
Enter Password:
<input type="password">
</body>
</html>
This will produce the following output −
Write some text in the first input and press enter −
Matplotlib.ticker.MultipleLocator Class in Python

21 Apr, 2020
Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack.
The matplotlib.ticker.MultipleLocator class is used for setting a tick for every integer multiple of a base within the view interval.
Syntax: class matplotlib.ticker.MultipleLocator(base=1.0)
Methods of the class:
set_params(self, base): It is used for setting the parameters within the locator.
tick_values(self, vmin, vmax): For a given vmin and vmax it returns the values of the located ticks.
view_limits(self, dmin, dmax): It is used for setting the view limits to the nearest multiples of base that contain the data.
Example 1:
import matplotlib.pyplot as pltimport matplotlib.ticker as ticker    x = [0, 5, 9, 10, 15]y = [0, 1, 2, 3, 4]  tick_spacing = 1  fig, ax = plt.subplots(1, 1)ax.plot(x, y)ax.xaxis.set_major_locator(ticker.MultipleLocator(tick_spacing))  plt.show()
Output:
Example 2:
import matplotlib.pyplot as pltimport matplotlib.ticker    plt.plot([-1.5, 0, 1.5], [1, 3, 2])ax = plt.gca()  func = lambda x, pos: str(x).rstrip('0').rstrip('.')  ax.xaxis.set_major_locator(matplotlib.ticker.MultipleLocator(0.25))ax.xaxis.set_major_formatter(matplotlib.ticker.FuncFormatter(func))  plt.show()
Output:
Python-matplotlib
Python
Write From Home
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to check file size in Python?

17 Dec, 2020
Prerequisites:
os 
pathlib
Given a file, the task here is to generate a Python Script to print its size. This article explains 2 methods to do so.
Import module
Get file size
Name: Data.csv
Size: 226 bytes
Method1: Using pathlib
Path().stat().st_size() function of pathlib module gets the size of any type of the file and the output of this function will be the size of the file in bytes.
Syntax:
Path('filename').stat().st_size()
Example:
Python3
from pathlib import Path  sz = Path('Data.csv').stat().st_size  print(sz)
Output:
Method 2: With Os module
os.path.getsize() function only works with os Library, with the help of importing this library we can use this to get the size of any type of file and the output of this function will be the size of the file in bytes.
Syntax:
getsize(filename)
Example:
Python3
import os  sz = os.path.getsize("Data.csv")  print(sz)
Output:
We got the result as 226 bytes
Picked
Python file-handling-programs
python-file-handling
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to iterate through Excel rows in Python?
Rotate axis tick labels in Seaborn and Matplotlib
Deque in Python
Queue in Python
Defaultdict in Python
Check if element exists in list in Python
Python Classes and Objects
Bar Plot in Matplotlib
reduce() in Python
Python | Get unique values from a list
Different Ways to Convert the Boolean Type in String in Golang

10 May, 2020
In order to convert Boolean Type to String type in Golang , you can use the strconv and fmt package function.
1. strconv.FormatBool() Method: The FormatBool is used to Boolean Type to String. It returns “true” or “false” according to the value of b.
Syntax:
func FormatBool(b bool) string

Example : Convert an Boolean Type into String using strconv.FormatBool() function.
Go
// Go program to illustrate // How to convert the// Boolean Type into Stringpackage main  import (    "fmt"    "strconv")  //Main Function  func main() {      i := true    s := strconv.FormatBool(i)    fmt.Printf("Type : %T \nValue : %v\n", s, s)  }
Output:
Type : string 
Value : true

2. fmt.Sprintf() Method: The Sprintf is used to represents the string by formatting according to a format specifier.
Syntax:
func Sprintf(format string, a ...interface{}) string

Example : Convert an Boolean Type into String using fmt.Sprintf() function.
Go
// Go program to illustrate // How to convert the// Boolean Type into Stringpackage main  import (    "fmt")  //Main Function  func main() {      i := true    s := fmt.Sprintf("%v", i)    fmt.Printf("Type : %T \nValue : %v\n\n", s, s)          i1 := false    s1 := fmt.Sprintf("%v", i1)    fmt.Printf("Type : %T \nValue : %v\n", s1, s1)}
Output:
Type : string 
Value : true

Type : string 
Value : false

Go Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java Program to Illustrate a Method Without Parameters and Return Type

17 Nov, 2020
Functions are a way to break a program into different modules which are executed one by one. To use a function in Java we need to: 
Declare the function i.e. declare a prototype of the function.
Define the function
Call the function
It is important that we declare the function before calling it and the definition can be kept at any portion of the program.
Declaring, Defining and Calling a function
Now we will be creating a function with no return type and no parameters. While declaring a function we need to specify the return type of the functions and the number and types of parameters it is going to accept. For the return type, we have options such as int, float, char etc. But sometimes we don’t have to return anything in such scenario we have to use the void return type. And since we are not going to pass any parameter too, so we have to specify it while declaring by keeping the parenthesis empty. 
Example:
Java
// Java Program to Illustrate a Method with No Parameters// and Return Type  public class Main {        // Declaration and Definition of the function     public static void greet()    {        System.out.println(            "Hey Geeks! Welcome to NoWhere.");                /* Optional program will work same           without this return statement */        return;    }    public static void main(String args[])    {        // Calling of the function without any parameters        greet();    }}
Hey Geeks! Welcome to NoWhere.

In the above program, we declare and define the function at the same place which can be done and is also considered good if we want to use the function in the same program it is declared. Also, you can notice that the parameters during declaration and call are empty because we are not passing any parameters. Even we are not storing any data from the function because the function isn’t returning anything.
Note: A return statement can be used at the end of the function but it’s completely optional if you remove the return statement then to the program will run in the same manner as it does with the return statement.
Functions
Picked
Java
Java Programs
Java
Functions
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Online XML Formatter

Editable XML Code
123456789101112131415<?xml version="1.0"?><Company><Employee><FirstName>Tanmay</FirstName><LastName>Patil</LastName><ContactNo>1234567890</ContactNo><Email>tanmaypatil@xyz.com</Email><Address><City>Bangalore</City><State>Karnataka</State><Zip>560212</Zip></Address></Employee></Company>X
Privacy Policy
Cookies Policy
Terms of Use
What happens when we type a URL - GeeksforGeeks

05 Jun, 2020
URL stands for Uniform Resource Locator. URL is the address of the website which you can find in the address bar of your web browser. It is a reference to a resource on the internet, be it images, hypertext pages, audio/video files, etc.
Example :
https://practice.geeksforgeeks.org/ 
What is DNS :DNS is short for Domain Name System. Like a phonebook, DNS maintains and maps the name of the website, i.e. URL, and particular IP address it links to. Every URL on the internet has a unique IP address which is of the computer which hosts the server of the website requested.
Steps for what happens when we enter a URL :
Browser checks cache for DNS entry to find the corresponding IP address of website.It looks for following cache. If not found in one, then continues checking to the next until found.Browser CacheOperating Systems CacheRouter CacheISP CacheIf not found in cache, ISP’s (Internet Service Provider) DNS server initiates a DNS query to find IP address of server that hosts the domain name.The requests are sent using small data packets that contain information content of request and IP address it is destined for.Browser initiates a TCP (Transfer Control Protocol) connection with the server using synchronize(SYN) and acknowledge(ACK) messages.Browser sends an HTTP request to the web server. GET or POST request.Server on the host computer handles that request and sends back a response. It assembles a response in some format like JSON, XML and HTML.Server sends out an HTTP response along with the status of response.Browser displays HTML contentFinally, Done.
Browser checks cache for DNS entry to find the corresponding IP address of website.It looks for following cache. If not found in one, then continues checking to the next until found.Browser CacheOperating Systems CacheRouter CacheISP Cache
Browser Cache
Operating Systems Cache
Router Cache
ISP Cache
If not found in cache, ISP’s (Internet Service Provider) DNS server initiates a DNS query to find IP address of server that hosts the domain name.The requests are sent using small data packets that contain information content of request and IP address it is destined for.
Browser initiates a TCP (Transfer Control Protocol) connection with the server using synchronize(SYN) and acknowledge(ACK) messages.
Browser sends an HTTP request to the web server. GET or POST request.
Server on the host computer handles that request and sends back a response. It assembles a response in some format like JSON, XML and HTML.
Server sends out an HTTP response along with the status of response.
Browser displays HTML content
Finally, Done.
Computer Networks
Computer Networks
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Advanced Encryption Standard (AES)
Intrusion Detection System (IDS)
Introduction and IPv4 Datagram Header
Secure Socket Layer (SSL)
Cryptography and its Types
Multiple Access Protocols in Computer Network
Congestion Control in Computer Networks
Routing Information Protocol (RIP)
Architecture of Internet of Things (IoT)
Wireless Sensor Network (WSN)
Scala | Create Array with Range - GeeksforGeeks

12 Jun, 2019
Array is a special kind of collection in Scala. It is a fixed size data structure that stores elements of the same data type. By using range() method to generate an array containing a sequence of increasing integers in a given range. We can use final argument as jump to create the sequence. if we do not use final argument, then jump would be assumed as 1.
Below are some examples of array with range:
Example:
// Scala program to create array with range import Array._  // Creating objectobject GFG{    // Main method    def main(args: Array[String])     {        var array1 = range(1, 15)        var array2 = range(1, 15, 3)                // Print all the elements of array1        for ( i <- array1 )         {            print( " " + i )        }                  println()                  // Print all the elements of array2        for ( i <- array2 )         {            print( " " + i )        }    }}
1 2 3 4 5 6 7 8 9 10 11 12 13 14
 1 4 7 10 13

In above example, an array of range (1, 15). In this range difference is not given so by default difference of range will be 1 element. Elements in the array are 1, 4, 7, 10 and 13. Here, we are creating an array of range (1, 15, 3). Which means an array with elements between 1 and 15 and range difference is 3. Elements in the array are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, and 14.
For some of the collections, such as List and Array, we can also create a Range and convert it to the desired sequence: The REPL shows the array that can be created directly from a Range is toArray. We can also use a Range to create a sequence of characters as below:
Example:
// Scala program to create array with range import Array._  // Creating objectobject GFG{    // Main method    def main(args: Array[String])     {        val array1 = ('A' to 'F').toArray        val array2 = ('a' to 'f').by(2).toArray                    // Print all the elements of array1        for ( i <- array1 )         {            print( " " + i )        }                  println()                  // Print all the elements of array2        for ( i <- array2 )         {            print( " " + i )        }    }}
A B C D E F
 a c e

In above example, an array of range (‘A’ to ‘F’).toArray. In this, range difference is not given so by default difference of range will be 1 character. characters in the array are A, B, C, D, E and F. Here, we are creating an array of range (‘a’ to ‘f’).by(2).toArray. Which means an array with characters between a and f and range difference is 2. Characters in the array are a, c, and e.
Scala-Arrays
Scala
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Inheritance in Scala
Scala | Traits
Scala ListBuffer
Scala | Case Class and Case Object
Hello World in Scala
Scala | Functions - Basics
Scala | Decision Making (if, if-else, Nested if-else, if-else if)
Scala List map() method with example
Comments In Scala
Abstract Classes in Scala
HTML height Attribute - GeeksforGeeks

10 Dec, 2021
The HTML <td> height Attribute is used to specify the height of the table cell. If the <td> height attribute is not set then it takes default height according to content.
Syntax: 
<td height="pixels | %">
Attribute Values:  
pixels: It sets the height of the table cell in terms of pixels.
%: It sets the height of the table cell in terms of percentage (%).
Note: The <td> height Attribute is not supported by HTML 5.
Example: This example describes the  HTML <td> height Attribute in order to add the height of the table cell.
HTML
<!DOCTYPE html><html> <head>    <title>        HTML td height Attribute    </title></head> <body>    <h1>GeeksforGeeks</h1>    <h2>HTML td height Attribute</h2>     <table border="1" width="500">        <tr>            <th>NAME</th>            <th>AGE</th>            <th>BRANCH</th>        </tr>         <tr>            <td height="50">BITTU</td>            <td height="50">22</td>            <td height="50">CSE</td>        </tr>         <tr>            <td height="100">RAKESH</td>            <td height="100">25</td>            <td height="100">EC</td>        </tr>    </table></body> </html>
Output:
 HTML <td> height Attribute 
Supported Browsers: The browser supported by HTML <td> height Attribute are listed below:
Google Chrome
Internet Explorer
Microsoft Edge
Firefox
Safari
Opera
Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.
ManasChhabra2
bhaskargeeksforgeeks
HTML-Attributes
HTML
Web Technologies
HTML
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to update Node.js and NPM to next version ?
REST API (Introduction)
How to Insert Form Data into Database using PHP ?
CSS to put icon inside an input element in a form
Types of CSS (Cascading Style Sheet)
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
Difference between var, let and const keywords in JavaScript
Java String startsWith() Method

❮ String Methods

Find out if the string starts with the specified characters:
String myStr = "Hello";
System.out.println(myStr.startsWith("Hel"));   // true
System.out.println(myStr.startsWith("llo"));   // false
System.out.println(myStr.startsWith("o"));     // false

Try it Yourself »

The startsWith() method checks whether a 
string starts with the specified character(s).
Tip: Use the endsWith() method to check whether a string ends with the specified character(s).
public boolean startsWith(String chars)

true - if the string starts with the specified character(s)
false - if the string does not start with the specified character(s)
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
What is Ambiguous Grammar?

A Grammar that makes more than one Leftmost Derivation (or Rightmost Derivation) for the similar sentence is called Ambiguous Grammar.
Example − Verify whether the following Grammar is Ambiguous or Not.
E → E+E|E ∗ E|id
Solution
For string id + id * id, there exist two parse trees.
E ⇒lm E_+E
 ⇒ id+ E_
⇒ id+E_ ∗ E
⇒ id+id ∗ E_
⇒ id+id ∗ id
E ⇒lm E_ ∗ E
⇒ E_+E ∗ E
⇒ id+ E_ ∗ E
⇒ id+id ∗ E_
⇒ id+id ∗ id
So, the same string is generated using two different leftmost derivations. Each is having a different parse tree.
∴ Two different parse trees exist for string id + id * id.
∴ Grammar is Ambiguous.
The productions containing more than one occurrence of a given non-terminal on its right-hand side are ambiguous productions.
Example − E → E_ * E_
It contains two E’s on R.H.S.
It can convert these types of Ambiguous productions to Unambiguous production by introducing a new Non-terminal to move right most of these non-terminal farther down the Parse Tree.
Example1 − Consider the Grammar
E → E+E|E ∗ E|(E)| id
Convert this Ambiguous Grammar into Unambiguous Grammar.
Solution
Step1 − Introduction a non-terminal T (term) which cannot be further addition of two terms.
E → E+T | T
T → E * E | (E) |id
Step2 − As we have production E → T. Substitute E with T to get
T→T∗T
Introduce another non-terminal F (factor) that cannot be further factorized or cannot be multiplication of two numbers.
Substitute T with F to get,
T → T * F | F
F → (E) | id
∴ Unambiguous Grammar will be
E → E+T | T
T → T * F | F
F → (E) | id
Example2 − Prove that following Grammar is Ambiguous for the string if c then if c2 then s1 else s2.
<statement> →if<cond> then<statement>
| if<cond> then<statement> else<statement>
| another statement
Convert it into Unambiguous Grammar.
Solution
Given grammar is Ambiguous since there exists two Parse Trees for the same string because else condition can belong to any if statement.
In the above Parse tree, else belongs to second if.
In the above Parse tree, else belongs to first if.
The Unambiguous Grammar will be −
<statement>→<match−statement>|<Unmatch−statement>
<match−statement>→if<cond>then<match−statement>else
    <match−statement>| other−statement
<Unmatch−statement>→if<cond>then<statement>| if<cond>then
    <match−statement>else<Unmatch Statement>
GUID in Postman

GUID means Global Unique Identifier. It is in the form of a hexa-decima digit which is separated by hyphen. It helps to achieve distinctiveness due to this even if multiple people are creating the GUID simultaneously, the chance of having a duplicate GUID is rare.
To generate a random value, using GUID, the format is −
{
   "name": "{{$guid}}"
}
On sending a request, it would produce a random value.
GUID is a value with 128 bits having a structure defined in RFC4122. The structure of GUID is uncomplicated and simple for generation.The format of a GUID is shown below −
xxxxxxxx-xxxx-Axxx-Bxxx-xxxxxxxxxxxx
Here, A is the version and B is the variant.
For instance, if a GUID is 6315147b-458e-ada0-7d24b5479582b. Then as per the structure, it has the version 4(which is marked in bold). GUID can be generated manually or with the help of online tools.
The below link will help to generate a GUID −
https://www.guidgenerator.com/
The available versions of GUID are listed below −
Version 1 - the MAC address and Date-Time are mentioned.
Version 1 - the MAC address and Date-Time are mentioned.
Version 2 - the DCE security is mentioned.
Version 2 - the DCE security is mentioned.
Version 3 - the MD5 and namespace are mentioned.
Version 3 - the MD5 and namespace are mentioned.
Version 4 - produces random digits for creating GUID.
Version 4 - produces random digits for creating GUID.
Version 5 - the SHA-1 hash and namespace are mentioned.
Version 5 - the SHA-1 hash and namespace are mentioned.
GUID can be created manually.
GUID can be created manually.
Distinct value gets generated every time so there is less chance of encountering identical values.
Distinct value gets generated every time so there is less chance of encountering identical values.
Can be utilized as a database primary key.
Can be utilized as a database primary key.
GUID can be created offline.
GUID can be created offline.
GUID is useful when we have more than one standalone application.
GUID is useful when we have more than one standalone application.
Consumes a lot of space.
Consumes a lot of space.
No option of sorting to organize data in specific format.
No option of sorting to organize data in specific format.
Custom progress Bar in Android?

This example demonstrates how do I create a progress bar android
Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
Step 2 − Add the following code to res/layout/activity_main.xml.
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
   xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:app="http://schemas.android.com/apk/res-auto"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   tools:context=".MainActivity">
   <ProgressBar
      android:layout_width="150dp"
      android:layout_height="150dp"
      style="?android:progressBarStyleLarge"
      android:progress="50"
      android:id="@+id/progressBar"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintLeft_toLeftOf="parent"
      app:layout_constraintRight_toRightOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      android:progressDrawable="@drawable/circle"/>
</android.support.constraint.ConstraintLayout>
Step 3 − Create a drawable resource file, name it as circle.xml and add the following code −
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
   android:shape="ring"
   android:innerRadiusRatio="2.5"
   android:thickness="4dp"
   android:useLevel="true">
   <solid android:color="@color/colorAccent"/>
Step 4 − Add the following code to src/MainActivity.java
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ProgressBar;
public class MainActivity extends AppCompatActivity {
   ProgressBar progressBar;
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      progressBar = findViewById(R.id.progressBar);
      progressBar.setMax(100);
      progressBar.setProgress(20);
   }
}
Step 5 − Add the following code to androidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.sample">
   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:roundIcon="@mipmap/ic_launcher_round"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>
Let's try to run your application. I assume you have connected your actual Android Mobile device with your computer. To run the app from android studio, open one of your project's activity files and click Run icon from the toolbar. Select your mobile device as an option and then check your mobile device which will display your default screen −
Click here to download the project code.