code-rag-bench/online-tutorials huggingface dataset:
Google Colab - Documenting Your Code

As the code cell supports full Python syntax, you may use Python comments in the code window to describe your code. However, many a time you need more than a simple text based comments to illustrate the ML algorithms. ML heavily uses mathematics and to explain those terms and equations to your readers you need an editor that supports LaTex - a language for mathematical representations. Colab provides Text Cells for this purpose.
A text cell containing few mathematical equations typically used in ML is shown in the screenshot below −
As we move ahead in this chapter, we will see the code for generating the above output.
Text Cells are formatted using markdown - a simple markup language. Let us now see you how to add text cells to your notebook and add to it some text containing mathematical equations.
Let us look into few examples of markup language syntax to demonstrate its capabilities.
Type in the following text in the Text cell.
This is **bold**.
This is *italic*.
This is ~strikethrough~.

The output of the above commands is rendered on the right hand side of the Cell as shown here.
Add a Text Cell to your notebook and enter the following markdown syntax in the text window −
$\sqrt{3x-1}+(1+x)^2$

You will see the immediate rendering of the markdown code in the right hand side panel of the text cell. This is shown in the screenshot below −
Hit Enter and the markdown code disappears from the text cell and only the rendered output is shown.
Let us try another more complicated equation as shown here −
$e^x = \sum_{i = 0}^\infty \frac{1}{i!}x^i$

The rendered output is shown here for your quick reference.
Here is the code for the sample equations shown in an earlier screenshot −
Constraints are
   - $3x_1 + 6x_2 + x_3 =< 28$
   - $7x_1 + 3x_2 + 2x_3 =< 37$
   - $4x_1 + 5x_2 + 2x_3 =< 19$
   - $x_1,x_2,x_3 >=0 $

The trial vector is calculated as follows:
- $u_i(t) = x_i(t) + \beta(\hat{x}(t) − x_i(t)) + \beta \sum_{k = 1}^{n_v}(x_{i1,k}(t) − x_{i2,k}(t))$
$f(x_1, x_2) = 20 + e - 20exp(-0.2 \sqrt {\frac {1}{n} (x_1^2 + x_2^2)}) - exp (\frac {1}{n}(cos(2\pi x_1) + cos(2\pi x_2))$

$x ∈ [-5, 5]$
>$A_{m,n} =
   \begin{pmatrix}
   a_{1,1} > a_{1,2} > \cdots > a_{1,n} \\
   a_{2,1} > a_{2,2} > \cdots > a_{2,n} \\
   \vdots > \vdots > \ddots > \vdots \\
   a_{m,1} > a_{m,2} > \cdots > a_{m,n}
   \end{pmatrix}$

Describing full markup syntax is beyond the scope of this tutorial. In the next chapter, we will see how to save your work.
How can Tensorflow and pre-trained model be used to visualize the data using Python?

Tensorflow and the pre-trained model can be used to visualize the data using the ‘matplotlib’ library. The ‘plot’ method is used to plot the data on the console.
Read More:
What is TensorFlow and how Keras work with TensorFlow to create Neural Networks?
A neural network that contains at least one layer is known as a convolutional layer. We can use the Convolutional Neural Network to build learning model. 
We will understand how to classify images of cats and dogs with the help of transfer learning from a pre-trained network. The intuition behind transfer learning for image classification is, if a model is trained on a large and general dataset, this model can be used to effectively serve as a generic model for the visual world. It would have learned the feature maps, which means the user won’t have to start from scratch by training a large model on a large dataset.
Read More:
How can a customized model be pre-trained?
We are using the Google Colaboratory to run the below code. Google Colab or Colaboratory helps run Python code over the browser and requires zero configuration and free access to GPUs (Graphical Processing Units). Colaboratory has been built on top of Jupyter Notebook.
print("Visualizing the data")
plt.figure(figsize=(8, 8))
plt.subplot(2, 1, 1)
plt.plot(acc, label='Training Accuracy')
plt.plot(val_acc, label='Validation Accuracy')
plt.ylim([0.8, 1])
plt.plot([initial_epochs-1,initial_epochs-1], plt.ylim(), label='Start Fine Tuning')
plt.legend(loc='lower right')
plt.title('Training and Validation Accuracy')
plt.subplot(2, 1, 2)
plt.plot(loss, label='Training Loss')
plt.plot(val_loss, label='Validation Loss')
plt.ylim([0, 1.0])
plt.plot([initial_epochs-1,initial_epochs-1], plt.ylim(), label='Start Fine Tuning')
plt.legend(loc='upper right')
plt.title('Training and Validation Loss')
plt.xlabel('epoch')
plt.show()
Code credit −https://www.tensorflow.org/tutorials/images/transfer_learning
The learning curves of the training and validation accuracy/loss is visualized.
The learning curves of the training and validation accuracy/loss is visualized.
This is done once the fine-tuning is performed.
This is done once the fine-tuning is performed.
The validation loss is higher than the training loss, which means there would be some overfitting.
The validation loss is higher than the training loss, which means there would be some overfitting.
This overfitting could also be due to the fact that the training dataset is relatively smaller and similar to original MobileNet V2 datasets.
This overfitting could also be due to the fact that the training dataset is relatively smaller and similar to original MobileNet V2 datasets.
Once fine tuning is done, model reaches 98% accuracy on the validation set.
Once fine tuning is done, model reaches 98% accuracy on the validation set.
Instruction type CMP R in 8085 Microprocessor

In 8085 Instruction set, CMP is a mnemonic that stands for “CoMPareAccumulator” and hereR stands for any of the following registers, or memory location M pointed by HL pair.
R = A, B, C, D, E, H, L, or M

This instruction is used to compare contents of the Accumulator with given register R. The result of compare operation will be stored in the Temp register. Temp is not a GPR (General Purpose Register) but an internal register that is not accessible to the programmer. Actually R register’s content will get subtracted from Accumulators content and difference value will be stored on the Temp register. As R can have any of the eight values, there are eight opcodes for this type of instruction. It occupies only 1-Byte in memory.
Let us consider one sample instruction CMP E falling in this category.As It is a 1-Byte instruction so during execution of this instruction it will occupy only a single Byte in memory. The result of execution of this instruction has been depicted with following set of examples −
(A)
(E)
(Temp)
(F)
(A)
(E)
(Temp)
(F)
(A)
(E)
(Temp)
(F)
The timing diagram against this instruction CMP E execution is as follows −
Summary − So this instruction CMP E requires 1-Byte, 1-Machine Cycle (Opcode Fetch) and 4 T-States for execution as shown in the timing diagram.
Bootstrap block level help text

Bootstrap form controls can have a block level help text that flows with the inputs. To add a full width block of content, use the .help-block after the <input>.
The following example demonstrates this
Live Demo
<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <form role = "form">
         <span>Example of Help Text</span>
         <input class = "form-control" type = "text" placeholder = "">
         <span class = "help-block">
            A longer block of help text that breaks onto a new line and may extend beyond one line.
         </span>
      </form>
   </body>
</html>
How to use media queries with JavaScript?

To use media queries with JavaScript, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      color: white;
      padding: 20px;
   }
</style>
</head>
<body>
<h1>Using media queries with JavaScript Example</h1>
<h2>Resize the screen to see the color change from blue to red</h2>
<script>
   var mediaQuery = window.matchMedia("(max-width: 700px)");
   function setColor(mediaQuery) {
      if (mediaQuery.matches) {
         document.body.style.backgroundColor = "red";
      } else {
         document.body.style.backgroundColor = "blue";
      }
   }
   setColor(mediaQuery);
   mediaQuery.addListener(myFunction);
</script>
</body>
</html>
The above code will produce the following output on window size greater than 700px −
On resizing the browser window size less than 700px −
Python | Convert given list into nested list - GeeksforGeeks

11 Oct, 2019
Some times, we come over the data that is in string format in a list and it is required to convert it into a list of the list. This kind of problem of converting a list of strings to nested list is quite common in web development. Let’s discuss certain ways in which this can be performed.
Method #1: Using iteration
# Python code to convert list # of string into list of list  # List initializationInput = ['Geeeks, Forgeeks', '65.7492, 62.5405',         'Geeks, 123', '555.7492, 152.5406']           temp = []  # Getting elem in list of list formatfor elem in Input:    temp2 = elem.split(', ')    temp.append((temp2))  # List initializationOutput = []   # Using Iteration to convert # element into list of listfor elem in temp:    temp3 = []    for elem2 in elem:        temp3.append(elem2)    Output.append(temp3)  # printingprint(Output)
[[‘Geeeks’, ‘Forgeeks’], [‘65.7492’, ‘62.5405’], [‘Geeks’, ‘123’], [‘555.7492’, ‘152.5406’]]
 Method #2 : Using ast [list with numeric values]
# Python code to convert list # of string into list of list  # importingimport ast  # List InitializationInput = ['12, 454', '15.72, 82.85', '52.236, 25256', '95.9492, 72.906']  # using ast to convertOutput = [list(ast.literal_eval(x)) for x in Input]  # printingprint(Output)
[[12, 454], [15.72, 82.85], [52.236, 25256], [95.9492, 72.906]]
mayank5326
shubham_singh
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read a file line by line in Python
Enumerate() in Python
How to Install PIP on Windows ?
Iterate over a list in Python
Different ways to create Pandas Dataframe
Python program to convert a list to string
Defaultdict in Python
Python | Split string into list of characters
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Static import the Math Class Methods in Java

Static import means that the fields and methods in a class can be used in the code without specifying their class if they are defined as public static.
The Math class method sqrt() in the package java.lang is static imported.
A program that demonstrates this is given as follows:
 Live Demo
import static java.lang.Math.sqrt;
public class Demo {
   public static void main(String[] arg) {
      double num = 36.0;
      System.out.println("The number is: " + num);
      System.out.println("The square root of the above number is: " + sqrt(num));
   }
}
The number is: 36.0
The square root of the above number is: 6.0
Now let us understand the above program.
The Math class is not required along with the method sqrt() as static import is used for the java.lang package. The number num and its square root is displayed. A code snippet which demonstrates this is as follows:
double num = 36.0;
System.out.println("The number is: " + num);
System.out.println("The square root of the above number is: " + sqrt(num));
Angular CLI - Code Coverage

This chapter explains the syntax of code coverage command along with an example.
The syntax for code coverage command is as follows −
ng test <project> --codeCoverage=true

ng test command allows to check code coverage using the test cases written. See the example below.
Move to an angular project updated using ng xi18n command. This chapter is available at https://www.tutorialspoint.com/angular_cli/angular_cli_ng_xi18n.htm. Now, run the test with codeCoverage command.
An example for ng code coverage command is given below −
\>Node\>TutorialsPoint> ng test --codeCoverage=true
10% building 2/2 modules 0 active07 06 2020 15:21:46.292:WARN [karma]: No captur
ed browser, open http://localhost:9876/
07 06 2020 15:21:46.299:INFO [karma-server]: Karma v4.4.1 server started at http
://0.0.0.0:9876/
07 06 2020 15:21:46.300:INFO [launcher]: Launching browsers Chrome with concurre
ncy unlimited
07 06 2020 15:21:46.312:INFO [launcher]: Starting browser Chrome
07 06 2020 15:21:55.456:WARN [karma]: No captured browser, open http://localhost
:9876/
07 06 2020 15:21:55.533:INFO [Chrome 83.0.4103 (Windows 7.0.0)]: Connected on so
cket gJgRaX_rXI6ZqoAiAAAA with id 261512
...
Chrome 83.0.4103 (Windows 7.0.0): Executed 1 of 2 SUCCESS (0 secs / 0.053 secs)
...
Chrome 83.0.4103 (Windows 7.0.0): Executed 2 of 2 SUCCESS (0.107 secs / 0.082 se
cs)
TOTAL: 2 SUCCESS

=============================== Coverage summary ===============================

Statements   : 100% ( 8/8 )
Branches     : 100% ( 0/0 )
Functions    : 100% ( 3/3 )
Lines        : 100% ( 6/6 )
================================================================================

Now ng test command has created a coverage folder within the TutorialsPoint, the project folder and has prepared the coverage report in html format available as \>Node\>TutorialsPoint\>coverage\>TutorialsPoint\>index.html.

    16 Lectures 
     1.5 hours 

 Anadi Sharma

    28 Lectures 
     2.5 hours 

 Anadi Sharma

    11 Lectures 
     7.5 hours 

 SHIVPRASAD KOIRALA

    16 Lectures 
     2.5 hours 

 Frahaan Hussain

    69 Lectures 
     5 hours 

 Senol Atac

    53 Lectures 
     3.5 hours 

 Senol Atac
 Print
 Add Notes
 Bookmark this page
How to find group-wise summary statistics for an R data frame?

To compare different groups, we need the summary statistics for each of the groups. It helps us to observe the differences between the groups. The summary statistics provides the minimum value, first quartile, median, third quartile, and the maximum values. Therefore, we can compare each of these values for the groups. To find the group-wise summary statistics for an R data frame, we can use tapply function.
Consider the below data frame −
> set.seed(99)
> x1<-sample(1:100,50,replace=TRUE)
> x2<-rep(c("G1","G2","G3","G4","G5"),times=10)
> df<-data.frame(x1,x2)
> head(df,20)
x1 x2
1 48 G1
2 33 G2
3 44 G3
4 22 G4
5 99 G5
6 62 G1
7 98 G2
8 32 G3
9 13 G4
10 20 G5
11 100 G1
12 31 G2
13 68 G3
14 9 G4
15 82 G5
16 88 G1
17 30 G2
18 86 G3
19 84 G4
20 32 G5
Finding the summary statistics of x1 for each group −
> tapply(df$x1, df$x2, summary)
$G1
Min. 1st Qu. Median Mean 3rd Qu. Max.
14.0 55.0 72.0 67.8 86.5 100.0
$G2
Min. 1st Qu. Median Mean 3rd Qu. Max.
4.0 31.5 60.5 52.4 69.5 98.0
$G3
Min. 1st Qu. Median Mean 3rd Qu. Max.
14.0 33.5 41.0 46.9 64.5 86.0
$G4
Min. 1st Qu. Median Mean 3rd Qu. Max.
9.00 23.75 53.00 53.30 82.75 97.00
$G5
Min. 1st Qu. Median Mean 3rd Qu. Max.
7.00 31.25 32.00 42.40 44.75 99.00
Let’s have a look at one more example −
> y1<-rep(c(letters[1:5]),times=5)
> y2<-rep(c(14,25,13,12,41,52,44,28,17,30),times=c(2,5,3,3,1,5,1,2,2,1))
> df_y<-data.frame(y1,y2)
> head(df_y,20)
  y1 y2
 1 a 14
 2 b 14
 3 c 25
 4 d 25
 5 e 25
 6 a 25
 7 b 25
 8 c 13
 9 d 13
10 e 13
11 a 12
12 b 12
13 c 12
14 d 41
15 e 52
16 a 52
17 b 52
18 c 52
19 d 52
20 e 44
> tapply(df_y$y2, df_y$y1, summary)
$a
Min. 1st Qu. Median Mean 3rd Qu. Max.
12.0 14.0 25.0 26.2 28.0 52.0
$b
Min. 1st Qu. Median Mean 3rd Qu. Max.
12.0 14.0 25.0 26.2 28.0 52.0
$c
Min. 1st Qu. Median Mean 3rd Qu. Max.
12.0 13.0 17.0 23.8 25.0 52.0
$d
Min. 1st Qu. Median Mean 3rd Qu. Max.
13.0 17.0 25.0 29.6 41.0 52.0
$e
Min. 1st Qu. Median Mean 3rd Qu. Max.
13.0 25.0 30.0 32.8 44.0 52.0
Find the text of the given tag using BeautifulSoup - GeeksforGeeks

03 Mar, 2021
Web scraping is a process of using software bots called web scrapers in extracting information from HTML or XML content of a web page. Beautiful Soup is a library used for scraping data through python. Beautiful Soup works along with a parser to provide iteration, searching, and modifying the content that the parser provides(in the form of a parse tree). It’s fairly easy to crawl through the web pages and to find the text of a given tag using Beautiful Soup. 
In this article, we will discuss finding the text from the given tag.
Step-by-step Approach: 
First import the library.
Python3
from bs4 import BeautifulSoupimport requests
Now assign the URL.
Python3
# assign URLurl = "https://www.geeksforgeeks.org/"
Fetch the raw HTML content from the URL.
Python3
html_content = requests.get(url).text
Now parse through the content.
Python3
# Now that the content is ready, iterate # through the content using BeautifulSoupsoup = BeautifulSoup(html_content, "html.parser")
After the content is parsed we search for a specific tag and print its text.
Python3
print(soup.find('title'))
Below is the complete program.
Python3
from bs4 import BeautifulSoupimport requests    # Assign URLurl = "https://www.geeksforgeeks.org/"  # Fetch raw HTML contenthtml_content = requests.get(url).text  # Now that the content is ready, iterate # through the content using BeautifulSoup:soup = BeautifulSoup(html_content, "html.parser")  # similarly to get all the occurences of a given tagprint(soup.find('title').text)
Output:
Similarly to get all the occurrences of the given tag:
Python3
from bs4 import BeautifulSoupimport requests  # Assign URLurl = "https://www.geeksforgeeks.org/"  # Fetch raw HTML contenthtml_content = requests.get(url).text  # Now that the content is ready, iterate # through the content using BeautifulSoup:soup = BeautifulSoup(html_content, "html.parser")  # similarly to get all the occurences of a given tagtexts = soup.find_all('p')for text in texts:    print(text.get_text())
Output:
Picked
Python BeautifulSoup
Python bs4-Exercises
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
Selecting rows in pandas DataFrame based on conditions
How to drop one or multiple columns in Pandas Dataframe
Python | Get unique values from a list
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | os.path.join() method
Defaultdict in Python
Create a directory in Python
Python Classes and Objects
How to get the current location latitude and longitude in iOS?

Almost all the application uses location services, thus having complete understanding on location is necessary. In this post we will be seeing how to get current location’s latitude and longitude.
For this we will be using CLLocationManager, you can read more about it herehttps://developer.apple.com/documentation/corelocation/cllocationmanager
We will be developing a sample application where we will print user’s latitude and longitude on viewDidLoad method, alternatively you can print on tap of a button also on UILabel as per need.
So let’s get started,
Step 1 − Open Xcode → New Projecr → Single View Application → Let’s name it “Location”
Step 2 − Open info.plist file and add the below keys.
<key>NSLocationWhenInUseUsageDescription</key>
<string>Application wants to use your location</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Application wants to use your location</string>
These are required whenever you’re doing location related stuff, we need to ask user’s permission.
Step 3 − In ViewController.swift,
import CoreLocation
Step 4 − Create an Object of CLLocationManager
var locationManager = CLLocationManager()
Step 5 − In viewDidLoad method write the below code,
locationManager.requestWhenInUseAuthorization()
var currentLoc: CLLocation!
if(CLLocationManager.authorizationStatus() == .authorizedWhenInUse ||
CLLocationManager.authorizationStatus() == .authorizedAlways) {
   currentLoc = locationManager.location
   print(currentLoc.coordinate.latitude)
   print(currentLoc.coordinate.longitude)
}
Here “requestWhenInUseAuthorization” means Requests permission to use location services while the app is in the foreground.
Step 6 − Run the application to get the latitude and longitude, Find the Complete code
import UIKit
import CoreLocation
class ViewController: UIViewController {
   var locationManager = CLLocationManager()
   override func viewDidLoad() {
      super.viewDidLoad()
      locationManager.requestWhenInUseAuthorization()
      var currentLoc: CLLocation!
      if(CLLocationManager.authorizationStatus() == .authorizedWhenInUse ||
      CLLocationManager.authorizationStatus() == .authorizedAlways) {
         currentLoc = locationManager.location
         print(currentLoc.coordinate.latitude)
         print(currentLoc.coordinate.longitude)
      }
   }
}
How to remove options from a dropdown list with JavaScript?

To remove options from a dropdown list, use the remove() method in JavaScript. You can try to run the following code to learn how to remove options from the drop-down −
<!DOCTYPE html>
<html>
   <body>
      <form id = "myForm">
         <select id = "selectNow">
            <option>One</option>
            <option>Two</option>
            <option>Three</option>
         </select>
         <input type = "button" onclick = "remove()" value = "Click to Remove">
      </form>
      <p>Select and click the button to remove the selected option.</p>
      
      <script>
         function remove() {
            var x = document.getElementById("selectNow");
            x.remove(x.selectedIndex);
         }
      </script>
      
   </body>
</html>
p5.js Image delay() Method - GeeksforGeeks

30 Sep, 2020
The delay() method of p5.Image in p5.js is used to change the delay between each frame in a GIF animation. This value can be set in milliseconds and a higher value would mean that the GIF would show its next frame after a longer time.
An optional second parameter can be used to specify the index of the frame that needs to have the new delay value set. All the frames would get the new delay value if nothing is specified.
Syntax:
resize( d, index )

Parameters: This function accepts two parameters as mentioned above and described below. 
d: It is a number that specifies the amount to delay between each frame in milliseconds.
index: It is a number that specifies the index of the frame that has to be modified. It is an optional parameter.
The examples below illustrate the delay() method in p5.js:
Example 1:
Javascript
function preload() {    faster_gif = loadImage("sample-gif.gif");    slower_gif = loadImage("sample-gif.gif");}  function setup() {    createCanvas(500, 300);    textSize(20);      text('Faster GIF', 20, 20);    text('Slower GIF', 20, 180);      // Speed up the GIF with a delay    // of 10 milliseconds between    // each frame    faster_gif.delay(10);      // Slow down the GIF with a delay    // of 100 milliseconds between    // each frame    slower_gif.delay(100);}  function draw() {    image(faster_gif, 20, 40, 200, 100);    image(slower_gif, 20, 200, 200, 100);}
Output:
Example 2:
Javascript
function preload() {    normal_gif = loadImage("sample-gif.gif");    modified_gif = loadImage("sample-gif.gif");}  function setup() {    createCanvas(500, 300);    textSize(20);      text('Normal GIF', 20, 20);    text('Modified GIF', 20, 180);      // Modify the GIF with the delay    // applied to the 100th frame    modified_gif.delay(4000, 100);}  function draw() {    image(normal_gif, 20, 40, 200, 100);    image(modified_gif, 20, 200, 200, 100);}
Output:
Online editor: https://editor.p5js.org/Environment Setup: https://www.geeksforgeeks.org/p5-js-soundfile-object-installation-and-methods/Reference: https://p5js.org/reference/#/p5.Image/delay
JavaScript-p5.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to calculate the number of days between two dates in javascript?
File uploading in React.js
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Redux - Installation

Before installing Redux, we have to install Nodejs and NPM. Below are the instructions that will help you install it. You can skip these steps if you already have Nodejs and NPM installed in your device.
Visit https://nodejs.org/ and install the package file.
Visit https://nodejs.org/ and install the package file.
Run the installer, follow the instructions and accept the license agreement.
Run the installer, follow the instructions and accept the license agreement.
Restart your device to run it.
Restart your device to run it.
You can check successful installation by opening the command prompt and type node -v. This will show you the latest version of Node in your system.
You can check successful installation by opening the command prompt and type node -v. This will show you the latest version of Node in your system.
To check if npm is installed successfully, you can type npm –v which returns you the latest npm version.
To check if npm is installed successfully, you can type npm –v which returns you the latest npm version.
To install redux, you can follow the below steps −
Run the following command in your command prompt to install Redux.
npm install --save redux

To use Redux with react application, you need to install an additional dependency as follows −
npm install --save react-redux

To install developer tools for Redux, you need to install the following as dependency −
Run the below command in your command prompt to install Redux dev-tools.
npm install --save-dev redux-devtools

If you do not want to install Redux dev tools and integrate it into your project, you can install Redux DevTools Extension for Chrome and Firefox.

    56 Lectures 
     12.5 hours 

 Eduonix Learning Solutions

    63 Lectures 
     9.5 hours 

 TELCOMA Global

    129 Lectures 
     19.5 hours 

 Ghulam Abbas

    31 Lectures 
     3 hours 

 Saumitra Vishal

    55 Lectures 
     4 hours 

 Saumitra Vishal
 Print
 Add Notes
 Bookmark this page
Java long Keyword

❮ Java Keywords

long myNum = 15000000000L;
System.out.println(myNum);


Try it Yourself »

The long keyword is a data type that can store whole numbers from -9223372036854775808 to 9223372036854775808.
Note that you should end the value with an "L":
Read more about data types in our Java Data Types Tutorial.

❮ Java Keywords

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.
Equality Operators: == and !=  in C++

The equality operators in C++ are is equal to(==) and is not equal to(!=). They do the task as they are named. The binary equality operators compare their operands for strict equality or inequality. The equality operators, equal to (==) and not equal to (!=), have lower precedence than the relational operators, but they behave similarly. The result type for these operators is bool.
The equal-to operator (==) returns true (1) if both operands have the same value; otherwise, it returns false (0). The not-equal-to operator (!=) returns true if the operands do not have the same value; otherwise, it returns false.
#include <iostream>  
using namespace std;  
int main() {  
   // For printing true and false as true and false in case of a bool result
   cout  << boolalpha  
   << "The true expression 3 != 2 yields: "  
   << (3 != 2) << endl  
   << "The false expression 20 == 10 yields: "  
   << (20 == 10) << endl;  
}
This gives the output −
The true expression 3 != 2 yields: true
The false expression 20 == 10 yields: false
How to attempt Function Coding Questions?

17 Aug, 2018
Function Coding Questions are similar to normal coding questions apart from the fact that one does not need to read input and print output from standard I/O while writing solutions.
In function coding question, one just needs to complete a function already written in the code editor. You need to work on inputs provided as a parameter to this function and instead of printing the result you will have to return it from the function.
Let’s take the example of a sample function problem: Equilibrium Index of an Array. The pattern of question is almost the same as that of normal programming questions. In function problems, you can notice an additional information provided as “Task” after the output format which clearly explains that the user only needs to complete a function and return the result from it.
You can also see that in the code editor for this question there is already a function written with name findEquilibrium().
This function accepts an array A[] and an integer n which denotes the size of the array A[]. You can see in the above image that the body of this function is empty. You need to write your complete code inside the body of this function and return the result from it without writing a separate main() function. You must assume that there is already a main() function written which is invoking this function and write your program accordingly.
Below is the complete working solution for the above question:
/*Please note that it's Function problem i.e.you need to write your solution in the form of Function(s) only.Driver Code to call/invoke your function is mentioned above.*/  /* You are required to complete this method*/int findEquilibrium(int A[], int n){    // Your code here    int i, y, f, j, x;    for (i = 1; i < n; i++) {        y = 0;        x = 0;        for (j = 0; j < i; j++) {            y = y + A[j];        }        for (j = i + 1; j < n; j++) {            x = x + A[j];        }        if (x == y) {            f = 1;              // returning answer            return (i);            break;        }        else {            f = 0;        }    }    if (f == 0) {        // returning answer        return (-1);    }}
Important things to remember
One should assume that a main() function is already present which is invoking the current function and should not write a separate main() function.
Use inputs as provided in the function parameters.
Return result from the function instead of printing it.
interview-preparation
placement preparation
Articles
Placements
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Must Do Questions for Companies like TCS, CTS, HCL, IBM ...
Const keyword in C++
Service-Oriented Architecture
Advantages and Disadvantages of Linked List
What's the difference between Scripting and Programming Languages?
SDE SHEET - A Complete Guide for SDE Preparation
TCS Placement Paper | MCQ 1
Numbers
Interview Preparation
TCS Placement Paper | Email Writing Question 1
Python PIL | ImageFont.truetype()

14 Jul, 2019
PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. The ImageFont module defines a class with the same name. Instances of this class store bitmap fonts, and are used with the PIL.ImageDraw.Draw.text() method.
PIL uses its own font file format to store bitmap fonts. You can use the :command`pilfont` utility to convert BDF and PCF font descriptors (X window font formats) to this format.
PIL.ImageFont.truetype() Load a TrueType or OpenType font file, and create a font object. This function loads a font object from the given file, and creates a font object for a font of the given size.
This function requires the _imagingft service.
Syntax: PIL.ImageFont.truetype(font=None, size=10, index=0, encoding=”)
Parameters:
font – A truetype font file. Under Windows, if the file is not found in this filename, the loader also looks in Windows fonts/ directory.size – The requested size, in points.index – Which font face to load (default is first available face).encoding – Which font encoding to use (default is Unicode).
Returns: A font object.Exception: IOError – If the file could not be read.
Image Used:
   # Importing Image and ImageFont, ImageDraw module from PIL package from PIL import Image, ImageFont, ImageDraw      # creating a image objectimage = Image.open(r'C:\Users\System-Pc\Desktop\rose.jpeg')   draw = ImageDraw.Draw(image)  font = ImageFont.truetype(r'C:\Users\System-Pc\Desktop\arial.ttf', 70)  text = 'DO NOT DRINK AND \nDRIVE'  draw.text((10, 20), text, font = font)  image.show()
Output:
Another example:Take another image.Image Used
Importing Image and ImageFont, ImageDraw module from PIL package from PIL import Image, ImageFont, ImageDraw      # creating a image objectimage = Image.open(r'C:\Users\System-Pc\Desktop\flower.jpg')   draw = ImageDraw.Draw(image)  font = ImageFont.truetype(r'C:\Users\System-Pc\Desktop\arial.ttf', 70)  text = 'stay healthy'  draw.text((50, 100), text, font = font)  image.show()
Output:
Python-pil
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Create a directory in Python
GATE | GATE CS 1999 | Question 22

25 Nov, 2020
The main memory of a computer has 2 cm blocks while the cache has 2c blocks. If the cache uses the set associative mapping scheme with 2 blocks per set, then the block k of main memory maps to the set:(A) (k mod m) of the cache(B) (k mod c) of the cache(C) (k mod 2c) of the cache(D) (k mod 2cm) of the cacheAnswer: (B)Explanation: Given,Main memory = 2 C M blocksCache Size = 2 C blocks
Set Associative Mapping is 2-way set associative. Therefore Number of lines per set = 2 {i.e., Set size}.
Number of sets,
= Cache size / Set size
= 2 C / 2 

Number of sets = C in the cache.
kth block of the main memory maps to (K mod C)th set of the main memory .
i = k modulo c
where
i = cache set number
k = main memory block number
c = number of sets in the cache 
This solution is contributed by VIVEK YEMUL.Quiz of this Question
vivekyemul786
GATE CS 1999
GATE-GATE CS 1999
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | GATE-CS-2014-(Set-2) | Question 65
GATE | Sudo GATE 2020 Mock I (27 December 2019) | Question 33
GATE | GATE CS 2008 | Question 46
GATE | GATE-CS-2014-(Set-3) | Question 65
GATE | GATE-CS-2015 (Set 3) | Question 65
GATE | GATE CS 2011 | Question 49
GATE | GATE CS 1996 | Question 38
GATE | GATE-CS-2004 | Question 31
GATE | GATE IT 2006 | Question 20
GATE | GATE-CS-2016 (Set 1) | Question 45
Hamiltonian Cycle

In an undirected graph, the Hamiltonian path is a path, that visits each vertex exactly once, and the Hamiltonian cycle or circuit is a Hamiltonian path, that there is an edge from the last vertex to the first vertex.
In this problem, we will try to determine whether a graph contains a Hamiltonian cycle or not. And when a Hamiltonian cycle is present, also print the cycle.
Input:
The adjacency matrix of a graph G(V, E).

Output:
The algorithm finds the Hamiltonian path of the given graph. For this case it is (0, 1, 2, 4, 3, 0). This graph has some other Hamiltonian paths.
If one graph has no Hamiltonian path, the algorithm should return false.
isValid(v, k)
Input − Vertex v and position k.
Output − Checks whether placing v in the position k is valid or not.
Begin
   if there is no edge between node(k-1) to v, then
      return false
   if v is already taken, then
      return false
   return true; //otherwise it is valid
End
cycleFound(node k)
Input − node of the graph.
Output − True when there is a Hamiltonian Cycle, otherwise false.
Begin
   if all nodes are included, then
      if there is an edge between nodes k and 0, then
         return true
      else
         return false;

   for all vertex v except starting point, do
      if isValid(v, k), then //when v is a valid edge
         add v into the path
         if cycleFound(k+1) is true, then
            return true
         otherwise remove v from the path
   done
   return false
End
#include<iostream>
#define NODE 5
using namespace std;

int graph[NODE][NODE] = {
   {0, 1, 0, 1, 0},
   {1, 0, 1, 1, 1},
   {0, 1, 0, 0, 1},
   {1, 1, 0, 0, 1},
   {0, 1, 1, 1, 0},
};
   
/* int graph[NODE][NODE] = {
   {0, 1, 0, 1, 0},
   {1, 0, 1, 1, 1},
   {0, 1, 0, 0, 1},
   {1, 1, 0, 0, 0},
   {0, 1, 1, 0, 0},
}; */

int path[NODE];

void displayCycle() {
   cout<<"Cycle: ";

   for (int i = 0; i < NODE; i++)
      cout << path[i] << " ";
   cout << path[0] << endl;      //print the first vertex again
}

bool isValid(int v, int k) {
   if (graph [path[k-1]][v] == 0)   //if there is no edge
      return false;

   for (int i = 0; i < k; i++)   //if vertex is already taken, skip that
      if (path[i] == v)
         return false;
   return true;
}

bool cycleFound(int k) {
   if (k == NODE) {             //when all vertices are in the path
      if (graph[path[k-1]][ path[0] ] == 1 )
         return true;
      else
         return false;
   }

   for (int v = 1; v < NODE; v++) {       //for all vertices except starting point
      if (isValid(v,k)) {                //if possible to add v in the path
         path[k] = v;
         if (cycleFound (k+1) == true)
            return true;
         path[k] = -1;               //when k vertex will not in the solution
      }
   }
   return false;
}

bool hamiltonianCycle() {
   for (int i = 0; i < NODE; i++)
      path[i] = -1;
   path[0] = 0; //first vertex as 0

   if ( cycleFound(1) == false ) {
      cout << "Solution does not exist"<<endl;
      return false;
   }

   displayCycle();
   return true;
}

int main() {
   hamiltonianCycle();
}
Cycle: 0 1 2 4 3 0
How to show ProgressBar in ReactNative?

ProgressBar is a way to tell users that the content will be available in sometime. It can best be used when you submit something to the server and wait for the server to respond.
To work with the progress bar component install react-native-paper module using npm.
The command to install react-native-paper is −
npm install --save-dev react-native-paper
The basic component of progress bar is as follows−
<ProgressBar progress={progress_number} color="progresscolorbar" />
To work with Progress Bar you need to import it from react-native-paper as follows −
import { ProgressBar} from 'react-native-paper';
Following are some of the important properties available on ProgressBar −
It is very simple to display a progressbar. Just import it first from react-native-paper.
import { ProgressBar} from 'react-native-paper';
The show a progress bar the code is as follows −
<ProgressBar style={{ marginTop:200}} progress={0.5} color="#00BCD4" />
The default value is 0.5 and it will increment till 10.
import * as React from 'react';
import { ProgressBar} from 'react-native-paper';
const MyComponent = () => (
   <ProgressBar style={{ marginTop:200}} progress={0.5} color="#00BCD4" />
);
export default MyComponent;
Python 3 - dictionary get() Method

The method get() returns a value for the given key. If key is not available then returns default value None.
Following is the syntax for get() method −
dict.get(key, default=None)

key − This is the Key to be searched in the dictionary.
key − This is the Key to be searched in the dictionary.
default − This is the Value to be returned in case key does not exist.
default − This is the Value to be returned in case key does not exist.
This method return a value for the given key. If key is not available, then returns default value None.
The following example shows the usage of get() method.
#!/usr/bin/python3 

dict = {'Name': 'Zara', 'Age': 27}

print ("Value : %s" %  dict.get('Age'))
print ("Value : %s" %  dict.get('Sex', "NA"))
When we run above program, it produces the following result −
Value : 27
Value : NA


    187 Lectures 
     17.5 hours 

 Malhar Lathkar

    55 Lectures 
     8 hours 

 Arnab Chakraborty

    136 Lectures 
     11 hours 

 In28Minutes Official

    75 Lectures 
     13 hours 

 Eduonix Learning Solutions

    70 Lectures 
     8.5 hours 

 Lets Kode It

    63 Lectures 
     6 hours 

 Abhilash Nelson
 Print
 Add Notes
 Bookmark this page
TestNG - Basic Annotations - Factory

@Factory annotated method allows tests to be created at runtime depending on certain data-sets or conditions. The method must return Object[].
Create a java test class, say, SimpleTestFactory.java.
Create a java test class, say, SimpleTestFactory.java.
Add a test method testMethod() to your test class.
Add a test method testMethod() to your test class.
Add an Annotation @Test to method testMethod().
Add an Annotation @Test to method testMethod().
Create a java class file called SimpleTestFactory.java in /work/testng/src.
  import org.testng.annotations.Test;
  public class SimpleTestFactory {
    @Test
    public void testMethod(){
      System.out.println("Simple Test Method.");
      }
  }
Create a another java class, say, TestAnnotationFactory.java in /work/testng/src.
Create a another java class, say, TestAnnotationFactory.java in /work/testng/src.
Add a factory method factoryMethod() to your test class. It's mandatory
that a factory method should return an array of Object class ( Object [] )
Add a factory method factoryMethod() to your test class. It's mandatory
that a factory method should return an array of Object class ( Object [] )
Add an Annotation @Factory to method factoryMethod().
Add an Annotation @Factory to method factoryMethod().
Following are the TestAnnotationFactory.java contents:
  import org.testng.annotations.Test;
  import org.testng.annotations.Factory;

  public class TestAnnotationFactory {
    @Factory
    public Object[] factoryMethod() {
      return new Object[]{
        new SimpleTestFactory(),
        new SimpleTestFactory()
        };
    }
  }
Next, let's create testng.xml file in /work/testng/src, to execute test case(s). This file captures your entire testing in XML. This file makes it easy to describe all your test suites and their parameters in one file, which you can check in your code repository or e-mail to coworkers. It also makes it easy to extract subsets of your tests or split several runtime configurations (e.g., testngdatabase.xml would run only tests that exercise your database).
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
  <suite name="Suite">
    <test thread-count="5" name="Test">
      <classes>
        <class name="TestAnnotationFactory"/>
      </classes>
    </test> <!-- Test -->
  </suite> <!-- Suite -->
Compile the test case using javac.
/work/testng/src$ javac SimpleTestFactory.java TestAnnotationFactory.java

Now, run the testng.xml, which will run the test case defined in <test> tag. As you can see the the test method from the SimpleTestFactory class was executed two times.
/work/testng/src$ java org.testng.TestNG testng.xml

Verify the output.
  Simple Test Method.
  Simple Test Method.

  ===============================================
  Suite
  Total tests run: 2, Passes: 2, Failures: 0, Skips: 0
  ===============================================


    38 Lectures 
     4.5 hours 

 Lets Kode It

    15 Lectures 
     1.5 hours 

 Quaatso Learning

    28 Lectures 
     3 hours 

 Dezlearn Education
 Print
 Add Notes
 Bookmark this page
Arrays in Java - GeeksforGeeks

07 Dec, 2018
Unlike C++, arrays are first class objects in Java. For example, in the following program, size of array is accessed using length which is a member of arr[] object.
// file name: Main.javapublic class Main {    public static void main(String args[]) {       int arr[] = {10, 20, 30, 40, 50};       for(int i=0; i < arr.length; i++)       {             System.out.print(" " + arr[i]);                     }    }}
Output:10 20 30 40 50
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Java-Output
Arrays
Java
School Programming
Arrays
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Trapping Rain Water
Program to find sum of elements in a given array
Reversal algorithm for array rotation
Window Sliding Technique
Find duplicates in O(n) time and O(1) extra space | Set 1
Split() String method in Java with examples
For-each loop in Java
Reverse a string in Java
HashMap in Java with Examples
Interfaces in Java
GATE | GATE-CS-2007 | Question 85 - GeeksforGeeks

11 Sep, 2019
Consider the following segment of C-code:
  int j, n;
  j = 1;
  while (j <= n)
        j = j*2; 
The number of comparisons made in the execution of the loop for any n > 0 is:
Base of Log is 2 in all options.(A) CEIL(logn) + 2(B) n(C) CEIL(logn)(D) FLOOR(logn) + 2Answer: (D)Explanation:
We can see it by taking few examples like n = 1, n = 3, etc.

For example, for n=5 we have the following (4) comparisons:
------------------------
1 <= 5 (T)
2 <= 5 (T)
4 <= 5 (T)
8 <= 5 (F)

------------------------
FLOOR(log_2 n)+2 = FLOOR(log_2 5) + 2 = FLOOR(2.3) + 2 = 2 + 2 = 4
Quiz of this Question
UzairGhauri
VivekRaj9
GATE-CS-2007
GATE-GATE-CS-2007
GATE
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
GATE | Gate IT 2007 | Question 25
GATE | GATE-CS-2000 | Question 41
GATE | GATE-CS-2001 | Question 39
GATE | GATE-CS-2005 | Question 6
GATE | GATE MOCK 2017 | Question 21
GATE | GATE-CS-2006 | Question 47
GATE | GATE MOCK 2017 | Question 24
GATE | Gate IT 2008 | Question 43
GATE | GATE-CS-2009 | Question 38
GATE | GATE-CS-2003 | Question 90