Modulo
noun
say it: “MOJ-uh-loh” /ˈmɑdʒəˌloʊ/
The % operator, which gives the remainder left over after dividing one whole number by another, such as 17 % 5 being 2.
What does the modulo operator do?
The modulo operator (%) gives the remainder left over after dividing. It answers questions like "is this number even?"
cookies = 17
kids = 5
print(cookies % kids) # 2 left over
print(10 % 2 == 0) # True: 10 is even
In a sentence
- “Modulo tells the bakery that 17 cookies shared by 5 kids leave 2 over.”
- “The program uses modulo to shade every other row of the table: a row number % 2 of 0 means even.”
Level: Novice · More Python terms at this level
Updated