[Courses] [python] Lesson 2: Loops, if, and beer

Donald Russell russell.donaldrussell at gmail.com
Tue Jun 28 15:53:54 UTC 2011


1.

for i in range(100, 0, -1) :
    print ""
    print i, "bottles of beer on the wall",i,"bottles of beer."
    print "Take one down, pass it around."
    print i-1,"bottles of beer."
print ""
print "No more bottles of beer on the wall, no more bottles of beer."
print "Go to the store and buy some more, 99 bottles of beer on the wall."
 2.

[]    The first number in the expression has to be larger than the
second otherwise subtracting 1 results in a value ouside the range?

3.

length of lesson is just about perfect for me

4.

for i in range(1, 6) :
    if i == 1 :
        print "one"
    elif i == 2 :
        print "two"
    elif i == 3 :
        print "three"
    elif i == 4 :
        print "four"
    elif i == 5 :
        print "five"


-- 
Donald Russell


More information about the Courses mailing list