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
Ites and days, on one of the slides in her school presentation. Which element can she use to
Lady_Fox [76]
<h2>Answer:</h2><h3>A text</h3><h3>or</h3><h3>C chart</h3>

8 0
3 years ago
Read 2 more answers
What do developers do to support software products? explain to users which development process model was used to make the produc
cestrela7 [59]

Answer:

The developer develops the user manuals to support their products. And agile development process is being used to make the user manual. The technical write this, but they first talk to developers, designers, project managers, team leaders etc. and collect all the information from them. And they start making them since start of the project. They use jira, git and various version control to update this document. And all the functionalities must be mentioned accurately, as well as latest of them to ensure reliability and credibility. Devops is another automated technology being used extensively these days.

Explanation:

The answer is self explanatory.

8 0
3 years ago
How many frequencies does a full-duplex qam-64 modem use?
Vsevolod [243]

The answer is 2 frequencies.

A Full-Duplex QAM 64 K Modem uses two frequencies. One frequency is used for upstream and the other for downstream. A variety of common QAM forms are available and include, 16 QAM, 32 QAM, 64 QAM, and 256 QAM. For example, for domestic broadcast use, 64 and 256 QAM are used for cable modem and digital cable TV. The modulation scheme for this modem uses both amplitude and phase.

8 0
4 years ago
Read 2 more answers
What is the purpose of interrupts? What is a trap? Can traps be generated intentionally by a user program? If so, for what purpo
SpyIntel [72]

Answer:

Interrupt (INT) helps operating system to stop work on one process and start work on other process using interrupt signals.

Explanation:

Purpose of interrupts:

• Interrupts are useful when an I/O device needs to be serviced only occasionally at low data transfer rate.

• For example, when a peripheral requires the attention of the processor to perform an I/ O operation.

A trap:

• also known as an exception or a fault, is typically a type of synchronous interrupt caused by an exceptional condition

• is a software-generated interrupt.

• For example it's caused by division by zero or invalid memory access.

Can traps be generated intentionally by a user program?  Yes.

If so, for what purpose?  

• the usual way to invoke a kernel routine (a system call) because those run with a higher priority than user code.  

• Handling is synchronous, so the user code is suspended and continues afterwards.

• In a sense they are active - most of the time, the code expects the trap.

3 0
4 years ago
What X coordinate does the center of a game begin at?
kotegsom [21]

A. 0

I am not entirely sure, I am not much of a coder(well I am but I don’t code often) so I hope this helps!

5 0
3 years ago
Other questions:
  • Building relationships during your career exploration is called
    9·2 answers
  • How do you access the dark web? What are the negatives of doing this?
    14·1 answer
  • Compare a Wi-Fi hotspot with a cybercafé.
    6·1 answer
  • GenXTech is a growing company that develops gaming applications for military simulations and commercial clients. As part of its
    8·1 answer
  • Write an SQL statement that uses all of the SQL built-in functions on the Quantity-OnHand column. Include meaningful column name
    14·1 answer
  • What does the action tool allow you to do in Microsoft power point?
    9·1 answer
  • Which step is first in changing the proofing language of an entire document?
    11·1 answer
  • Look at the following code:
    7·1 answer
  • Information systems include all of these
    5·1 answer
  • Explain the role that the number of data exchanges plays in the analysis of selection sort and bubble sort. What role, if any, d
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!