def Song(Drink, Container, Location): # This is a function that gives you a song with 100 verses. Drink = Drink.lower() # I added these ".lower", to ensure that if someone inserts the variables with capatilized letters, the song is still printed neatly Container = Container.lower() Location = Location.lower() Object_mv = Container + "s" + " of " + Drink # this creates a phrase with the drink in its container, in plural form Object_ev = Container + " of " + Drink # this creates a phrase with the drink in its container, in singular form Action = "Take one down, pass it around" # These 3 extra variables are added for the remainder of the text and for easy coding Empty_n = "No more" Restore = "Go to the store and buy some more" for n in range (99,-1,-1): # for every n from 99 to 0, going down with one each iteration, check if the following applies if n>2: # for every n that is bigger than 2, print the following print n, Object_mv, Location + ",\n", n, Object_mv + ".\n", Action + ",\n", n-1, Object_mv, Location + ".\n" # print the four lines of the verse, with plural containers, the third line deleting one container and in the last line one container less elif n==2: # for every n that is 2, print the following print n, Object_mv, Location + ",\n", n, Object_mv + ".\n", Action + ",\n", n-1, Object_ev, Location + ".\n" # print the four lines of the verse, with plural containers in the first 2 lines, the third line deleting one container and in the last line only one singular container elif n==1: # for every n that is 1, print the following print n, Object_ev, Location + ",\n", n, Object_ev + ".\n", Action + ",\n", Empty_n, Object_mv, Location + ".\n" # print the four lines of the verse, with singular containers in the first 2 lines, the third line deleting one container and in the last line no more containers else: # for every n is not bigger than 2, 2, or 1, print the following print Empty_n, Object_mv, Location + ",\n", Empty_n.lower(), Object_mv + ".\n", Restore + ",\n", "99", Object_mv, Location + ".\n" # print the four lines of the verse, with no more containers in the first 2 lines, the third line buying new containers and in the last line the starting amount of containers Song("beEr","botTle","on the wAll") # print the song so that Drink = beEr, Container = botTle and Location = on the wAll Song("winE","Bottle","in an airPlane") # print the song so that Drink = winE, Container = Bottle and Location = in an airPlane Drink = raw_input("What do you want to drink?") # Here, the user can specify Drink Container = raw_input("In what do you want your drink to be served?") # Here, the user can specify Container Location = raw_input("Where do you want to drink it?") # Here, the user can specify Location Song(Drink, Container, Location) # print the song so that Drink, Container and Location are as specified by the user
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question