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
Rom4ik [11]
3 years ago
10

Write a program that receives a series of numbers from the user and allows the user to press the enter key to indicate that he o

r 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
BASE CODE

theSum = 0.0
data = input("Enter a number: ")
while data != "":
number = float(data)
theSum += number
data = input("Enter the next number: ")
print("The sum is", theSum)
Computers and Technology
1 answer:
kogti [31]3 years ago
5 0

Answer:

theSum = 0.0#defined in the question.

count=0 #modified code and it is used to intialize the value to count.

data = input("Enter a number: ") #defined in the question.

while data != "": #defined in the question.

   number = float(data) #defined in the question.

   theSum += number #defined in the question.

   data = input("Enter the next number or press enter to quit ") #defined in the question "only some part is modified"

   count=count+1#modified code and it is used to count the input to print the average.

print("The sum is", theSum)#defined in the question.

print("The average is", theSum/count) #modified code and it is used to print the average value.

output:

  • If the user inputs as 1,4 then the sum is 5 and the average is 2.5.

Explanation:

  • The above code is written in the python language, in which some part of the code is taken from the question and some are added.
  • The question has a code that tells the sum, but that code is not print the average value of the user input value.
  • To find the average, some codes are added, in which one count variable which is initialized at the starting of the program and gets increased by 1, when the user gives the value.
  • Then that count divides the sum to print the average.
You might be interested in
The hottest part of the Earth is the
Troyanec [42]
C. Mantle would be correct
3 0
3 years ago
Read 2 more answers
Most operating systems perform these tasks.
taurus [48]
1, 3




---------------------------------------------------
3 0
3 years ago
Read 2 more answers
Let G = (V, E) be an undirected graph. Design algorithms for the following (in each
Degger [83]

Answer:

i think its b if not sorry

Explanation:

3 0
2 years ago
Although heart rate increases and decrease depending upon activity level on average a typical person heart rate is about _____ b
ExtremeBDS [4]

Answer:

72

The normal resting heart rate is between 70 and 100 bpm.

4 0
3 years ago
Q.drtrdyudoijoemrkdf
sveta [45]

Answer:

Yes

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • "The term ____ refers to the programs or instructions used to tell the computer hardware what to do."
    6·1 answer
  • A computer’s BIOS is defined as the
    12·2 answers
  • Idea citizen activation
    9·2 answers
  • The function of the file server is to : 1. store data and software programs that can be used by client computers on the network.
    12·1 answer
  • You are late in the preparation of the computer graphics for your final report and presentation. You run into a friend who is gr
    13·1 answer
  • You are utilizing BitLocker Drive Encryption, and are attempting to update Windows Server 2016. What must be done so that the up
    14·1 answer
  • AYUDAAAA!!!!! URGENTE!!!!!!1<br> ¿para que sirve la "BIG DATA"?
    9·1 answer
  • The information given to you by your teachers is always accurate and should never be questioned. Please select the best answer f
    8·1 answer
  • Why should running your unit test suites not take a long time?A. Unit tests aren't that important, so less time should be spent
    5·1 answer
  • Write code that outputs variable numCats. End with a newline.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!