n1 = input("How many bottles are on the wall when you start? ") people = input("How many people are drinking with you? ") weight = input("How much do you weigh? ") n = n1 #bac is a function to calculate Blood Alcohal Level based on User Input. #I use n1-n to calculate the number of drinks that have been removed from #the wall. for n in range(n, 1, -1): def bac(n): drinks = ((n1 - n) * 1.0)/people weight_effect = weight/2000.0 adj_level = ((drinks * 4)/100) - weight_effect if adj_level < 0 : adj_level = 0 return adj_level #This is a modified chaos program which returns a value which is higher #the more the person has had to drink. However, it is chaotic, so there #can be a lot of variation. def chaos(n): l = 10*bac(n) r = n/100 xa = l * r * (1-r) r = r + .01 xb = l * r * (1-r) r = r + .02 xc = l * r * (1-r) x = ((xa + xb + xc)/3) - xa return int(100*x) #I use the output from the chaos function to slurr speach in phrase1, #add number to "n" in phrase2, and repeat lines in the verse. def phrase1(n): s =(chaos(n)+1) * "s" e = (2*chaos(n)+1) * "e" bottles = str(n) return bottles + " bottle" + s + " of be" + \ e + "r on the wall" def phrase2(n): n = str(n + chaos(n)) return n + " bottles of beer" def verse(n): return phrase1(n) + ", " + phrase2(n) + ".\n" \ + (chaos(n) +1) * "You take one down, \n" + "pass it around, \n" \ + phrase1(n-1) + "\n" if (10*bac(n)) > 4.0 : print "You drank way too much and died. Better luck next time." else: print verse(n)