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
What does limited access to a document mean?
OverLord2011 [107]
Limited access to a document usually means that the creator of the document is able to limit how much access one person is able to get.
8 0
3 years ago
Read 2 more answers
Im new what are points
Nesterboy [21]

You earn points to ask questions, the higher your level the more you can hold I'm guessing

8 0
3 years ago
Read 2 more answers
If a football player had to use the restroom during a play what do they do?
Artyom0805 [142]
Usually they wait for halftime
4 0
3 years ago
When is it appropriate to delete an entire row or column as opposed to deleting the data in the row or column
borishaifa [10]

Answer:

huh wdym

Explanation:

7 0
3 years ago
Your company has just opened an office in another state and you need the computers to communicate between the offices. What type
galina1969 [7]

Answer:

WAN network

Explanation:

A WAN network is an abbreviation for wide area network. This telecommunication network is mainly used for networking computers. They are not tied to just one location. They can also be called network of networks. It connects several LANs. The lans stand for local area and networks and they are computer networks and devices that are connected to each other within a geographical area.

8 0
3 years ago
Other questions:
  • How does a 3D CAD solid model program display the progression of work involved in creating a model?
    5·1 answer
  • Which of the following indicates what a reply to all function does in most email programs
    8·1 answer
  • Write down the complete AJAX code to avoid page caching.
    6·1 answer
  • A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in
    13·1 answer
  • List the steps you took to configure SERVERC and take a screen shot of the Connect to DNS Server dialog box by pressing Alt+Prt
    11·1 answer
  • List three examples of telescopes that detect different types of electromagnetic radiation?
    11·1 answer
  • In a singing competition, there are 34 more men than women
    5·2 answers
  • What is cloud computing?
    9·1 answer
  • A typical day in programming and software development would involve
    7·1 answer
  • You are the network administrator for a city library. Throughout the library, there are several groups of computers that provide
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!