In: Computer Science
Using Python Programming
PROBLEM 3 - OLD MACDONALD: Write a program to print the lyrics
of the song ”Old MacDonald”. Your program should print the lyrics
using five different animals (i.e., cow, sheep, dog, cat ,turkey)
using the example verse below. For this problem you are required to
write then make use of a function getVerse that takes two string
parameters: (1) the name of an animal and (2) the sound that animal
makes. The function should not print anything if the name of the
animal is not one of the five above, or if there is a mismatch
between the animal and the sound. In your program, call your
function 5 times, passing each time to the function a different
combination of animal name and sound. The five different animals and
their associated sounds are the followings:
Animal Sound
cow moo
sheep baaa
dog woof
cat meow
turkey gobble gobble
Assumptions:
1) python version 2.x and above is used to execute the code
2) As it is not very clear on how the input would be provided to the function , thus I have declared an default list with 5 sets of inputs which can be changed if required to test against some other data set.
3) sys module is available in the python version that you chose to use
CODE: