Question

In: Computer Science

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

Solutions

Expert Solution

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:


Related Solutions

❐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...
Beginning Python Programming - Sorting: Write and test a Python program to print a set of...
Beginning Python Programming - Sorting: Write and test a Python program to print a set of real numbers in descending order. The program should also print out the median of the numbers input and how many numbers were input. The program should read in numbers until a negative number is read. The negative number serves as a sentinel or marker telling the program when to stop reading numbers. The program should then sort the numbers and print them out in...
MUST BE PYTHON 3 Instructions: The following programming problem can be solved by a program that...
MUST BE PYTHON 3 Instructions: The following programming problem can be solved by a program that performs three basic tasks (Input Data, Process Data, Output Results) along with selection and repetition coding techniques. Problem Statement A finance company provides loans for motorcycles at different rates depending on how much the total loan amount is and how many payments will be made on the loan. Using the information in the table below, write a program that will calculate the monthly payment...
using python 3 2. Write a python program that finds the numbers that are divisible by...
using python 3 2. Write a python program that finds the numbers that are divisible by both 2 and 7 but not 70, or that are divisible by 57 between 1 and 1000. 3. Write a function called YesNo that receives as input each of the numbers between 1 and 1000 and returns True if the number is divisible by both 2 and 7 but not 70, or it is divisible by 57. Otherwise it returns False. 4. In your...
using python 3 2. Write a python program that finds the numbers that are divisible by...
using python 3 2. Write a python program that finds the numbers that are divisible by both 2 and 7 but not 70, or that are divisible by 57 between 1 and 1000. 3. Write a function called YesNo that receives as input each of the numbers between 1 and 1000 and returns True if the number is divisible by both 2 and 7 but not 70, or it is divisible by 57. Otherwise it returns False. 4. In your...
Python Problem Problem 1: In this problem you are asked to write a Python program to...
Python Problem Problem 1: In this problem you are asked to write a Python program to find the greatest and smallest elements in the list. The user gives the size of the list and its elements (positive and negative integers) as the input. Sample Output: Enter size of the list: 7 Enter element: 2 Enter element: 3 Enter element: 4 Enter element: 6 Enter element: 8 Enter element: 10 Enter element: 12 Greatest element in the list is: 12 Smallest...
This is an exercise to design and write a Python program in good programming style for...
This is an exercise to design and write a Python program in good programming style for a simulation of stock price over a period of 100 days. In this exercise, you are asked to simulate the stock price starting at $100.00 for 100 days with a daily fluctuation based on the Normal Distribution with mean = 0.0 & sigma = 0.0125. The program will show the daily stock price, the 7-day minimum, the 7-day maximum, the 7-day average, and the...
Write a Python program in a file called consonants.py, to solve the following problem using a...
Write a Python program in a file called consonants.py, to solve the following problem using a nested loop. For each input word, replace each consonant in the word with a question mark (?). Your program should print the original word and a count of the number of consonants replaced. Assume that the number of words to be processed is not known, hence a sentinel value (maybe "zzz") should be used. Sample input/output: Please enter a word or zzz to quit:...
***This program is to be created using Python*** Requirements to be numbered in program01.py: Print “This...
***This program is to be created using Python*** Requirements to be numbered in program01.py: Print “This program provides concert seat assignments.” Ask the user their musical preference and take the following actions based on their potential input: Classical – proceed with the program (i.e. move the next requirement) – output a message that states “We do not recognize the musical genre.” Then end the program. Ask the user to enter the following data about themselves: • First Name • Last...
Programming Python Jupiter notebook Write a Python program that gets a numeric grade (on a scale...
Programming Python Jupiter notebook Write a Python program that gets a numeric grade (on a scale of 0-100) from the user and convert it to a letter grade based on the following table. The program should be written so that if the user entered either a non-numeric input or a numeric input out of the 0-100 range, it asks him/her to enter a numeric input in the correct range, instead of returning an error. Example: Enter your score: 78 Letter...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT