code-rag-bench/online-tutorials huggingface dataset:
How to create an about / about us page for website with CSS?

To create an about page, the code is as follows −
 Live Demo
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
   html {
      box-sizing: border-box;
   }
   body {
      font-family: monospace, serif, sans-serif;
      margin: 0px;
      padding: 0px;
   }
   h1 {
      text-align: center;
      background-color: rgb(108, 18, 131);
      color: white;
      padding-top: 40px;
      padding-bottom: 40px;
      margin-top: 0px;
   }
   .teamContainer {
      margin-left: 10%;
   }
   img {
      width: 100%;
      height: 200px;
   }
   *, *:before, *:after {
      box-sizing: inherit;
   }
   .teamColumn {
      display: inline-block;
      width: 300px;
      height: 400px;
      margin-bottom: 16px;
      padding: 0 8px;
   }
   @media screen and (max-width: 650px) {
      .teamColumn {
         display: block;
      }
   }
   .teamCard {
      background-color: rgb(162, 162, 255);
      text-align: center;
      font-size: 20px;
   }
   .personContainer {
      padding: 0 16px;
   }
   .personContainer::after, .teamContainer::after {
      content: "";
      clear: both;
      display: table;
   }
   .Designation {
      color: rgb(15, 0, 100);
      font-weight: bolder;
      font-size: 20px;
   }
   .contact {
      border: none;
      outline: 0;
      display: inline-block;
      padding: 12px;
      color: white;
      font-weight: bolder;
      background-color: rgb(78, 0, 102);
      text-align: center;
      cursor: pointer;
      width: 100%;
   }
   .contact:hover {
      background-color: #555;
   }
</style>
</head>
<body>
<h1>About Us</h1>
<div class="teamContainer">
<div class="teamColumn">
<div class="teamCard">
<img src="https://images.pexels.com/photos/839011/pexels-photo839011.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"/>
<div class="personContainer">
<h3>Jane Doe</h3>
<p class="Designation">CTO</p>
<p><button class="contact">Contact</button></p>
</div>
</div>
</div>
<div class="teamColumn">
<div class="teamCard">
<img
src="https://images.pexels.com/photos/614810/pexels-photo614810.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"/>
<div class="personContainer">
<h3>Mike Ross</h3>
<p class="Designation">Front End Developer</p>
<p><button class="contact">Contact</button></p>
</div>
</div>
</div>
<div class="teamColumn">
<div class="teamCard">
<img
src="https://images.pexels.com/photos/736716/pexels-photo736716.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500"/>
<div class="personContainer">
<h3>John Doe</h3>
<p class="Designation">FullStack Developer</p>
<p><button class="contact">Contact</button></p>
</div>
</div>
</div>
</div>
</body>
</html>
The above code will create the following output −
Python | Download YouTube videos using youtube_dl module

26 May, 2019
Each and every day, you must be watching some video or another on YouTube which may be related to Music, Movies, Studies, Research, Leisure etc. You might want to store some video for future use where it will be required due to lack of internet or saving data or any other reason.
What if we tell you that you can do this exact very thing using Python. Let’s see how to download Youtube videos using youtube_dl module in Python.
Install the module with this command –
pip install youtube_dl

Now, suppose you are watching this video on YouTube.
Below is the Python code –
# importing moduleimport youtube_dl  ydl_opts = {}  def dwl_vid():    with youtube_dl.YoutubeDL(ydl_opts) as ydl:        ydl.download([zxt])  channel = 1while (channel == int(1)):    link_of_the_video = input("Copy & paste the URL of the YouTube video you want to download:- ")    zxt = link_of_the_video.strip()      dwl_vid()    channel = int(input("Enter 1 if you want to download more videos \nEnter 0 if you are done "))
Output:
And it’s done. The video you want gets downloaded in the Python folder.
python-utility
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to list all the Collections in a MongoDB database using Java?

You can print a list of all the existing collections in a database using show collections.
Assume we have created 3 collections in a MongoDB database as shown below −
> use sampleDatabase
switched to db sampleDatabase
> db.createCollection("students")
{ "ok" : 1 }
> db.createCollection("teachers")
{ "ok" : 1 }
> db.createCollection("sample")
{ "ok" : 1 }
Following query lists all the collections in the database −
> use sampleDatabase
switched to db sampleDatabase
> show collections
sample
students
teachers
In Java, you can get the names of all collections in the current database using the listCollectionNames() method of the com.mongodb.client.MongoCollection
interface.
Therefore to list all the collections in a database in MongoDB using Java program −
Make sure you have installed MongoDB in your system
Make sure you have installed MongoDB in your system
Add the following dependency to its pom.xml file of your Java project.
Add the following dependency to its pom.xml file of your Java project.
<dependency>
   <groupId>org.mongodb</groupId>
   <artifactId>mongo-java-driver</artifactId>
   <version>3.12.2</version>
</dependency>
Create a MongoDB client by instantiating the MongoClient class.
Create a MongoDB client by instantiating the MongoClient class.
Connect to a database using the getDatabase() method.
Connect to a database using the getDatabase() method.
Get the list of the collections using the listCollectionNames() method.
Get the list of the collections using the listCollectionNames() method.
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.MongoIterable;
import com.mongodb.MongoClient;
public class ListOfCollection {
   public static void main( String args[] ) {
      // Creating a Mongo client
      MongoClient mongo = new MongoClient( "localhost" , 27017 );
      //Connecting to the database
      MongoDatabase database = mongo.getDatabase("mydatabase");
      //Creating multiple collections
      database.createCollection("sampleCollection1");
      database.createCollection("sampleCollection2");
      database.createCollection("sampleCollection3");
      database.createCollection("sampleCollection4");
      //Retrieving the list of collections
      MongoIterable<String> list = database.listCollectionNames();
      for (String name : list) {
         System.out.println(name);
      }
   }
}
sampleCollection3
sampleCollection2
sampleCollection4
sampleCollection1
How to create a scatterplot using ggplot2 with different shape and color of points based on a variable in R?

In general, the default shape of points in a scatterplot is circular but it can be changed to other shapes using integers or sequence or the variable. We just need to use the argument shape inside geom_point function and pass the variable name. For example, if we want to create the scatterplot with varying shapes of a variable x then we can use geom_point(shape=x). And if we want to change the size then integer values can be used.
Consider the below data frame −
 Live Demo
set.seed(151)
x<-rnorm(20,5,1)
y<-rnorm(20,5,2)
df<-data.frame(x,y)
df
      x       y
1 4.948461 2.255857
2 5.765737 1.726474
3 4.853260 4.280697
4 4.886814 7.402230
5 4.604489 3.708252
6 5.782276 3.978782
7 3.602522 3.801754
8 3.981162 6.091206
9 5.229476 4.017412
10 5.672173 5.383071
11 4.515448 3.882945
12 5.560609 6.845399
13 5.066156 7.307996
14 3.650124 2.255179
15 4.757084 7.580363
16 3.763259 7.309804
17 3.525322 7.891359
18 7.437159 5.522026
19 5.673526 8.858292
20 5.310040 3.800228
Loading ggplot2 package and creating point chart between x and y −
library(ggplot2)
ggplot(df,aes(x,y))+geom_point()
Creating the scatterplot by different shape of the points and the size = 3 −
ggplot(df,aes(x,y))+geom_point(shape=x,color=x,size=3)
LocalDate plusDays() Method in Java with Examples

30 Apr, 2019
The plusDays() method of a LocalDate class in Java is used to add the number of specified day in this LocalDate and return a copy of LocalDate. For example, 2018-12-31 plus one day would result in 2019-01-01. This instance is immutable and unaffected by this method call.
Syntax:
public LocalDate plusDays(long daysToAdd)

Parameters: This method accepts a single parameter daysToAdd which represents the days to add, may be negative.
Return Value: This method returns a LocalDate based on this date with the days added, not null.
Exception: This method throws DateTimeException if the result exceeds the supported date range.
Below programs illustrate the plusDays() method:
Program 1:
// Java program to demonstrate// LocalDate.plusDays() method  import java.time.*;  public class GFG {    public static void main(String[] args)    {          // create a LocalDate object        LocalDate date            = LocalDate.parse("2018-11-13");          // print instance        System.out.println("LocalDate before"                           + " adding days: " + date);          // add 5 days        LocalDate returnvalue            = date.plusDays(5);          // print result        System.out.println("LocalDate after "                           + " adding days: " + returnvalue);    }}
LocalDate before adding days: 2018-11-13
LocalDate after  adding days: 2018-11-18

Program 2:
// Java program to demonstrate// LocalDate.plusDays() method  import java.time.*;  public class GFG {    public static void main(String[] args)    {          // create a LocalDate object        LocalDate date            = LocalDate.parse("2018-12-24");          // print instance        System.out.println("LocalDate before"                           + " adding days: " + date);          // add 15 days        LocalDate returnvalue            = date.plusDays(15);          // print result        System.out.println("LocalDate after "                           + " adding days: " + returnvalue);    }}
LocalDate before adding days: 2018-12-24
LocalDate after  adding days: 2019-01-08

Reference:https://docs.oracle.com/javase/10/docs/api/java/time/LocalDate.html#plusDays(long)
Akanksha_Rai
Java-Functions
Java-LocalDate
Java-time package
Java
Java
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to use AppBar Component in ReactJS ?

12 Feb, 2021
The App Bar displays information and actions relating to the current screen. Material UI for React has this component available for us and it is very easy to integrate. We can use the AppBar Component in ReactJS using the following approach.
Creating React Application And Installing Module:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Step 3: After creating the ReactJS application, Install the material-ui modules using the following command:
npm install @material-ui/core
npm install @material-ui/icons
App.js: Now write down the following code in the App.js file. Here, App is our default component where we have written our code.
Javascript
import React from "react";import Toolbar from "@material-ui/core/Toolbar";import AppBar from "@material-ui/core/AppBar";import Typography from "@material-ui/core/Typography";import IconButton from "@material-ui/core/IconButton";import Button from "@material-ui/core/Button";import MenuIcon from "@material-ui/icons/Menu";  const App = () => {  return (    <div>      <h2>How to use AppBar Component in ReactJS?</h2>      <AppBar position="static">        <Toolbar>          <IconButton            edge="start"            style={{              marginRight: 20,            }}            color="inherit"            aria-label="menu"          >            <MenuIcon />          </IconButton>          <Typography            variant="h6"            style={{              flexGrow: 1,            }}          >            Dashboard          </Typography>          <Button color="inherit">Logout</Button>        </Toolbar>      </AppBar>    </div>  );};  export default App;
Step to Run Application: Run the application using the following command from the root directory of the project.
npm start
Output: Now open your browser and go to http://localhost:3000/, you will see the following output.
React-Questions
JavaScript
ReactJS
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Magic Tables in SQL Server

11 Jun, 2021
Magic tables are the temporary logical tables that are created by the SQL server whenever there are insertion or deletion or update( D.M.L)  operations. The recently performed operation on the rows gets stored in magic tables automatically. These are not physical table but they are just temporary internal tables. These magic tables can’t be retrieved directly, we need to use triggers to access these magic tables to get the deleted and inserted rows.
When the following operations are done : 
INSERT – The recently inserted row gets added to the INSERTED magic table. 
DELETE –The recently deleted row gets added to the DELETED magic table. 
UPDATE –The updated row gets stored in INSERTED magic table and the old row or previous row gets stored in the DELETED magic table.
Let us see how this works by using MSSQL as a server:
Creating a database :Creating a database GeeksForGeeks by using the following SQL query as follows.
CREATE DATABASE GeeksForGeeks;
Using the database :Using the database student using the following SQL query as follows.
USE GeeksForGeeks;
Creating table students with SQL query as follows:
CREATE TABLE students
( 
 stu_id varchar(10),
 stu_name varchar(20),
 branch varchar(20)
);
Verifying the database :To view the description of the table in the database GeeksForGeeks using the following SQL query as follows.
EXEC sp_columns students;
Inserting data into the table :Inserting rows into students table using the following SQL query as follows:
INSERT INTO students VALUES
('1901401','DEVA','C.S'),
('1901402','HARSH','C.S'),
('1901403','ABHISHEK','C.S'),
('1901404','GARVIT','C.S'),
('1901405','SAMPATH','C.S');
Verifying the inserted data :Viewing the table after inserting rows by using the following SQL query as follows.
SELECT * FROM students;
Creating a trigger T1 on insert operation :
CREATE TRIGGER T1 ON students
AFTER INSERT
AS
BEGIN
SELECT * FROM INSERTED
END
Inserting entries to check how trigger retrieves INSERTED magic table :
INSERT INTO students VALUES
('1901406','PRADEEP','C.S'),
('1901407','DEVESH','C.S');
SELECT* FROM students ;
Creating a trigger T2 on delete operation :
CREATE TRIGGER T2 ON students
AFTER DELETE
AS
BEGIN
SELECT * FROM DELETED
END
Deleting entry to check how trigger retrieves DELETED magic table :
DELETE FROM students
WHERE stu_name = 'PRADEEP';
SELECT* FROM students ;
Creating a trigger T3 on update operation :
CREATE TRIGGER T3 ON students
AFTER UPDATE
AS
BEGIN
SELECT * FROM DELETED
SELECT* FROM INSERTED 
END
Updating entry to check how trigger retrieves DELETED, INSERTED magic tables since we find an old entry in a DELETED and updated entry in the INSERTED magic table :
UPDATE students SET stu_name= 'DEVANSH' 
WHERE stu_id = '1901401'
SELECT* FROM students
DBMS-SQL
Picked
SQL-Server
SQL
SQL
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Subgroup and Order of group | Mathematics

20 May, 2019
Prerequisite: Groups
A nonempty subset H of the group G is a subgroup of G if H is a group under binary operation (*) of G. We use the notation H ≤ G to indicate that H is a subgroup of G. Also, if H is a proper subgroup then it is denoted by H < G .
H ≠ φ
if a, k ∈ H then ak ∈ H
if a ∈ H then a-1 ∈ H
Ex. – Integers (Z) is a subgroup of rationals (Q) under addition, (Z, +) < (Q, +)
Note:G is a subgroup of itself and {e} is also subgroup of G, these are called trivial subgroup.Subgroup will have all the properties of a group.A subgroup H of the group G is a normal subgroup if g -1 H g = H for all g ∈ G.If H < K and K < G, then H < G (subgroup transitivity).if H and K are subgroups of a group G then H ∩ K is also a subgroup.if H and K are subgroups of a group G then H ∪ K is may or maynot be a subgroup.
G is a subgroup of itself and {e} is also subgroup of G, these are called trivial subgroup.
Subgroup will have all the properties of a group.
A subgroup H of the group G is a normal subgroup if g -1 H g = H for all g ∈ G.
If H < K and K < G, then H < G (subgroup transitivity).
if H and K are subgroups of a group G then H ∩ K is also a subgroup.
if H and K are subgroups of a group G then H ∪ K is may or maynot be a subgroup.
Let H be a subgroup of a group G. If g ∈ G, the right coset of H generated by g is, Hg = { hg, h ∈ H };and similarly, the left coset of H generated by g is gH = { gh, h ∈ H }
Example: Consider Z4 under addition (Z4, +), and let H={0, 2}. e = 0, e is identity element. Find the left cosets of H in G?Solution:
 The left cosets of H in G are,
 eH = e*H = { e * h | h ∈ H} = { 0+h| h ∈ H} = {0, 2}.
 1H= 1*H = {1 * h | h ∈ H} = { 1+h| h ∈ H} = {1, 3}.
 2H= 2*H = {2 * h | h ∈ H} = { 2+h| h ∈ H} = {0, 2}.
 3H= 3*H = {3 * h  |h ∈ H} = { 3+h| h ∈ H} = {1, 3}.
 Hence there are two cosets, namely 0*H= 2*H = {0, 2} and  1*H= 3*H = {1, 3}. 
The Order of a group (G) is the number of elements present in that group, i.e it’s cardinality. It is denoted by |G|.Order of element a ∈ G is the smallest positive integer n, such that an= e, where e denotes the identity element of the group, and an denotes the product of n copies of a. If no such n exists, a is said to have infinite order. All elements of finite groups have finite order.
Lagrange’s Theorem:
If H is a subgroup of finite group G then the order of subgroup H divides the order of group G.
The order of every element of a finite group is finite.
The Order of an element of a group is the same as that of its inverse a-1.
If a is an element of order n and p is prime to n, then ap is also of order n.
Order of any integral power of an element b cannot exceed the order of b.
If the element a of a group G is order n, then ak=e if and only if n is a divisor of k.
The order of the elements a and x-1ax is the same where a, x are any two elements of a group.
If a and b are elements of a group then the order of ab is same as order of ba.
Related GATE Questions:1) Gate CS 20182) Gate CS 2014 (Set-3)
Engineering Mathematics
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Static method in Interface in Java

To implement static method in Interface, the Java code is as follows −
 Live Demo
interface my_interface{
   static void static_fun(){
      System.out.println("In the newly created static method");
   }
   void method_override(String str);
}
public class Demo_interface implements my_interface{
   public static void main(String[] args){
      Demo_interface demo_inter = new Demo_interface();
      my_interface.static_fun();
      demo_inter.method_override("In the override method");
   }
   @Override
   public void method_override(String str){
      System.out.println(str);
   }
}
In the newly created static method
In the override method
An interface is defined, inside which a static function is defined. Another function named ‘method_override’ is defined without a body. This interface is implemented by another class named
‘Demo_interface’. Inside this class, the main function is defined, and an instance of this ‘Demo_interface’ is also created. The static function is called on this instance, and next, the
‘method_override’ function is called on this instance. An override specification is written, under
which the ‘method_override’ is defined. This function just prints the string on the console.
How to Spoof SMS Message in Linux ? - GeeksforGeeks

18 Jul, 2021
In this article, we will show how to spoof SMS messages in Linux using two of the following tools:-
fake-smsSocial Engineering Toolkit (SET)
fake-sms
Social Engineering Toolkit (SET)
It is a tool written in simple script to send SMS anonymously.
Send sms anonymously
Fast sms delivery
International sms sending available.
One can send only one sms per day.
Easy to install and use.
First, one needs to clone the tool from github repo using the following command:
 git clone https://github.com/machine1337/fake-sms
Change directory by,
cd fake-sms
Now we need to change permission before running it.
chmod +x run.sh
Run this tool first by typing the following command in your terminal window,
./run.sh
Type 1 and hit enter to see the usage of this tool.
Sending Fake SMS: Make sure that you use the victim’s country code and it should be without + and shouldn’t start with 0. For eg, 923443210111. Now enter your victim’s phone number with the country code and then type the message you want to send.
Checking SMS status: Now to check your sms status, copy the text id which was shown when you sent the message.
We can see from the above image that the status of our message is showing delivered, which means our message has been successfully delivered without any errors.
Go to your applications and search social engineering toolkit and hit enter or simply type the following command:
sudo setoolkit
Type 1 to select social-engineering attacks.
SMS Spoofing : Select SMS spoofing by typing 7 and hit enter.
Spoofed Text Message: Type 1 again to perform an SMS spoofing attack.
Crafting message: Type 1 to select an SMS  attack to a single phone number, and enter the phone number preceded by ‘+’ and country code. Then, select to one-time use SMS option.
Target’s Mob Number: Enter your target’s phone number and then enter the message you want to send.
Select intermediary: Select the intermediary for the spoofed SMS message from the given 4 options. Select the first option. It is the only one free, the rest 3 are paid but it is buggy and might not work. So select option 3 which is a paid one, enter your pincode and send the message.
And just like that, your spoofed message is sent.
How To
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install FFmpeg on Windows?
How to Install Jupyter Notebook on MacOS?
How to Install Flutter on Visual Studio Code?
How to Override compareTo Method in Java?
How to Install Python Pandas on MacOS?
AWK command in Unix/Linux with examples
Sed Command in Linux/Unix with examples
grep command in Unix/Linux
TCP Server-Client implementation in C
cut command in Linux with examples
What are the different data types of arrays in C#?

With C#, you can create an array of integers, chars, etc. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type stored at contiguous memory locations. This type can be integer, char, float, etc.
The following is an array declaration showing the datatype usage −
datatype[] Name_of_array;
Here,
datatype is used to specify the type of elements in the array.
[ ] specifies the rank of the array. The rank specifies the size of the array.
Name_of_array − specifies the name of the array.
Set the integer array −
int[] a;

Set the double array −
double[] z;
WhatWeb - Open Source Web Scanner - GeeksforGeeks

23 Sep, 2021
Whatweb is a free and open-source tool available on GitHub. Whatweb is a scanner written in the Ruby language. This tool can identify and recognize all the web technologies available on the target website. This tool can identify technologies used by websites such as blogging, content management system, all JavaScript libraries. Whatweb contains more than 180 modules. each module is responsible for grabbing particular information from the target website.  Whatweb works as an information-gathering tool and can identify all the email addresses, SQL errors, technology used in the website.
Step 1: Open your kali Linux operating system and use the following command to install the tool from GitHub.
cd Desktop
git clone https://github.com/urbanadventurer/WhatWeb/
Step 2: Now use the following command to move into the directory of the tool.
cd Whatweb
Step 3: Now you are in the directory of the tool. Use the following command to run the tool.
./whatweb 
The tool is running successfully. Now we will see examples to use the tool.
Example 1: Use the Whatweb tool to scan a domain.
./whatweb <domain>
Example 2: Use the Whatweb tool to scan a domain.
./whatweb <domain>
Kali-Linux
Linux-Tools
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Thread functions in C/C++
nohup Command in Linux with Examples
mv command in Linux with examples
Docker - COPY Instruction
SED command in Linux | Set 2
chown command in Linux with Examples
Basic Operators in Shell Scripting
Array Basics in Shell Scripting | Set 1
scp command in Linux with Examples
Named Pipe or FIFO with example C program
Data Structures | Binary Trees | Question 1 - GeeksforGeeks

28 Jun, 2021
Which of the following is a true about Binary Trees(A) Every binary tree is either complete or full.(B) Every complete binary tree is also a full binary tree.(C) Every full binary tree is also a complete binary tree.(D) No binary tree is both complete and full.(E) None of the aboveAnswer: (E)Explanation: A full binary tree (sometimes proper binary tree or 2-tree or strictly binary tree) is a tree in which every node other than the leaves has two children.
A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.
A) is incorrect. For example, the following Binary tree is neither complete nor full
     12
   /  
  20
 /
30
B) is incorrect. The following binary tree is complete but not full
     12
   /   \
  20    30
 /
30
C) is incorrect. Following Binary tree is full, but not complete
     12
   /   \
  20    30
       /  \  
      20   40

D) is incorrect. Following Binary tree is both complete and full
      12
    /   \
   20    30
  /  \  
 10   40

Please refer http://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_treesQuiz of this Question
Binary Trees Quiz
Data Structures
Data Structures-Binary Trees
Data Structures
Data Structures
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Advantages and Disadvantages of Linked List
Introduction to Data Structures | 10 most commonly used Data Structures
FIFO vs LIFO approach in Programming
Multilevel Linked List
Advantages of vector over array in C++
Difference between data type and data structure
Bit manipulation | Swap Endianness of a number
Data Structures | Array | Question 2
Data Structures | Queue | Question 1
Program to create Custom Vector Class in C++
Excel Syntax

A formula in Excel is used to do mathematical calculations. Formulas always start with the equal sign = typed in the cell, followed by your calculation. 

Note: You claim the cell by selecting it and typing the equal sign (=)
Select a cell
Type the equal sign (=)
Select a cell or type value
Enter an arithmetic operator
Select another cell or type value
Press enter
For example =1+1 is the formula to calculate 1+1=2
Note: The value of a cell is communicated by reference(value) for example A1(2)
You can type values to cells and use them in your formulas.
Lets type some dummy values to get started. Double click the cells to type values into them. Go ahead and type:
A1(309)
A2(320)
B1(39)
B2(35)
Compare with the picture shown below:
Note: Type values by selecting a cell, claim it by entering the equal sign (=) 
and then type your value. For example =309.
Well done! You have successfully typed values to cells and now we can use them to create formulas.

Here is how to do it, step by step.

Select the cell C1
Type the equal sign (=)
Left click on A1, the cell that has the (309) value
Type the minus sign (-)
Left click on B2, the cell that has the (35) value
Hit enter

Select the cell C1
Type the equal sign (=)
Left click on A1, the cell that has the (309) value
Type the minus sign (-)
Left click on B2, the cell that has the (35) value
Hit enter
Tip: The formula can be typed directly without clicking the cells. The typed formula would be the same as the value in C1 (=A1-B2). 
The result after hitting the enter button is C1(274). Did you make it? 

Let's try one more example, this time let's make the formula =A2-B1. 
Here is how to do it, step by step.

Select the cell C2
Type the equal sign (=)
Left click A2, the cell that has the (320) value
Type the minus sign (-)
Left click B1, the cell that has the (39) value
Hit the enter button

Select the cell C2
Type the equal sign (=)
Left click A2, the cell that has the (320) value
Type the minus sign (-)
Left click B1, the cell that has the (39) value
Hit the enter button
You got the result C2(281), right? Way to go!
Note: You can make formulas with all four arithmetic operations, such as addition (+), subtraction (-), multiplication (*) and division (/).
Here are some examples:
=2+4 gives you 6
=4-2 gives you 2
=2*4 gives you 8
=2/4 gives you 0.5
In the next chapter you will learn about Ranges and how data 
can be moved in the Sheet.
Complete the Excel formula:
1+1

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.
Difference between Structure and Union in C Program

In C we have container for both i.e. for same type data and multiple type data. For storage of data of same type C provides concept of Array which stores data variables of same type while for storing data of different type C has concept of structure and union that can store data variable of different type as well.
Since both Structure and Union can hold different type of data in them but now on the basis of internal implementation we can find several differences in both of these containers.
Following are the important differences between Structure and Union.
struct struct_name{
   type element1;
   type element2;
   .
   .
} variable1, variable2, ...;
union u_name{
   type element1;
   type element2;
   .
   .
} variable1, variable2, ...;
Checking if a double (or float) is NaN in C++

To check whether a floating point or double number is NaN (Not a Number) in C++, we can use the isnan() function. The isnan() function is present into the cmath library. This function is introduced in C++ version 11. So From C++11 next, we can use this function.
#include <cmath>
#include <iostream>
using namespace std;
main() {
   if(isnan(sqrt(30))) { //square root of 30 is a floating point number
      cout << "Square root of 30 is not a number" <<endl;
   } else {
      cout << "Square root of 30 is a number" <<endl;
   }
   if(isnan(sqrt(-30))) { //square root of -30 is an imaginary number
      cout << "Square root of -30 is not a number" <<endl;
   } else {
      cout << "Square root of -30 is a number" <<endl;
   }
}
Square root of 30 is a number
Square root of -30 is not a number
Equivalent to matlab's imagesc in Matplotlib

To make equivalent imagesc, we can use extent [left, right, bottom, top].
Create random data using numpy.
Display the data as an image, i.e., on a 2D regular raster, with data and extent [−1, 1, −1, 1]
arguments.
To display the figure, use show() method.
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
data = np.random.rand(4, 4)
plt.imshow(data, extent=[-1, 1, -1, 1])
plt.show()
Vector Projection using Python - GeeksforGeeks

29 Nov, 2019
A vector is a geometric object which has both magnitude (i.e. length) and direction. A vector is generally represented by a line segment with a certain direction connecting the initial point A and the terminal point B as shown in the figure below and is denoted by 
The projection of a vector  onto another vector  is given as
Computing vector projection onto another vector in Python:
# import numpy to perform operations on vectorimport numpy as np  u = np.array([1, 2, 3])   # vector uv = np.array([5, 6, 2])   # vector v:  # Task: Project vector u on vector v  # finding norm of the vector vv_norm = np.sqrt(sum(v**2))      # Apply the formula as mentioned above# for projecting a vector onto another vector# find dot product using np.dot()proj_of_u_on_v = (np.dot(u, v)/v_norm**2)*v  print("Projection of Vector u on Vector v is: ", proj_of_u_on_v)
Output:
Projection of Vector u on Vector v is:  [1.76923077 2.12307692 0.70769231]
One liner code for projecting a vector onto another vector:
(np.dot(u, v)/np.dot(v, v))*v
The projection of a vector  onto a plane is calculated by subtracting the component of  which is orthogonal to the plane from .where,  is the plane normal vector.
Computing vector projection onto a Plane in Python:
# import numpy to perform operations on vectorimport numpy as np  # vector u u = np.array([2, 5, 8])         # vector n: n is orthogonal vector to Plane Pn = np.array([1, 1, 7])          # Task: Project vector u on Plane P  # finding norm of the vector n n_norm = np.sqrt(sum(n**2))       # Apply the formula as mentioned above# for projecting a vector onto the orthogonal vector n# find dot product using np.dot()proj_of_u_on_n = (np.dot(u, n)/n_norm**2)*n  # subtract proj_of_u_on_n from u: # this is the projection of u on Plane Pprint("Projection of Vector u on Plane P is: ", u - proj_of_u_on_n)
Output:
Projection of Vector u on Plane P is:  [ 0.76470588  3.76470588 -0.64705882]
Machine Learning
Python
Machine Learning
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ML | Linear Regression
Decision Tree
Reinforcement learning
Decision Tree Introduction with example
Python | Decision tree implementation
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
How to get column names in Pandas dataframe
Python Dictionary
Taking input in Python
How can a String be validated (for alphabets) in java?

To validate a string for alphabets you can either compare each character in the String with the characters in the English alphabet (both cases) or, use regular expressions.
The following program accepts a string value (name) from the user and finds out whether given string is a proper name by comparing each character in it with the characters in the English alphabet.
 Live Demo
import java.util.Scanner;
public class ValidatingString {
   public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter your name: ");
      String str = sc.next();
      boolean flag = true;
      for (int i = 0; i < str.length(); i++) {
         char ch = str.charAt(i);
         if (!(ch >= 'a' && ch <= 'z'|| ch >= 'A' && ch <= 'Z')) {
            flag = false;
         }
      }
      if(flag)
         System.out.println("Given string is a proper name.");
      else
         System.out.println("Given string is a proper string is not a proper name.");
   }
}
Enter your name:
krishna45
Given string is a proper string is not a proper name.
Enter your name:
kasyap
Given string is a proper name.
The following program accepts a string value (name) from the user and finds out whether the given string is a proper name, using a regular expression.
 Live Demo
import java.util.Scanner;
public class ValidatingString2 {
   public static void main(String args[]) {
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter your name: ");
      String str = sc.next();
      if((!str.equals(null))&&str.matches("^[a-zA-Z]*$"))
         System.out.println("Given string is a proper name.");
      else
         System.out.println("Given string is a proper string is not a proper name.");
   }
}
Enter your name:
krishna45
Given string is a proper string is not a proper name.
Enter your name:
kasyap
Given string is a proper name.
How to get the position of the current frame in OpenCV using C++?

The current frame means that you are playing a video and the frame shown now is the current frame. It is also referred to as the active frame. In many application, you can require to get the number of the current frame.
The following program reads the position of the current frame and shows it in the console window.
#include<opencv2/opencv.hpp>//OpenCV header to use VideoCapture class//
#include<iostream>
using namespace std;
using namespace cv;
int main() {
   Mat myImage;//Declaring a matrix to load the frames//
   namedWindow("Video Player");//Declaring the video to show the video//
   VideoCapture cap("video.mp4");//Declaring an object to load video from device//  
   if(!cap.isOpened()){ //This section prompt an error message if no video stream is found//
      cout << "No video stream detected" << endl;
      system("pause");
      return-1;
   }
   while (true){ //Taking an everlasting loop to show the video//
      cap >> myImage;
      int current_Frame;//Declaring an integer variable to store the position of the current frame//
      current_Frame = cap.get(CAP_PROP_POS_FRAMES);//Reading the position of current frame//
      if (myImage.empty()){ //Breaking the loop if no video frame is detected//
         break;
      }
      cout << "Current Frame Number:" << current_Frame << endl;
      imshow("Video Player", myImage);//Showing the video//
      char c = (char)waitKey(25);//Allowing 25 milliseconds frame processing time and initiating break condition//
      if (c == 27){ //If 'Esc' is entered break the loop//
         break;
      }
   }
   cap.release();//Releasing the buffer memory//
   return 0;
}
This program will play the video and show the current frame's position in the console window.
Point Processing in Image Processing using Python-OpenCV

10 May, 2020
OpenCV is the huge open-source library for computer vision, machine learning, and image processing and now it plays a major role in real-time operation which is very important in today’s systems. By using it, one can process images and videos to identify objects, faces, or even the handwriting of a human.
All the processing done on the pixel values. Point processing operations take the form –
s = T ( r )
Here, T is referred to as a grey level transformation function or a point processing operation, s refers to the processed image pixel value and r refers to the original image pixel value.
Image Negative:
s = (L-1) – r, where L= number of grey levels
Thresholding:
s = L-1 for r > threshold
s = 0 for r < threshold
Grey level slicing with background:
s = L-1 for a < r < b,
here a and b define some specific range of grey level
s = r otherwise.
Below is the implementation.
Original Input Image :
import cv2import numpy as np     # Image negativeimg = cv2.imread('food.jpeg',0)   # To ascertain total numbers of # rows and columns of the image,# size of the imagem,n = img.shape   # To find the maximum grey level# value in the imageL = img.max()   # Maximum grey level value  minus # the original image gives the# negative imageimg_neg = L-img   # convert the np array img_neg to # a png imagecv2.imwrite('Cameraman_Negative.png', img_neg)   # Thresholding without background # Let threshold =T# Let pixel value in the original be denoted by r# Let pixel value in the new image be denoted by s# If r<T, s= 0# If r>T, s=255   T = 150  # create a array of zerosimg_thresh = np.zeros((m,n), dtype = int)    for i in range(m):          for j in range(n):                  if img[i,j] <  T:             img_thresh[i,j]= 0        else:            img_thresh[i,j] = 255      # Convert array to png imagecv2.imwrite('Cameraman_Thresh.png', img_thresh)   # the lower threshold valueT1 = 100  # the upper threshold valueT2 = 180   # create a array of zerosimg_thresh_back = np.zeros((m,n), dtype = int)   for i in range(m):          for j in range(n):                  if T1 < img[i,j] < T2:             img_thresh_back[i,j]= 255        else:            img_thresh_back[i,j] = img[i,j]  # Convert array to  png imagecv2.imwrite('Cameraman_Thresh_Back.png', img_thresh_back)
Output : Image Negative
Output : Image with Thresholding :
Output : Image with Grey Level Slicing with Background
Python-OpenCV
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Java Program for focal length of a spherical mirror

06 Dec, 2018
Focal length is the distance between the center of the mirror to the principal foci. In order to determine the focal length of a spherical mirror we should know the radius of curvature of that mirror. The distance from the vertex to the center of curvature is called radius of curvature.
The focal length is half the radius of curvature.Formula :
F =   ( R / 2 )      for concave mirror
F = - ( R / 2 )      for convex mirror
Examples :
For a convex mirror
Input : R = 30 
Output : F = 15


For a convex mirror
Input : R = 25
Output : F = - 12.5

// Java program to determine// the focal length of a// of a spherical mirrorimport java.util.*;import java.lang.*;  public class GfG{    // Determines focal length    // of a spherical concave    // mirror    public static float focal_length_concave(float R)    {        return R / 2 ;    }      // Determines focal length of a     // spherical convex mirror    public static float focal_length_convex(float R)    {        return - ( R / 2 ) ;    }          // Driver function    public static void main(String argc[])    {        float R = 30 ;                  System.out.print("Focal length of" +                         "spherical concave"+                         "mirror is : "+                         focal_length_concave(R) +                         " units\n");                                  System.out.println("Focal length of"+                           "spherical convex"+                            "mirror is : "+                           focal_length_convex(R) +                            " units");    }}  /* This code is contributed by Sagar Shukla */
Focal length ofspherical concavemirror is : 15.0 units
Focal length ofspherical convexmirror is : -15.0 units

Please refer complete article on Program to determine focal length of a spherical mirror for more details!
Java Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Iterate Over the Characters of a String in Java
How to Convert Char to String in Java?
How to Get Elements By Index from HashSet in Java?
Java Program to Write into a File
How to Write Data into Excel Sheet using Java?
Java Program to Read a File to String
Comparing two ArrayList In Java
SHA-1 Hash
Java Program to Convert File to a Byte Array
Java Program to Find Sum of Array Elements
Python | sep parameter in print()

21 Jan, 2021
The separator between the arguments to print() function in Python is space by default (softspace feature) , which can be modified and can be made to any character, integer or string as per our choice. The ‘sep’ parameter is used to achieve the same, it is found only in python 3.x or later. It is also used for formatting the output strings. 
Examples:
Python3
#code for disabling the softspace featureprint('G','F','G', sep='') #for formatting a dateprint('09','12','2016', sep='-') #another exampleprint('pratik','geeksforgeeks', sep='@')
Output:  
GFG
09-12-2016
pratik@geeksforgeeks
The sep parameter when used with the end parameter it produces awesome results. Some examples by combining the sep and end parameters. 
Python3
print('G','F', sep='', end='')print('G')#\n provides new line after printing the yearprint('09','12','2016', sep='-', end='\n') print('prtk','agarwal', sep='', end='@')print('geeksforgeeks')
Output:  
GFG
09-12-2016
prtkagarwal@geeksforgeeks
Note: Please change the language from Python to Python 3 in the online ide. Go to your interactive python ide by typing python in your cmd ( windows ) or terminal ( linux ) 
Python3
#import the below module and see what happensimport antigravity#NOTE - it wont work on online ide
This article is contributed by Pratik Agarwal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. 
AshisKumarSahu
rubicminer
kishan797
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Read JSON file using Python
Adding new column to existing DataFrame in Pandas
Python map() function
How to get column names in Pandas dataframe
Different ways to create Pandas Dataframe
Enumerate() in Python
Read a file line by line in Python
Python String | replace()
How to Install PIP on Windows ?
Iterate over a list in Python
Python MongoDB – find_one_and_replace Query

02 Sep, 2021
find_one_and_replace() method search one document if finds then replaces with the given second parameter in MongoDb. find_one_and_replace() method is differ from find_one_and_update() with the help of filter it replace the document rather than update the existing document. 
Syntax: find_one_and_replace(filter, replacement, projection=None, sort=None, return_document=ReturnDocument.BEFORE, session=None, **kwargs)Parameters filter: A query for replacement of a matched document. replacement: replacement document. projection: it is optional.A list of a field that should be returned in the result. sort: key, direction pair for the sort order of query. return_document: Return the original document without replacement. **kwargs: Additional commands.  
Sample database used in all the below examples: 
Example 1: 
Python3
import pymongo     # establishing connection# to the databaseclient = pymongo.MongoClient("mongodb://localhost:27017/")    # Database namedb = client["mydatabase"]    # Collection namecol = db["gfg"] # replace with the help of# find_one_and_replace()col.find_one_and_replace({'coursename':'SYSTEM DESIGN'},                         {'coursename': 'PHP'}) # print the document after replacementfor x in col.find({}, {"_id":0, "coursename": 1, "price": 1 }):    print(x)
Output:  
Example 2:  
Python3
import pymongo        # establishing connection# to the databaseclient = pymongo.MongoClient("mongodb://localhost:27017/")    # Database namedb = client["mydatabase"]    # Collection namecol = db["gfg"] # replace with the help of# find_one_and_replace()col.find_one_and_replace({'price':9999}, {'price':19999}) # print the document after replacementfor x in col.find({}, {"_id":0, "coursename": 1, "price": 1 }):    print(x)
Output:  
 
abhishek0719kadiyan
Python-mongoDB
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function