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
Default color html ​
Marrrta [24]

Answer:

black for font...

and

white for bg color

Explanation:

i think this is enough for ur question...

3 0
3 years ago
PL Technologies suffered considerable data loss when its database was infected by a virus. George, an operations personnel, atte
Luba_88 [7]

Answer:

Recovery is the correct answer to the given question.

Explanation:

Recovery is used when the data is lost from the database in any issue Database Recovery is giving the data to returning in its consistent state of the database.

When George sees that the  PL Technologies is suffered from considerable data loss due to it is infected by a virus then George retrieving the information and the data by using the recovery process  

6 0
3 years ago
What is pure substance ​
nlexa [21]

Answer:

i don't know

Explanation:

I don't understand

4 0
2 years ago
PLSSS HELP!! During the late 20th century, immigration to the United States increased dramatically from
AysviL [449]

Answer:

The correct answer is 3. Asia and Latin America.

Explanation:

America has historically been, and continues to be, one of the main arrival points for migrants from all regions of the world, mainly due to the security and political and economic stability that the United States offers its citizens. In recent years, the main regions that have sent immigrants to the United States have been Asia (Southeast Asian nations, such as Vietnam, the Philippines; authoritarian countries such as China or extremely poor such as India) and Latin America (especially Mexico, Honduras, El Salvador, Guatemala and Nicaragua).

8 0
3 years ago
The cpu stores the results of computations in ________.
alexira [117]

Answer:

Main memory

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • Netflix suggestions ?
    15·2 answers
  • Modern database tools support ________________, which entails separating data from the programs that manipulate data.
    14·1 answer
  • A rootkit is software and file folders that are hidden from view and permit viruses, spyware, and malware to be installed on a P
    10·1 answer
  • How can a user view the options for Junk E-mail?
    11·2 answers
  • Absolute time would be most similar to :
    9·1 answer
  • In which client/server relationship can a computer act as both a client AND a server? Select one: a. X-Windows b. SSH c. Classic
    8·1 answer
  • What tells the hardware what to do and how to do it?
    9·1 answer
  • Why hackers hack?? in other people?​
    8·2 answers
  • You have $5 and earn $1.75 for each roll of wrapping paper you sell. Write an equation in two variables that represents the tota
    12·1 answer
  • Alice and Bob are unknown to each other. Alice wants to send an encrypted message to Bob. So it chooses a KDC which is known to
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!