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.

OperatorSymbolExampleDescription
Addition+x + yReturns the sum of x and y.
Subtraction-x - yReturns the subtraction of y from x.
Multiplication*x * yReturns the product of x and y.
Division/x / yReturns the quotient in the division of x by y.
Modulus%x % yReturns the remainder in the division of x by y.
Exponentiation**x ** yReturns the result of x raised to the power of y.
Floor Division//x // yReturns 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 Copy

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

Code copied to clipboard successfully 👍