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
Consider the following code:
ICE Princess25 [194]

Answer: 3

Explanation:

Because X = 18 and our condition given to the code if > and < which do not match with the input so it prints 3.

4 0
3 years ago
Which class of fire extinguisher is appropriate for a fire involving electrical/energized electrical equipment?
krok68 [10]
The answer would be a C class fire extinguisher. 
6 0
3 years ago
Read 2 more answers
Differences between windows xp and windows vista
krek1111 [17]
Well since Windows XP runs on Windows 2000 technology,it would be "slow".Also that Windows XP had MSN,which expired 15 years ago,but the good thing about Windows XP is that it can connect to the internet via WiFi without the computers hardware used for WiFi(PC only).Also that Windows XP has a logo on the start-up screen.Windows Vista on the other hand, doesn't have a logo on the start-up screen,but shows a Windows Vista animated logo atfer the start-up screen.Also that some people named Windows Vista "The first Windows 7".But somewhat,Windows Vista ran faster than Windows XP at starting up.Windows Vista was old,but it sold better than Windows XP.
6 0
3 years ago
Given the following method definitions: void mystery(double a) { System.out.print("double! "); } void mystery(int a) { System.ou
kicyunya [14]

Answer:

The correct answer to the following question is option "b".  

Explanation:

The method having the same name but the arguments have different so it is called method overloading. It is a part of the object-oriented programming language (oops).  

  • In the given code we define same method two times that is "mystery()". but in this method, we pass two different parameters. For the first time, we pass a double variable that is "a" as a parameter. In the second time, we pass an integer variable that is "a" as a parameter and in both functions, we write some codes.
  • In the calling time, we call function two times. In first time calling we pass an integer value that is "1" and second time calling we pass double value that is "1.0". So the output of this code is "int! double!".  

That's why the option "b" is correct.

6 0
3 years ago
Renee works for a television series. Her responsibility is to transfer data from the camera to a hard drive. What is her job des
Marysya12 [62]

Answer:

Data wrangler

Explanation:

Her responsibility is to transfer data from the camera to a hard drive. What is her job designation? Data Wrangler.

<h2>mark as brainliests </h2>
8 0
2 years ago
Other questions:
  • System uses a 6-bit 2’s complement signed integer representation. What is the range of decimal values it can represent?
    14·1 answer
  • A user can easily move to the end of a document by pressing the _____ key combination.
    10·2 answers
  • 1. What is the main factor that affects Earth’s average temperature?
    12·1 answer
  • [Java] Using the comparable interface
    13·1 answer
  • Which key must you press after you write into a cell?
    12·1 answer
  • The computer mouse are used for
    15·2 answers
  • True or False
    7·1 answer
  • A customer would like you to install a high-end video card suitable for gaming. Your installation and configuration SHOULD inclu
    7·1 answer
  • In science class, Patricia is giving a presentation on the different types of flowers in her community. As part of her presentat
    5·1 answer
  • Which phrase best describes a scenario in Excel 2016?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!