In Learn Python the Hard Way, students encounter modulo (modulus) in exercise 3. Most journalism students find it perplexing. So I thought they might understand it better if they could see it used as a test for prime numbers. See the full code here.
n = raw_input("Enter a number: ") for num in range(2, n):
# below, % is the modulus sign remainder = n % num
# below, % is used with d to represent a variable # called formatters, or format strings: %s %d %r print "%d / %d leaves a remainder of %d" % (n, num, remainder)
if remainder == 0: print "Sorry, %d is not a prime number." % n break