Arithmetic operators in python

Arithmetic operators are used for mathematical computations. Arithmetic operators are used with numeric values like integers or float.
Following are the Arithmetic operators in python:

  1. + (Addition) operator
  2. – (Subtraction) operator
  3. * (Multiplication) operator
  4. / (Division) operator
  5. // (Floor Division) operator
  6. % (Modulus) operator
  7. ** (Exponent) operator

+ operator:

+ is an addition operator. This operator is used to add two numbers.

Example:

num1 = 10
num2 = 20
total = num1 + num2
print(total)

Output:

30

– operator:

-is a subtraction operator. This operator is used for subtracting two numbers.

Example:

num1 = 10
num2 = 20
total = num2 - num1
print(total)

Output:

10

* operator:

* is the multiplication operator. * operator is used for multiplication.

Example:

num1 = 10
num2 = 20
total = num1 * num2
print(total)

Output:

200

/ operator:

/ is a division operator. / is used for division. It returns result in float.

Example:

num1 = 10
num2 = 20
total = num2 / num1
print(total)

Output:

2.0

// operator:

// is a floor division operator. // is used for division. But this operator returns result in an integer.

Example:

num1 = 10
num2 = 3
total = num1 // num2
print(total)

Output:

3

% operator:

% is a modulus operator. % is a modulus operator which gives the remainder of the division.

Example:

num1 = 10
num2 = 3
total = num1 % num2
print(total)

Output:

1

** operator:

** is an exponent operator.

Example:

num1 = 10
num2 = 3
total = num1 ** num2
print(total)

Output:

1000

Conclusion:

From this article, you learned different arithmetic operators in python with examples. If you have problems while implementing code, you can ask me through the comment section.

See Also:

Logical operators in python

Comparison operators in python

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments