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
lesantik [10]
3 years ago
12

Write a Python 3 program that prompts the user for 3 postive numbers (or zero) and then adds them together. If the user enters a

negative number, the program should reprompt them until they enter a postive number. Divide your program into two functions: prompt_number - Prompts for a number, and keeps re-prompting as long as it is negative. Then, returns the number. compute_sum - Accepts 3 numbers, adds them together and returns the sum. main - Calls the prompt_number function 3 times, saves the return value into three different variables, then passes those 3 variables to the compute_sum function. Finally, saves the result of compute_sum into a variable and displays it.
Computers and Technology
1 answer:
Citrus2011 [14]3 years ago
6 0

Answer:

def prompt_number():

   while True:

       number = int(input("Enter a number: "))

       if number >= 0:

           break

       

   return number

   

def compute_sum(n1, n2, n3):

   total = n1 + n2 + n3

   return total

   

n1 = prompt_number()

n2 = prompt_number()

n3 = prompt_number()

result = compute_sum(n1, n2, n3)

print(result)

Explanation:

Create a function named prompt_number that asks the user to enter a number until a positive number or 0 is entered and returns the number

Create a function named compute_sum that takes three numbers, sums them and returns the sum

Ask the user to enter three numbers, call the prompt_number() three times and assign the values

Calculate the the sum, call the compute_sum and pass the numbers as parameters

Print the result

You might be interested in
In some networks, the data link layer handles transmission errors by requesting that damaged frames be retransmitted. If the pro
Usimov [2.4K]

Answer:

The answer with explanation is attached in the file.

Explanation:

Download docx
3 0
4 years ago
_________ is a society organized with the purpose of rendering service to its members and to the public in general.
sesenic [268]

Answer:

cooperate society

Explanation:

A cooperative society is a voluntary association that started with the aim of the service of its members.

8 0
3 years ago
True or false, cloud storage does not require internet access?
Dmitry_Shevchenko [17]
False, the storage is being accessed from the cloud which can only be accessed through an internet connection.
3 0
4 years ago
Real numbers which, when squared, become smaller than the original number."
8_murik_8 [283]
Those would be numbers below 1.

Explanation:
.5•.5 = .25
-2•-2 = -4
Hope this helps!
Also consider giving me brainliest.
7 0
2 years ago
Tara is a recent computer science graduate. After completing a three-month internship at an IT firm, she decides to become a tes
KengaRu [80]

Answer:

Explanation:

A tester has to evaluate, test and find errors, in this job you have to provide all the analysis and improve the software.

A tester has to evaluate:

  • Interact with buttons
  • Enter data
  • design for multiple situations

A tester must have these abilities:

  • The ability to work calmly under pressure.
  • Organizational capacity .
  • Logical thinking.
  • Ability to plan future work.
  • Pay attention to the details.

7 0
3 years ago
Other questions:
  • You receive an offer for a credit card that can be use to accrue points that
    11·1 answer
  • Which best compares and contrasts visual and performing arts? Both careers use communication skills; however, people involved in
    15·2 answers
  • In the __________ Standard, chemical manufacturers, importers, and distributors are required to provide hazard information by wa
    12·2 answers
  • Which of the following statements is NOT true about a mainframe computer?
    14·1 answer
  • Write a script which: Uses the input function to get any number and store it in a variable named my_number Create a new variable
    8·1 answer
  • The set of rules for how computers talk to one another is called
    12·1 answer
  • What is the platform-neutral programming language that can run on Windows, Macintosh, or UNIX?
    15·1 answer
  • Which skill type refers to the knowledge and ability to perform a task?
    13·2 answers
  • 12. Why is it so important to pay attention to your digital reputation?
    14·1 answer
  • Select the three subjects studied in sports biomechanics.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!