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 addition operator. operator is used to add two numbers.

Example:

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

Output:

30

– operator:

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

Example:

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

Output:

10

* operator:

* is 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 integer.

Example:

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

Output:

3

% operator:

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

Example:

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

Output:

1

** operator:

** is a exponent operator.

Example:

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

Output:

1000

Conclusion:

From this articles you learned different arithmetic operators in python with example. 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

Leave a Reply

Your email address will not be published. Required fields are marked *