import math def sqcube(): s = float(raw_input('enter length of one side: ')) print 'the area is:', s ** 2., '(units squared)' print 'the volume is:', s ** 3., '(cubic units)' def cirsph(): r = float(raw_input('enter length of radius: ')) print 'the area is:', math.pi * (r ** 2.), '(units squared)' print 'the volume is:', (4. / 3.) * math.pi * (r ** 3.), '(cubic units)' sqcube() cirsph()
11.
Modulus
for i in range(0, 22, 2): # range(0, 21, 2) okay too print i
or
for i in range(22): # range(21) okay too if i % 2 == 0: print i
for i in range(1, 20, 2): # range(1, 21, 2) okay too print i
or
for i in range(20): # range(21) okay too if i % 2 != 0: print i
When i % 2 == 0, it's even (divisible by 2), otherwise it's odd.