1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
shepuryov [24]
1 year ago
6

In your code editor, there is some code meant to output verses of the song "old macdonald had a farm. " when the code is working

properly, if the user types in pig for an animal (when prompted to "enter an animal: ") and oink for the sound (when prompted to "enter a sound: "), the program should output the following as it runs:.
Computers and Technology
1 answer:
iris [78.8K]1 year ago
5 0

Using the knowledge in computational language in python it is possible to write a code that  meant to output verses of the song "old macdonald had a farm.

<h3>Writting the code:</h3>

def main():

   # Make a list containing animals and sounds.

   #     Element n is the animal and n+1 is its sound.

   animals = ['cow', 'moo', 'chicken', 'cluck', 'dog', 'woof', 'horse', 'whinnie', 'goat', 'blaaah']

   # For each animal/sound pair

   for idx in range(0, len(animals), 2):

       # Call song(), passing the animal/sound pair as parameters.

       song(animals[idx], animals[idx+1])

       print()

# song():

#   animal and sound are arguments

def song(animal, sound):

   # Call firstLast() for first line of song

   firstLast()

   # Call middleThree() for middle three lines, passing animal and sound

   middleThree(animal, sound)

   # Call firstLast() for last line of song

   firstLast()

# firstLast():

def firstLast():

   # Print "Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!"

   print("Old MacDonald had a farm, Ee-igh, Ee-igh, Oh!")

# middleThree():

#   animal and sound are arguments

def middleThree(animal, sound):

   # Print middle three lines of song with passed animal and sound.

   print('And on that farm he had a {0}, Ee-igh, Ee-igh, Oh!'.format(animal))

   print('With a {0}, {0} here and a {0}, {0} there.'.format(sound))

   print('Here a {0}, there a {0}, everywhere a {0}, {0}.'.format(sound))

main()

See more about python at  brainly.com/question/18502436

#SPJ1

You might be interested in
when you enter a url, you’re creating a(n) ____ link, which is the full and complete address for the target document on the web.
RoseWind [281]

Answer:

Hope this helps it is called an absolute link.

6 0
3 years ago
Acceptance tests are normally conducted by the
dedylja [7]
The answer is D. System engineers
7 0
4 years ago
Read 2 more answers
Why might your coworker suggest encrypting an archive file before e-mailing it??
Genrish500 [490]
Because to prevent MITD (Man in the middle is a man that in the middle of the network. For example: You are sending a text, the man in the middle or in the modem will receive the text and can edit it and send it to the receiver, or the man will put the virus in...) and to prevent server snooping
8 0
3 years ago
In the 2007/2010 version of Paint, which of the following tools are located in the View tab? (Select all that apply.)
zaharov [31]
The answers are full screen and gridlines.
7 0
4 years ago
When powering up a home network, make sure all computers and peripherals are turned on before turning on the modem/router?
vazorg [7]
<span>the statement that when powering up a home network, make sure all computers and peripherals are turned on before turning on the modem/router is false.
The network devices like computers and other peripherals do not have to turned on before turning on the modem, they can be also later turned on.</span>
4 0
3 years ago
Other questions:
  • If you touch a downed power line covered or bare, what’s the likely outcome?
    10·2 answers
  • The Internet is a hierarchical structure linking different levels of service providers whose millions of devices supply all the
    13·1 answer
  • What is diffie-hellman most commonly used for?
    15·1 answer
  • Consider the following method:
    8·2 answers
  • Given an integer variable i and a floating-point variable f, write a statement that writes both of their values to standard outp
    12·1 answer
  • An isotope of an element has:
    11·2 answers
  • Of the three types of mutating malware, what type changes its internal code to one of a set number of predefined mutations whene
    9·1 answer
  • . Convert BAC4 from hexadecimal to decimal. Show your work.
    9·1 answer
  • True or False: VLANs in cloud computing are most likely to be found on direct connections with a CSP.
    9·1 answer
  • A classic game, Wario Land, has an invincible main character who reacts to the environment in order to solve puzzles. So, for ex
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!