Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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. Dont 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,

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

9. Dont forget to call main function at the end of program:

main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions