# Program to show different types of for loops # Matt Bishop, May 4, 2009 # for ECS 10 Spring 2009 # this routine has a for loop with range(5) def forran1(): print "This is for i in range(3):" for i in range(3): print i # this routine has a for loop with range(-3,3) def forran2(): print "This is for i in range(-3,3):" for i in range(-3,3): print i # this routine has a for loop with range(-3, 3, 2) def forran3(): print "This is for i in range(-3, 3, 2):" for i in range(-3, 3, 2): print i # this routine has a for loop with range(3, -3, -2) def forran4(): print "This is for i in range(3, -3, -2):" for i in range(3, -3, -2): print i # this routine has a for loop with [ 1, 6, -2, 8 ] def forran5(): print "This is for i in [ 1, 6, -2, 8 ]:" for i in [ 1, 6, -2, 8 ]: print i # calling them all def main(): forran1() forran2() forran3() forran4() forran5() main()