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
Nataly_w [17]
1 year ago
8

Edit the program provided so that it receives a series of numbers from the user and allows the user to press the enter key to in

dicate that he or she is finished providing inputs. After the user presses the enter key, the program should print:
The sum of the numbers
The average of the numbers
An example of the program input and output is shown below:

Enter a number or press Enter to quit: 1
Enter a number or press Enter to quit: 2
Enter a number or press Enter to quit: 3
Enter a number or press Enter to quit:

The sum is 6.0
The average is 2.0

This is what I have but it just keep going with the numbers
# Edit the code below
theSum = 0.0
count = 0
while True:
number= input("Enter a number or press Enter to quit:")
if number=="":
break
theSum+=float(number)
count+=1
print("The sum is", theSum)
if count>0:
print("The average is ", theSum/count)
Computers and Technology
1 answer:
BlackZzzverrR [31]1 year ago
8 0

The edited and complete program is as follows

theSum = 0.0

count = 0

while True:

   number= input("Enter a number or press Enter to quit:")

   if not number:

       print("The sum is", theSum)

       if count>0:

           print("The average is ", theSum/count)

       exit()

   theSum+=float(number)

   count+=1

<h3>How to edit the program?</h3>

The complete program that calculates the average and the sum of numbers entered by the user is as follows:

Note that the program ends when the user presses the enter key and comments are used to explain each line

#This initializes the sum

theSum = 0.0

#This initializes the counter

count = 0

#This ensures the user enters numbers repeatedly

while True:

   #This gets the input

   number= input("Enter a number or press Enter to quit:")

   #When the user presses enter

   if not number:

       #This prints the sum and the average

       print("The sum is", theSum)

       if count>0:

           print("The average is ", theSum/count)

       #This exits the program

       exit()

   #This calculates the sum

   theSum+=float(number)

   count+=1

Read more about python programs at

brainly.com/question/26497128

#SPJ1

You might be interested in
Validating the results of a program is important to a. correct runtime errors b. make sure the program solves the original probl
elena-s [515]

Answer:

b. make sure the program solves the original problem

Explanation:

This is important so as to avoid logical errors. Logical errors unlike compiler or run time errors will not stop your code from compilling and executing but after your program compiles and runs, but does the wrong thing by given you unexpected results

This is the reason why validation of results after your code is completed is important in this way you are sure the program solves the original problem.

4 0
3 years ago
All dogs = 199999990158161231
devlian [24]

Answer:

C=D cause d spells dogs jk I really dont know

3 0
3 years ago
Read 2 more answers
What is a tax exemption (also known as a tax allowance)?
KengaRu [80]
<span>Tax exemption refers to a monetary exemption which reduces taxable income. Tax exempt status can provide complete relief from taxes, reduced rates, or tax on only a portion of items.</span>
4 0
2 years ago
What is the purpose of citations?
Elina [12.6K]

Answer: Citiations areto show where you got information from.

Explanation:

6 0
3 years ago
"In a web app, where is data usually stored? A. Mobile network B. Application storage C. Local computer D. Cloud storage"
ollegr [7]

Answer:

The answer is "Option C".

Explanation:

The local computer also refers to locally, it is a device, that is used by LAN. It is also called as a remote computer, in which all the data is stored in the main computer and accessible by protected password, and certain choices were wrong, which can be described as follows:

  • In option A, It is used in digital communication.
  • In option B, It is used in androids.
  • In option D, It is used to provides web services.
6 0
3 years ago
Other questions:
  • 2. Statement: "I don't agree with you." Nonverbal gesture: Type of gesture:
    6·1 answer
  • You can access various sites on the WWW by using hyperlinks or by
    14·1 answer
  • Which is a real-world example of a procedure?
    11·1 answer
  • An IT technician has manually configured an IP address on a laptop for a new employee. Each time the employee tries to connect t
    10·1 answer
  • Windows 1.0 was not considered to be a "true" operating system but rather an operating environment because _____.
    13·1 answer
  • You have been using the same computer for several years. To extend its service life, you decide to upgrade the processor. You ch
    13·1 answer
  • 5. Which one of the following statements is true for spell checkers? A. Most spell checkers flag inappropriate word usage. B. A
    5·1 answer
  • Help meee pleaseeee
    5·1 answer
  • Xavier buys a new laptop for $540. He makes a down payment $75 and pays the rest in 6 equal monthly payments, p. What equation r
    7·1 answer
  • Implement a metho d to nd the k-th largest element in an array of size N using a minimum priority queue (MinPQ). Assume that the
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!