Skip to content

Lesson 12: Modulo

Nolen Felten edited this page Feb 23, 2016 · 1 revision

Our final operator is modulo. Modulo returns the remainder from a division. So, if you type 3 % 2, it will return 1, because 2 goes into 3 evenly once, with 1 left over.

Use modulo to set spam equal to 1. You can use any two numbers that will leave a remainder of 1 to do this.

#Set spam equal to 1 using modulo on line 3!

spam = 3 % 2

print spam
Clone this wiki locally