Skip to content

Operators

In Python, we use the below arithmetic operators.

arithmetic operators

Modulus %

The modulus operation finds the remainder after Euclidian division of one number by another.

Examples

10 % 4 = ?

10 / 4 = 2.5

2 * 4 = 8

108 = 2

10 % 4 = 2

27 % 16 = ?

27 / 16 = 1.6875

1 * 16 = 16

2716 = 11

27 % 16 = 11

Quotient

The quotient operation keeps only the truncated result of the division.

Examples

18 // 5 = ?

18 / 5 = 3.6

18 // 5 = 3

12 // 7 = ?

12 / 7 = 1.714

12 // 7 = 1

Exercise

In the interpreter, type the following and observe the results:

  • 4 + 17

  • 15 * 90 * 2

  • 2 * (3 + 4)

  • 1 + 18 / 4

  • 7 ** 3

  • 20 % 17

  • 20 // 17

  • 0.09 + 8.3

  • 7.004 - 9.004

  • 3.4 % 0.5

  • 3.4 // 0.5