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
Help help how do you sleep
sveta [45]
You can try drinking herbal tea if you're having trouble sleeping.
3 0
4 years ago
Please help!
Nesterboy [21]
I think it the answer would be B but I'm not sure
4 0
4 years ago
Read 2 more answers
In best practice, should you use all lowercase, all uppercase or a mixture of cases in HTML tag names?
mixas84 [53]
B considering it’s proper english, we went through this about a week ago
7 0
2 years ago
How did music in the Renaissance differ from medieval music?
Damm [24]
Medieval music was in the time<span>of the middle ages. Renaissance music is the time for art and culture.
</span>
Medieval music refers to music written during the Middle Ages, around the time of 500AD - 1400. Little written music of this period survives, as making scores of music proved expensive, but most music of this time was monothonic or homorhythmic plainchant. Music from this period was generally modal and the begginings of counterpoint were seen in the form of organum. Renaissance music refers to the period from around 1400-1600, although there is some discrepancy in defining the begining of this period. Counterpoint became much more elaborate and it was over the duration of this period that composers began to leave the old modal music system in favour of tonality. Notable composers of this period <span>are Orlando Gibbons, John Bull, Thomas Tallis and William Byrd. </span>
7 0
3 years ago
Which of the following is a common feature of GUI's?
AnnyKZ [126]
I believe the correct answer is C. A pointing device. 
6 0
3 years ago
Other questions:
  • A technician is troubleshooting an employee laptop that has a wired network connectivity issue. The laptop can connect to the in
    14·1 answer
  • Practice with CSS. a. Write the CSS for an HTML selector footer with the following characteristics: a light-blue background colo
    11·1 answer
  • Each piece of evidence that is collected should be placed in a separate container true or false
    11·1 answer
  • Which statement describes part of the meeting scheduling process? It is always an all-day event. It is created in a single calen
    14·1 answer
  • Equity is proportional ownership in a firm. Which of the following is synonymous with Equity?
    14·1 answer
  • Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. End with a n
    7·2 answers
  • In order for a fault-block mountain to form, a ______ must take place along a fault line and one side must be ________.
    11·1 answer
  • I WILL GIVS BRAINLIEST IF U ANSWER THIS
    9·1 answer
  • Define a function isPrime that consumes an integer argument and returns 1 if it'a prime number; 0 if it's not a prime number.
    9·1 answer
  • What is the best description of a programming language?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!