subject

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()

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 13:00
Which option should u select to ignore all tracked changes in a document
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
Creating "smart interfaces" in all sectors of industry, government, and the public arena is one of the fastest growing hct areas. these interfaces model, interpret, and analyze such human characteristics as speech, gesture, and vision. the field of biometrics, in which humans authenticate themselves to machines, is an area of considerable interest to hct practitioners. fingerprint scans are one of the most frequently used biometric options, and this article, biometric student identification: practical solutions for accountability & security in schools, makes a case for the implementation of fingerprint scans in schools. critique the article, and answer the following questions: according to the author, what are the main benefits of adopting fingerprint scans in schools for student identification? according to the author, what are the main drawbacks of adopting fingerprint scans in schools for student identification? do you agree with the author's assessment of the pl
Answers: 2
question
Computers and Technology, 23.06.2019 01:30
How do you set up a slide show to play continuously, advancing through all the slides without requiring your interaction? a. click set up slide show, and then select the loop continuously until ‘esc' and show without narration options. b. click set up slide show, and then select the loop continuously until ‘esc' and use timings, if present options. c. click set up slide show, and then select the show presenter view and use timings, if present options. d. click set up slide show, and then select the show without animation and browsed at a kiosk (full screen) options.
Answers: 3
question
Computers and Technology, 23.06.2019 19:30
What are loans to a company or government for a set amount of time
Answers: 1
You know the right answer?
Write a program to print the lyrics of the song "Old MacDonald." Your program should print the lyric...
Questions
question
Chemistry, 06.05.2021 01:00
question
Mathematics, 06.05.2021 01:00
question
Mathematics, 06.05.2021 01:00
question
Mathematics, 06.05.2021 01:00
question
Mathematics, 06.05.2021 01:00
question
Mathematics, 06.05.2021 01:00
Questions on the website: 13722361