Computers and Technology

Write a program to print the lyrics of the song "Old MacDonald." Your program should print the lyrics for five different animals, similar to the verse below.

Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!

And on that farm he had a cow, Ee-igh, Ee-igh, Oh!

With a moo, moo here and a moo, moo there.

Here a moo, there a moo, everywhere a moo, moo.

Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!

You are going to create a function for each of the moving parts of this song:

(1) eieio,

(2) refrain (Old MacDonald had a farm),

(3) hada (And on that farm he had a),

(4) witha (make the sounds),

(5) verse.

You will then loop in the main function to read through a list of animals and their sounds.

1. Add comments at the top with file name: lab6_animal_YourLastName. py, your name, date, course section, etc.

2. Make sure to have the correct indentation for functions. Don’t copy/paste the following codes, which will cause format errors within Python. Just type them one by one carefully.

3. Create the main function:

def main():

for a, n in [("cow","moo"), ("pig", "oink"), ("horse", "nay"), ("sheep", "baa"), ("chicken", "cluck")]: #Note: This is all on one line

verse(a, n) print()

4. Create verse function.

def verse(animal, noise):

refrain()

hada(animal)

witha(noise)

refrain()

5. Create refrain function.

def refrain():

print("Old MacDonald had a farm," ,eieio())

6. Create eieio function:

def eieio():

return ("Ee-igh, Ee-igh, Oh!")

7. Create hada function:

def hada(animal):

print("And on that farm he had a", animal+",", eieio())

8. Create witha function:

def witha(noise):

noisecomma = noise + ","

noise2 = noisecomma + " "+noise

print("With a", noise2, "here and a", noise2, "there.")

print("Here a", noisecomma, "there a", noisecomma,

"\neverywhere a", noise2+".") #Note: This is all on one line

9. Don’t forget to call main function at the end of program:

main()

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 04:30, zetrenne73
How can you know if the person or organization providing the information has the credentials and knowledge to speak on this topic? one clue is the type of web site it is--the domain name ".org" tells you that this site is run by a nonprofit organization.
Answers: 2
image
Computers and Technology, 23.06.2019 18:50, annieleblanc2004
Ais a picture icon that is a direct link to a file or folder
Answers: 1
image
Computers and Technology, 23.06.2019 19:30, bevanscory123
What are loans to a company or government for a set amount of time
Answers: 1
image
Computers and Technology, 23.06.2019 22:00, bb1593
Jackson, who works in the finance department of a company, is holding a seminar for other employees on how to file taxes. only three employees sign up to attend the seminar. which device can he use to share his presentation with a group of three employees?
Answers: 1
Do you know the correct answer?
Write a program to print the lyrics of the song "Old MacDonald." Your program should print the lyric...

Questions in other subjects: