Modulo Operator in Python

Level 113 keystrokes

This prints the remainder of 17 divided by 5, which is 2. The % operator calculates the modulo (remainder).

Python code

# % is the modulo operator: it gives the remainder of a division
# 17 ÷ 5 is 3 with remainder 2, so 2 is printed
1print(17 % 5)

Output

2
Practice typing this code

Practice typing this code. Results are not recorded in the rankings.

Symbols in this code

The symbols you type in this Python code and how often they appear.

  • (× 1
  • )× 1
  • %× 1

More Python examples at level 1

← Python typing practice