Menu Close

Python Arithmetic Operators

In this article, you are going to learn Python Arithmetic Operators with the help of examples. If you are a Python developer, Then you can’t ignore operators in Python.

If you are going to perform arithmetic operations like addition, subtraction, multiplication, division, etc then Python arithmetic operators will be very helpful.

Before going through this article, please click here to read out Python operators tutorial were explained all about Python operators and their types.

Python Arithmetic Operators

Arithmetic operators in Python are used to perform arithmetic operations like addition, multiplication, subtraction, division, etc.

There are 7 types of arithmetic operators in Python.

  • Addition
  • Subtraction
  • Division
  • Multiplication
  • Modulus
  • Exponentiation
  • Floor division

Arithmetic operators in Python

OperatorNameExample
+Additionx + y
Subtractionx – y
*Multiplicationx * y
/Divisionx / y
%Remainderx % y

Addition Operator

Python addition operator ( + ) is used to add two or more values.

Example


value1 = int(input("Please enter the first value:- "))
value2 = int(input("Please enter the second value:- "))

result = value1 + value2
print("The result is:- ", result)

Output


Please enter the first value:- 12
Please enter the second value:- 30
The result is:-  42

Subtraction Operator

Python subtraction operator ( ) is used to add two or more values.

Example


value1 = int(input("Please enter the first value:- "))
value2 = int(input("Please enter the second value:- "))

result = value1 - value2
print("The result is:- ", result)

Output


Please enter the first value:- 120
Please enter the second value:- 30
The result is:-  90

Multiplication Operator

Python Multiplication operator ( * ) is used to multiply two or more values.

Example


value1 = int(input("Please enter the first value:- "))
value2 = int(input("Please enter the second value:- "))

result = value1 * value2
print("The result is:- ", result)

Output


Please enter the first value:- 120
Please enter the second value:- 30
The result is:-  3600

Division Operator

In Python, / is the division operator that is used to find the quotient when the first operand is divided by the second operand.

Example


value1 = int(input("Please enter  Thefirst value:- "))
value2 = int(input("Please enter the second value:- "))

result = value1 / value2
print("The result is:- ", result)

Output


Please enter the first value:- 1200
Please enter the second value:- 30
The result is:-  40

Modulus Operator

In Python, % is the modulus operator that is used to find the remainder when the first operand is divided by the second operand.

Example


value1 = int(input("Please enter  the first value:- "))
value2 = int(input("Please enter the second value:- "))

result = value1 % value2
print("The result is:- ", result)

Output


Please enter the first value:- 85
Please enter the second value:- 40
The result is:-  5

Exponentiation Operator

In Python, ** is a Exponentiation operator that is used to raise the first operand to the power of second.

Example


value1 = int(input("Please enter the first value:- "))
value2 = int(input("Please enter the second value:- "))

result = value1 % value2
print("The result is:- ", result)

Output



Please enter the first value:- 2
Please enter the second value:- 3
The result is:-  8

Floor Operator

In Python, // is the floor operator that is used to construct the floor division.it is used to find the floor of the quotient when the first operand divide by second operand.

Example


value1 = int(input("Please enter the first value:- "))
value2 = int(input("Please enter the second value:- "))

result = value1 % value2
print("The result is:- ", result)

Summary

So in this article, we have seen all about Python arithmetic operators with the help of the examples.
Arithmetic operators in Python are useful operators when you want to work with arithmetic operations.

If you like this article, please share and keep visiting for further Python tutorials.

For More Information:- Click Here

Previous Article
Next Article

Was this post helpful?

Related Posts