In Class Code 3-26-15
#def main():
#sayHello()
# temp()
#def temp():
# print(“Sure is hot in here”)
#def sayHello():
# print(“Hello class!”)
#Old MacDonald Game
def main():
animals = [“cow”, “chicken”, “pig”, “horse”]
sounds = [“moo, moo”, “cluck, cluck”, “oink, oink”, “neigh, neigh”]
num = 0
while num >= 0:
begining()
usrAnimal = input(“And on that farm he had a: cow, chicken, pig, horse, end”)
num = animal(usrAnimal)
if num == -1:
break
elif num == -2:
print(“Sorry Old MacDonald didn’t have that animal.”)
continue
print(“With a”, sounds[num], ” here and a “, sounds[num], ” there!”)
ending()
def animal(usrAnimal):
if usrAnimal == “cow”:
num = 0
elif usrAnimal == “chicken”:
num = 1
elif usrAnimal == “pig”:
num = 2
elif usrAnimal == “horse”:
num = 3
elif usrAnimal == “end”:
num = -1
else:
num = -2
return num
def begining():
print(“\nOld MacDonald had a farm”)
print(“E I E I O”)
def ending():
print(“E I E I O”)
main()