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
5.2
Ray Of Light [21]

Answer:

In order to reduce the risk of accidents on the roads.

Explanation:

The special equipment is used when  testing eyesight for a driver's license in order to reduce the risk of accidents on the roads. Good eyesight is very important for good and safe driving so to find out the eyesight of the driver, the license officer used special equipment in order to check driver's eyes. If the eyesight is good, the officer provide license to the person otherwise not so that no accidents happen on the road.

8 0
2 years ago
Which of the following is an anxiety disorder
Tju [1.3M]

Answer:Conversion disorder

Explanation:Its a mental condition that affects the nervous system.

3 0
3 years ago
Read 2 more answers
Analyze the following code.
vazorg [7]

Answer:

The correct answer for the given question is "The program has a runtime NullPointerException because test is null while executing test.x"

Explanation:

In this code their is run time exception will occur in Main method i.e "java.lang.NullPointerException "because the object of the Test class i.e test will initialized by "null" .So on executing the statement test.x  it gives an Runtime Exception.The "NullPointerException" can occur if we assign the object to the "null" value that why it produce an java.lang.NullPointerException

8 0
3 years ago
Luentifying message rullidl Upuuns
WITCHER [35]

Answer:

Plain text, Rich Text, and HTML format

Explanation:

In Outlook 2016, three formats are allowed. You can send the plain text only or you can send using the Rich text format. However, there is another sending format as well that is allowed, and it is the HTML format. And by default, if you will let the Outlook choose the most appropriate sending format then the email message will be sent using the HTML format.

7 0
3 years ago
You recently started working part-time in a retail store, and are learning about the reading devices your store uses.Your store
slega [8]

Answer:

Laser beams.

Explanation:

Recently, that user has began functioning part-time in such a retail outlet, as well as he discovering regarding his shop's learning tools. During checkout, his shop requires the code scanner to scan objects.  

The barcode scanner uses laser beam technologies because the laser beam is rapidly running over the QR code or barcode back-and-forth, or executing the sequence. The sensors well into the system display the mirrored beam patterns that decrypts the barcode.

So, the following are the reason that describes the answer is correct according to the scenario.

5 0
3 years ago
Other questions:
  • What is the problem with assigning a port number to more than one server application?
    8·1 answer
  • Describe an ergonomic consideration for your body while working for long periods in front of a monitor or computer screen?
    14·1 answer
  • What connector has 4 pins, is used for older IDE drives and some SATA drives, and can provide +5 V and +12 V power outputs?
    11·1 answer
  • Why operating system is pivotal in teaching and learning
    10·1 answer
  • Important tools used in the _____ phase of the DMAIC process include a project charter, a description of customer requirements,
    10·1 answer
  • Which search engine do you prefer? Why
    15·2 answers
  • Which of these statements regarding mobile games is true?
    15·2 answers
  • c) If you are at foreign country visit, which banking card would you prefer to keep with you during visit (Debit Card or Credit
    10·1 answer
  • What is a word processing program? Give examples of word processing programs.
    10·1 answer
  • Which of the following uses the proper syntax for creating an HTML comment?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!