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]
2 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]2 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
Net Worth is equal to assets minus liabilities. Which event will have the greatest impact (positive or negative) on one's net wo
kolezko [41]
The answer would be: Go on a vacation that costs $3,500 

Paying off money for buying a car will not decrease your net worth as you get the car as assets for the money you use. But the depreciates 20% will cause you to lose $3,000 assets. Assuming you are not buying assets at all, go on a vacation that costs $3,500 will increase liability without any effect on assets. Paying up bills will decrease your asset but it also decreases your liability so the net worth wouldn't change. 
7 0
3 years ago
Write a function endpoints that takes a list of numbers (eg. [5, 10, 15, 20, 25]) and returns a new list of only the first and l
Ne4ueva [31]

I included a picture of my code below. Best of luck with your assignment.

5 0
3 years ago
To avoid potential documentary errors and security leaks, the configuration of firewalls should not be documented unless strictl
Zolol [24]

Answer: False

Explanation:

 The given statement is false, as the configuration of the firewall, operational and administration procedure must be documented.

The configuration of multiple firewall are identical and the integrity and also performance of the configuration firewall files are check on the regularly bases.

It is basically used to avoid the security leaks and the documentation errors so it is necessary that it should be check regularly so that it can easily implement without any interrupt occurrence.

8 0
3 years ago
Moore’s law refers to?
puteri [66]

Answer:

Moore’s law states that processor speeds, or overall processing power for computers will double every two years.

Explanation:

  • Moore’s law is more than an observation than a law which was originated in 1970. The observation is about the number of transistors that is present in any system or an integrated system that will be doubled every couple of years.
  • The real-world application of Moore's law can be seen during computing your business taxes, piloting a spaceship, or changing the television station, etc.
7 0
2 years ago
What type of document is a mobile device's EULA?
MakcuM [25]
EULA stands for End User License Agreement. This document is the contract between the software application author or publisher and the user of that application. It is also called "software license", because it establishes the purchaser's right to use the software on the mobile device. T<span>he user agrees to pay for the privilege of using the software, and promises the software author or publisher to comply with all restrictions stated in the EULA. </span>
6 0
3 years ago
Other questions:
  • &gt;
    6·1 answer
  • Amy has decided to use a dark background and light colored text for her prensentation. Which toolbar option will let her change
    5·1 answer
  • Malware that corrupts the target operating system in such a manner that a network defender can no longer trust the native OS is
    15·1 answer
  • Which is not an example of a mobile operating system?
    9·1 answer
  • An interpreter _______. converts the procedural language one statement at a time converts the source code into machine language
    12·1 answer
  • What important practice can help prevent hardware trouble?
    6·1 answer
  • Writing in Java, write a program that prompts the user to input an integer and then outputs both the individual digits of the nu
    15·1 answer
  • How do we Rewrite the following Python code to avoid error. mark=inpt("enter your mark ")
    6·1 answer
  • Figure out what this says:<br><br> ?driew tib a kool ti seoD
    7·1 answer
  • ____must cooperate with each other to neutralize the global threat of information censorship. Select 3 options.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!