Question
: Decompose a song into functions This problem is broken into two pieces. In the first,you will define your algorithm - how you will solve
: Decompose a song into functions
This problem is broken into two pieces. In the first,you will define your algorithm - how you will solve this problemusing functions, using commenting. In the second piece you will addcode.
Requirement: The output of your program shouldmatch the format of the lyrics below.
Old McDonald Had a Farm. The lyricsare:
Old MacDonald had a farm, E-I-E-I-O
And on that farm he had a cow, E-I-E-I-O
With a moo-moo here and a moo-moo there
Here a moo
There a moo
Everywhere moo-moo
Old MacDonald had a farm, E-I-E-I-O
Old MacDonald had a farm, E-I-E-I-O
And on that farm he had a pig, E-I-E-I-O
With an oink-oink here and an oink-oink there
Here an oink
There an oink
Everywhere oink-oink
Old MacDonald had a farm, E-I-E-I-O
Old MacDonald had a farm, E-I-E-I-O
And on that farm he had a duck, E-I-E-I-O
With a quack-quack here and a quack-quack there
Here a quack
There a quack
Everywhere quack-quack
Old MacDonald had a farm, E-I-E-I-O
Old MacDonald had a farm, E-I-E-I-O
And on that farm he had a horse, E-I-E-I-O
With a neigh-neigh here and a neigh-neigh there
Here a neigh
There a neigh
Everywhere neigh-neigh
Old MacDonald had a farm, E-I-E-I-O
Old MacDonald had a farm, E-I-E-I-O
And on his farm he had a lamb, E-I-E-I-O
With a baa-baa here and a baa-baa there
Here a baa
There a baa
Everywhere a baa-baa
Old MacDonald had a farm, E-I-E-I-O
Task 1a: Decomposition
In this task you will analyze the lyrics above and propose analgorithm that prints out the lyrics using functions.
- There should be a main() function with one line of code whichcalls the function that "sings" the song.
- The function called by main() should reflect the structure inthe song, i.e. it should call other functions that represent eachstanza.
- Other functions may be created to minimize redundant code.
- Use descriptive function names. The name should communicatewhat that function does. Likewise, parameter names should also bedescriptive.
- Use single line comments that describe your proposed functioncalls. There should be NO code in thisversion, just comments.
Use the built-in Python documentation features fordocumenting each function. The documentationshould include an IPO section as well asany other explanatory comments you think are necessary.
Task 1b: Coding
Now that the hard part is done, it's time to code.
Preserve your work from 1a. During coding and testing you mayfind that your original ideas didn't work as well as you expected.You are free to refactor your approach as needed to get what youthink is a better result. If you do this, make sure to addcommenting explaining your changes and why you made them. The whyis especially important.
Output:
The output of your program should match the format of the lyricsabove.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Code def compilestanzaanimal sound The function takes in two parameters to use them in the lyrics su...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started