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...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
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...
Write a Python program that print out the list of couples of prime numbers that are...
Write a Python program that print out the list of couples of prime numbers that are less than 50, but their sum is bigger than 40. For instance(29,13)or(37,17),etc. Your program should print all couples
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:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT