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
Which is a common problem caused by the widespread use of computers?
Andru [333]
Hacking would be a widespread problem.
8 0
4 years ago
When using the text command, what needs to be around the word or words you<br> want to appear?
AysviL [449]

Answer:

In most programming languages "" are required around text.

Explanation:

Python: print("text")

HTML: <p>text</p>

C++: int Main() {

cout << "text" << endl;

}

Lua: print("text")

8 0
3 years ago
You develop an app, and you don’t want anyone to resell it or modify it. This is an example of: A
Maru [420]

Answer:

C, proprietary software

Explanation:

Proprietary software, also known as non-free software, is computer software for which the software's publisher or another person reserves some rights from licensees to use, modify, share modifications, or share the software. It sometimes includes patent rights.

7 0
3 years ago
How do I mark someone brainiest
svet-max [94.6K]

Answer:

when someone answers your questio correctly, you will see a red crown. Click on that and mark them the most brainiest

Explanation:

3 0
2 years ago
Read 2 more answers
Big data are used to _____. Select 3 options.
jeka57 [31]

Answer:

AI, Interests, and marketing

Explanation:

Processing privacy policies is not a real function of a large data set.

8 0
3 years ago
Other questions:
  • A Color class has three int color component instance variables: red, green, and blue. Write a toString method for this class. It
    13·1 answer
  • Rewrite this method so that it avoids the use of a return statement:
    15·1 answer
  • What is the operating system?
    9·1 answer
  • How many possible keys does the playfair cipher have? an approximate power of 2
    14·1 answer
  • Suppose Alice, Bob, and Carol want to use secret key technology to authenticate each other. If they all used the same secret key
    10·1 answer
  • You can combine the algorithms for converting between infix to postfix and for evaluating postfix to evaluate an infix expressio
    13·1 answer
  • What does 69 mean?<br> Whenever I watch memes they always talk about the number 69
    8·2 answers
  • WAFL (write-anywhere file layout) Select one: a. is a distributed file system b. is a file system dedicated to single user opera
    6·1 answer
  • The steps.txt file contains the number of steps a person has taken each day for a year. There are 365 lines in the file, and eac
    12·1 answer
  • Megan owns a small neighborhood coffee shop, and she has fifteen employees who work as baristas. All of the employees have the s
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!