Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def title(): print(The name of the song: Old McDonald) print( ) def verse(animal, sound): print(Old McDonald had a farm, E-I-E-I-O. And on that farm he

def title(): print("The name of the song: \"Old McDonald\"") print(" ") def verse(animal, sound): print("Old McDonald had a farm, E-I-E-I-O. And on that farm he had a "+ animal+", E-I-E-I-O. With a "+ sound+"-"+sound+" here, and a "+ sound+"-"+sound+" there. Here a "+ sound+", there a "+ sound+", everywhere a "+ sound+"-"+ sound+". Old McDonald had a farm, E-I-E-I-O.") print(" ") def newVerse(): animal= input('Enter an animal: ') sound = input('Enter the sound the'+ animal +'makes: ') verse(animal, sound) print(" ") def main(): title() verse('chicken', 'cluck') verse('cow', 'moo') verse('duck', 'quack') newVerse() Q =input("Do you want to have a fifth verse (yes/no)?") if Q == "yes": newVerse() elif Q == "no": return else: newVerse()

main()

how do i update the code to be:

  • Complete all the work for the standard version.
  • Update the verse function to handle animal names or sounds that begin with a vowel. For the purposes of this assignment, there are exactly five vowels: A E I O U. Case does not matter. Also, we will not worry about the pronunciation, just the spelling. So, it would be "an unicorn" or "a honor" (Yes, I know "honor" is not an animal, but I can think of an animal whose name begins with a silent "h".) Examples:

    Old McDonald 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 an oink-oink. Old McDonald had a farm, E-I-E-I-O.

    Old McDonald had a farm, E-I-E-I-O. And on that farm he had an owl, E-I-E-I-O. With a who-who here, and a who-who there. Here a who, there a who, everywhere a who-who. Old McDonald had a farm, E-I-E-I-O.

  • Update the verse function by creating "helper" function that will remove code repetition. For example, the first line and the last line of the verse could be printed by the same "helper" function. A significant place to reduce code duplication is in the a/an logic since that must appear 6 times in the verse function otherwise.

Notes about the challenge version:

  • There shall be only one verse function. Notice that the write-up states that the verse function is updated. Submissions with multiple verse functions shall not get credit for the challenge options.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

4. What will the team agreement contain?

Answered: 1 week ago