Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In python 3 i need the following script updated script 1: import old_mcdonald de

ID: 3849638 • Letter: I

Question

In python 3 i need the following script updated

script 1:

import old_mcdonald

def main():

old_mcdonald.title()

old_mcdonald.verse('chicken', 'cluck')
old_mcdonald.verse('cow', 'moo')
old_mcdonald.verse('duck', 'quack')

  
while old_mcdonald.query_verse():
option = input('Do you want to have a fifth verse (yes/no)? ')
#if the option is yes
if option != 'no':
name = input('Enter an animal: ')
#check if the name is blank
if name == '':
print('The animal cannot be blank')
#check if the name is already present
elif name == 'cow' or name == 'chicken' or name == 'duck':
print('The animal is already been used')
else:
#to enter sound
sound = input('Enter the sound the it makes: ')
print(' ')
old_mcdonald.verse(name, sound)
else:
break

#when all the operations are over
print('Thanks for singing with me.')

# run the program
main()

script 2

def title():
print('Old McDonald')
print(' ')
pass

def verse(name, sound):
print('Old McDonald had a farm, E-I-E-I-O.')
print('And on that farm he had a ' + name + ', E-I-E-I-O.')
print('With a ' + sound + '-' + sound + ' here, and a ' + sound + '-' + sound +' there.')
print('Here a ' + sound + ', there a ' + sound + ', everywhere a ' + sound + '-' + sound + '.')
print('With a cluck-cluck here, and a cluck-cluck there.')
print('Here a cluck, there a cluck, everywhere a cluck-cluck.')
print('Old McDonald had a farm, E-I-E-I-O. ')
pass

def query_verse():
return True

I need the output to be cumalitive and to not allow blank input on yes/no. Right now when i get to the 5th verse, it does not call the other sounds that were already played, i need those in other verse in the 5th, 6th and so on. I also need help getting the good bye message to work.

I need the output to look like this

Old McDonald

Old McDonald had a farm, E-I-E-I-O.
And on that farm he had a chicken, E-I-E-I-O.
With a cluck-cluck here, and a cluck-cluck there.
Here a cluck, there a cluck, everywhere a cluck-cluck.
Old McDonald had a farm, E-I-E-I-O.

Old McDonald had a farm, E-I-E-I-O.
And on that farm he had a cow, E-I-E-I-O.
With a moo-moo here, and a moo-moo there.
Here a moo, there a moo, everywhere a moo-moo.
With a cluck-cluck here, and a cluck-cluck there.
Here a cluck, there a cluck, everywhere a cluck-cluck.
Old McDonald had a farm, E-I-E-I-O.

Old McDonald had a farm, E-I-E-I-O.
And on that farm he had a duck, E-I-E-I-O.
With a quack-quack here, and a quack-quack there.
Here a quack, there a quack, everywhere a quack-quack.
With a moo-moo here, and a moo-moo there.
Here a moo, there a moo, everywhere a moo-moo.
With a cluck-cluck here, and a cluck-cluck there.
Here a cluck, there a cluck, everywhere a cluck-cluck.
Old McDonald had a farm, E-I-E-I-O.

Enter an animal: cow
The animal cow is already been used.
Please try again. Enter an animal: turkey
Enter the sound the animal makes: gobble

Old McDonald had a farm, E-I-E-I-O.
And on that farm he had a turkey, E-I-E-I-O.
With a gobble-gobble here, and a gobble-gobble there.
Here a gobble, there a gobble, everywhere a gobble-gobble.
With a quack-quack here, and a quack-quack there.
Here a quack, there a quack, everywhere a quack-quack.
With a moo-moo here, and a moo-moo there.
Here a moo, there a moo, everywhere a moo-moo.
With a cluck-cluck here, and a cluck-cluck there.
Here a cluck, there a cluck, everywhere a cluck-cluck.
Old McDonald had a farm, E-I-E-I-O.

Enter an animal:
The animal cannot be blank.
Please try again. Enter an animal:
The animal cannot be blank.
Please try again. Enter an animal:
The animal cannot be blank.
Please try again. Enter an animal:
The animal cannot be blank.
Please try again. Enter an animal:
The animal cannot be blank.

Thanks for singing with me.

Explanation / Answer

I have done the tuning to your code as you want

and i have also added some suggestion to make it better in comments

Changes were only required in script 1 .

Script 2 is same , no change required

Script 1:

import old_mcdonald
def main():
   old_mcdonald.title()
   old_mcdonald.verse('chicken', 'cluck')
   old_mcdonald.verse('cow', 'moo')
   old_mcdonald.verse('duck', 'quack')
  
   #dictionary to hold the sounds that are used
   sounds = {'chicken':'cluck','cow':'moo','duck':'quack'}
   # names is a list containing name in order
   names = ['chicken','cow','duck']
  
   while old_mcdonald.query_verse():
       # You can replace below option with this
       #option = input('Do you want to have a {} verse (yes/no)? '.format(len(names))
      
       option = input('Do you want to have a fifth verse (yes/no)? ')
      
      
       #if the option is yes
       if option == 'yes':
           name = input('Enter an animal: ')
       #check if the name is blank
           if name == '':
               print('The animal cannot be blank')
           #check if the name is already present
           # improved your code for checking names
           # elif name == 'cow' or name == 'chicken' or name == 'duck':
           elif name in names:
               print('The animal is already been used')
           else:
           #to enter sound11
               sound = input('Enter the sound the it makes: ')
               sounds[name] = sound
               names.append(name)
               print(' ')
               for name in names:
                   old_mcdonald.verse(name, sounds[name])
       else:
           break
       #when all the operations are over
   print('Thanks for singing with me.')
# run the program
main()

PLEASE RATE!!!! THANKS

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote