Python Arithmetic Operators

Arithmetic Operators

Arithmetic Operators are used to perform arithmetic operations like addition, subtraction, multiplication, division, etc.

The following tables presents all the Arithmetic Operators available in Python, with respective operator symbol, description, and example.

Operator Symbol Example Description
Addition + x + y Returns the sum of x and y.
Subtraction - x - y Returns the subtraction of y from x.
Multiplication * x * y Returns the product of x and y.
Division / x / y Returns the quotient in the division of x by y.
Modulus % x % y Returns the remainder in the division of x by y.
Exponentiation ** x ** y Returns the result of x raised to the power of y.
Floor Division // x // y Returns the floor of the quotient in division of x by y.

Examples

In the following program, we take numeric values in x, y; and perform arithmetic operations.

Python Program

x = 5
y = 2

print(f'x + y  : {x + y}')
print(f'x - y  : {x - y}')
print(f'x * y  : {x * y}')
print(f'x / y  : {x / y}')
print(f'x % y  : {x % y}')
print(f'x ** y : {x ** y}')
print(f'x // y : {x // y}')
Run Code

Output

x + y  : 7
x - y  : 3
x * y  : 10
x / y  : 2.5
x % y  : 1
x ** y : 25
x // y : 2

Dedicated Tutorials for Arithmetic Operators

The following tutorials provide syntax, usage, and examples, for each of the Arithmetic Operators in detail.

Summary

In this tutorial of Python Examples, we learned about Arithmetic Operators, and how to use them in programs for operations like addition, subtraction, multiplication, etc.

Related Tutorials

Privacy Policy Terms of Use

SitemapContact Us