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