Question

In: Computer Science

Write a program, using functions, to print the lyrics of the song “Old MacDonald.” Your program...

Write a program, using functions, to print the lyrics of the song “Old MacDonald.” Your program should print the lyrics for five different animals, similar to the example 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! Include a function that returns multiple values

in python :)

Solutions

Expert Solution

def song(animals, sounds):
result = []
for i in range(len(animals)):
line = '''Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!
And on that farm he had a ''' + animals[i] + ''', Ee-igh, Ee-igh, Oh!
With a ''' + sounds[i] + ''', ''' + sounds[i] + ''' here and a ''' + sounds[i] + ''', ''' + sounds[i] + ''' there.
Here a ''' + sounds[i] + ''', there a ''' + sounds[i] + ''', everywhere a ''' + sounds[i] + ''', ''' + sounds[i] + '''.
Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!\n'''
result.append(line)
return result

result = song(["cow", "dog", "cat", "bee", "duck"], ["moo", "bow", "meow", "buzz", "quack"])
for one in result:
print(one)


Related Solutions

Using Python Programming PROBLEM 3 - OLD MACDONALD: Write a program to print the lyrics of...
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...
❐Part 1: SingASong Print “Old MacDonald Had a Farm” Lyrics using a function. To the function,...
❐Part 1: SingASong Print “Old MacDonald Had a Farm” Lyrics using a function. To the function, you pass the name of animal and the sound as parameters. Document your code carefully. Your program output must be identical to the sample output. OUTPUT OF SAMPLE RUN FOR PART 1 Old MacDonald had a farm Ee i ee i o And on his farm he had some cows Ee i ee i oh With a moo-moo here And a moo-moo there Here...
Find a popular song and examine its lyrics using the pentad. What elements do the lyrics...
Find a popular song and examine its lyrics using the pentad. What elements do the lyrics emphasize? What is the dominant ratio? What does that say about the songwriter's motivation?
Find a popular song and examine its lyrics using the pentad. What elements do the lyrics...
Find a popular song and examine its lyrics using the pentad. What elements do the lyrics emphasize? What is the dominant ratio? What does that say about the songwriter's motivation?
Write a C++ Program to print the first letter of your first and last name using...
Write a C++ Program to print the first letter of your first and last name using stars. Note: 1) Using nested For Loop 2) The number of lines is given by user. 3) Using one Outer loop to print your letters. 4) Print the letters beside each other.
Write a C++ Program to print the first letter of your first and last name using...
Write a C++ Program to print the first letter of your first and last name using stars. Note: 1) Using nested For Loop 2) The number of lines is given by user. 3) Using one Outer loop to print your letters. 4) Print the letters beside each other
Using lyrics from a Taylor Swift song, identify 3 self leadership concepts we have studied this...
Using lyrics from a Taylor Swift song, identify 3 self leadership concepts we have studied this semester that she addresses in her songs. Analyze the lyrics and explain the message of self leadership that they convey. Identify two characteristics that identify her as a self leader. Support your choices. What two lessons can you learn from Taylor Swift that you can employ in your own life and/or career? write about 350 words
Write a Java program that implements a song database. The SongsDatabase class keeps tracks of song...
Write a Java program that implements a song database. The SongsDatabase class keeps tracks of song titles by classifying them according to genre (e.g., Pop, Rock, etc.). The class uses a HashMap to map a genre with a set of songs that belong to such a genre. The set of songs will be represented using a HashSet. Your driver output should sufficiently prove that your code properly implements the code below. public class SongsDatabase { private Map<String, Set<String>> genreMap =...
Using the IntelliJ IDEA tool, write a program that will print a Christmas tree with the...
Using the IntelliJ IDEA tool, write a program that will print a Christmas tree with the "*". The tree should have at least 10 lines. Look back at the birthday cake lab for examples of how to do this lab. Submit a screen shot of your output in the console (i.e. non REPL tool).
In java coding, write a program that will print out a representation of a “W” using...
In java coding, write a program that will print out a representation of a “W” using a character that a user provides.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT