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
Veseljchak [2.6K]
3 years ago
11

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
Computers and Technology
1 answer:
Dmitriy789 [7]3 years ago
5 0

Answer:

The solution code is written in Python 3

  1. count = 0
  2. sum = 0
  3. num = input("Enter a number: ")
  4. while(num != ''):
  5.    sum += float(num)
  6.    count += 1
  7.    num = input("Enter a number: ")
  8. print("Sum : " + str(sum))
  9. print("Average: " + str(sum / count))

Explanation:

Firstly, we declare two variables count and sum to hold the number of input number and the total of the input number, respectively (Line 1-2)

Next, we prompt user to input the first number (Line 4). While the num is not ' ' (This means it is not "Enter" key), accumulate the num to sum variable and increment count by one (Line 6-8) and then prompt the user to input the next number (Line 9).

At the end, display the sum and average using print function (Line 11 -12).

You might be interested in
What is the name of a button on a website?
zhuklara [117]
May I know which button?
5 0
3 years ago
Downlad the file and write a program named Lab10b_Act2.py that does the following: Opens the CSV file for reading Reads the CSV
a_sh-v [17]
他們會不會是因為這樣就是說他們的問題,他們會會覺得委屈覺得我
5 0
3 years ago
Which type of image is not a supported using the Online Pictures or Insert Picture command?
IgorC [24]

Answer:

HTML  i think

Explanation:

4 0
3 years ago
Read 2 more answers
I need help in Jumbotron: Paragraph. The question is:
Aleksandr-060686 [28]
<span>.jumbotron p
{
color: #fff;
font-size: 20px;
}</span>
6 0
3 years ago
If anyone plays pokemon go put your code below.
Cerrena [4.2K]
Yeah my pokémon is not my mom hung bye
4 0
3 years ago
Read 2 more answers
Other questions:
  • Fix the 2 error codes.
    14·1 answer
  • You save $500 in a retirement account at age 25. it increases an average of 10% per year until you are 65. which formula and res
    13·1 answer
  • How can website illustrate cooperations and kidness?
    8·1 answer
  • Make a program that (i) asks the user for a temperature in Fahrenheit degrees and reads the number; (ii) computes the correspond
    8·1 answer
  • The producer thread will alternate between sleeping for a random period of time and inserting a random integer into the buffer.
    7·1 answer
  • What was the first video game ever invented
    11·2 answers
  • Which company provides a crowdsourcing platform for corporate research and development?
    9·1 answer
  • What is the difference between an activity inventory and an object inventory?
    8·1 answer
  • Normalization works through a series of stages called normal forms. For most purposes in business database design, _____ stages
    7·2 answers
  • 2. The internet offers a great source of information; however, how are
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!