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
In C++ we can print message for the user in Arabic?<br><br> A. True<br> B. False
Lynna [10]

Answer:

A

Explanation:

8 0
3 years ago
Help me if you do then you get 10 points and brainliest
stellarik [79]

The answer is A. The earth was formed 4.54 years ago, and during those first serveral hundred million years, oceans, continents started to form.

A) Precambrian time.

3 0
3 years ago
Choose the response that best completes the following statement.
slava [35]

Answer:

consider the outcome

Explanation:

7 0
2 years ago
Need the answer ASAP !!!!
Nuetrik [128]

Answer:

periodic checks

Explanation:

6 0
2 years ago
Before donating a computer you should use a program to wipe the hard disk to remove all of its data
Elenna [48]
Yes you should. highly recommended
7 0
3 years ago
Read 2 more answers
Other questions:
  • Describe in one or more complete sentences how someone starting a computer repair business in a town night gain a competitive ad
    15·1 answer
  • Categories of general purpose application software and examples each​
    13·1 answer
  • Which section of a personal narrative requires the most development
    9·1 answer
  • Suppose I have two DFAs D1, D2 and I perform the product construction on them to get a DFA for the union of their languages. Wha
    15·1 answer
  • Why computer literacy is vital to access in business work
    7·1 answer
  • Which statements about grades are accurate? Check all that apply. Grades help indicate how well a student is understanding a cer
    13·1 answer
  • Which phrase is the best definition of social media?
    10·1 answer
  • 100 POINTS!!!!!!!
    15·2 answers
  • If a company gave you a free version of their software and encouraged you to try and improve it and share it with the only commu
    8·1 answer
  • Define a function FindLargestNum() with no parameters that reads integers from input until a negative integer is read. The funct
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!