 # Python Arithmetic Operators

## Python Arithmetic Operators

Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication and division.

There are 7 arithmetic operators in Python :

2. Subtraction
3. Multiplication
4. Division
5. Modulus
6. Exponentiation
7. Floor division

1. Addition Operator : In Python, + is the addition operator. It is used to add 2 values.
Example :

 `val1 ``=` `2` `val2 ``=` `3` ` ` `# using the addition operator` `res ``=` `val1 ``+` `val2` `print``(res)`

Output :

`5`

2. Subtraction Operator : In Python,  is the subtraction operator. It is used to subtract the second value from the first value.
Example :

 `val1 ``=` `2` `val2 ``=` `3` ` ` `# using the subtraction operator` `res ``=` `val1 ``-` `val2` `print``(res)`

Output :

`-1`

3. Multiplication Operator : In Python, * is the multiplication operator. It is used to find the product of 2 values.
Example :

 `val1 ``=` `2` `val2 ``=` `3` ` ` `# using the multiplication operator` `res ``=` `val1 ``*` `val2` `print``(res)`

Output :

`6`

4. Division Operator : In Python, / is the division operator. It is used to find the quotient when first operand is divided by the second.
Example :

 `val1 ``=` `3` `val2 ``=` `2` ` ` `# using the division operator` `res ``=` `val1 ``/` `val2` `print``(res)`

Output :

`1.5`

5. Modulus Operator : In Python, % is the modulus operator. It is used to find the remainder when first operand is divided by the second.
Example :

 `val1 ``=` `3` `val2 ``=` `2` ` ` `# using the modulus operator` `res ``=` `val1 ``%` `val2` `print``(res)`

Output :

`1`

6. Exponentiation Operator : In Python, ** is the exponentiation operator. It is used to raise the first operand to power of second.
Example :

 `val1 ``=` `2` `val2 ``=` `3` ` ` `# using the exponentiation operator` `res ``=` `val1 ``*``*` `val2` `print``(res)`

Output :

`8`

7. Floor division : In Python, // is used to conduct the floor division. It is used to find the floorof the quotient when first operand is divided by the second.
Example :

 `val1 ``=` `3` `val2 ``=` `2` ` ` `# using the floor division` `res ``=` `val1 ``/``/` `val2` `print``(res)`

Output :

`1`

Below is the summary of all the 7 operators :

Operator Description Syntax
Subtraction: subtracts two operands x – y
* Multiplication: multiplies two operands x * y
/ Division (float): divides the first operand by the second x / y
// Division (floor): divides the first operand by the second x // y
% Modulus: returns the remainder when first operand is divided by the second x % y
** Power : Returns first raised to power second x ** y

Last Updated on December 29, 2021 by admin

## How to get column names in Pandas dataframeHow to get column names in Pandas dataframe

While analyzing the real datasets which are often very huge in size, we might need

## How to pass multiple arguments to function ?How to pass multiple arguments to function ?

How to pass multiple arguments to function ? A Routine is a named group of instructions performing

## Python – Pandas DataFrame.transposePython – Pandas DataFrame.transpose

Pandas DataFrame.transpose Pandas DataFrame.transpose() function transpose index and columns of the dataframe. It reflect the

## Different ways to clear a list in PythonDifferent ways to clear a list in Python

Different ways to clear a list in Python   There are many ways of clearing

## Create empty dataframe in PandasCreate empty dataframe in Pandas

The Pandas Dataframe is a structure that has data in the 2D format and labels

## Numpy size() function | PythonNumpy size() function | Python

Numpy size() function | Python In Python, numpy.size() function count the number of elements along

## Python – after method in TkinterPython – after method in Tkinter

Python | after method in Tkinter Tkinter provides a variety of built-in functions develop interactive

## Python DocstringsPython Docstrings

Python Docstrings Python documentation strings (or docstrings) provide a convenient way of associating documentation with