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
12. When computer professionals take on jobs, they may not enter into relationships with which of the
weeeeeb [17]

Answer:

12 is c. 13 is a .14 is c 15 I don't know sorry

6 0
3 years ago
In this lab, you use what you have learned about searching an array to find an exact match to complete a partially prewritten C
icang [17]

Answer:

Complete the program as follows:

for(int i = 0; i<10; i++){

     if(inCity == citiesInMichigan[i]){

         foundIt = true;

         break;       }    }

   if(foundIt){         cout<<"It is a city";     }

   else{         cout<<"Not a city";     }

Explanation:

Required

Complete the pre-written code in C++ (as indicated by the file name)

The pre-written code; though missing in this question, can be found online.

The explanation of the added lines of code is as follows:

This iterates through the array

for(int i = 0; i<10; i++){

This checks if the city exists in the array

     if(inCity == citiesInMichigan[i]){

If yes, foundIt is updated to true

         foundIt = true;

And the loop is exited

         break;       }    } -- The loop ends here

If foundIt is true, print it is a city

<em>    if(foundIt){         cout<<"It is a city";     }</em>

Print not a city, if otherwise

<em>    else{         cout<<"Not a city";     }</em>

8 0
3 years ago
Marsha receive an email saying that she won a free cruise to Alaska. What Marsha didn’t realize is that the email was fake and c
Gre4nikov [31]

Answer:

I think the answer is B

Explanation:She sent it to her friends not knowing it would give there computers a virus too.

4 0
3 years ago
Read 2 more answers
Cognizant's organizational structure was ________, but realized as its organization grew and its services became more complicate
Nookie1986 [14]

Answer:

D

Explanation:

hierarchical, matrix

3 0
3 years ago
Suppose that you write a subclass of Insect named Ant. You add a new method named doSomething to the Ant class. You write a clie
bearhunter [10]

Answer:

5) I and III only

Explanation:

From the declarations listed both declarations I and III will not permit calling the doSomething() method. This is because in declaration I you are creating a superclass variable but initializing the subclass. In declaration III you are doing the opposite, which would work in Java but only if you cast the subclass to the superclass that you are initializing the variable with. Therefore, in these options the only viable one that will work without error will be II.

7 0
3 years ago
Other questions:
  • _____ is a function performed by control programs that manages computer resources, such as storage and memory.
    11·1 answer
  • The Boffo Balloon Company makes helium balloons. Large balloons cost $13.00 a dozen, medium-sized balloons cost $11.00 a dozen,
    13·1 answer
  • Many people object to increased cybersecurity because _____.
    12·2 answers
  • The use of multiple _______ is sometimes called using a search phrase.
    15·1 answer
  • If my_string = "This is MY string!", why does print (my_string[0:7:5]) return "Ti" and not
    11·1 answer
  • With that ------ outlook he doesn't trust anyone.
    11·1 answer
  • Which of these parts of a computer produces an observable result?
    11·2 answers
  • What starts with p and ends with orn
    15·2 answers
  • Question 3 of 10
    14·1 answer
  • How can interference benefit a quantum system?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!