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
ASAP HELP
vovangra [49]

Answer:@the bottom slide

Explanation:wats ya email i

will help u

8 0
3 years ago
In order to identify the transmissions that belong to each VLAN, a switch will add a tag to Ethernet frames that identifies the
ira [324]

Answer:

True

Explanation:

Frame Tagging is a method Cisco developed to identify packets travelling through links also called VLAN Tagging.

8 0
3 years ago
Identify aspects of contemporary society that might lend themselves to a Commedia-type scenario or short play (ex: the British R
Helen [10]

Answer:

pls type clearly to understand i can't understand

4 0
3 years ago
How to do c++ programming
Kipish [7]

Answer:

Explanation:

learn by picking up courses and books

but if you don't have any prior programming experience, i recommend you DON'T do c++ first, but instead use an easier language to get the hang of it, like Python.

8 0
3 years ago
Mary is a student that's always been helpful to other students and plays her part when group assignment is given and ensures tha
Setler79 [48]

Explanation:

..................are there no options?

5 0
3 years ago
Read 2 more answers
Other questions:
  • IblMessage.txt=welcome to fiji.what is the error in the coding and what type of error is it?(explain)​
    5·1 answer
  • Binary code what does this mean I was sick so I don't under stand
    7·2 answers
  • How does the speaker feel about traditional forms of poetry
    14·2 answers
  • All of the following are advantages of database-stored information, except ______________. Multiple Choice
    7·1 answer
  • I like the impact that the increasing number of social grants may have on the things mothers​
    14·1 answer
  • Write the Stats method record that takes a test score and records that score in the database. If the score already exists in the
    15·1 answer
  • If Anyone can help me out that'll be great
    11·1 answer
  • In order to control access to a company's intranet and other internal networks, all communications pass through a _____ server.
    5·1 answer
  • What is the half of 3/18
    6·1 answer
  • You are given a list of N integers . find the largest sum of a continuous sequence from the given list
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!