55 is enough

Report a typo

Write a program that reads numbers until a user enters 5555. Once 5555 is entered, stop reading the input and ignore the numbers entered afterward (numbers entered before 5555, regardless of whether they are greater or less than 5555, should be counted), print out how many numbers have been entered before 5555, their total sum, and average (round the resulting average this way: round(average)). Do NOT include 5555 in your calculations. Print each resulting value on a new line in the following order:

  • how many numbers were given until 55
  • their sum
  • their average: sum / the number of given numbers

Tip: There are several ways to solve the problem, feel free to choose the one you like. However, the easiest one would be to use two variables – one to count incoming numbers (assign it to 0 and increase its value each time the incoming number is not 55) and one to sum them up on the fly (once again, start with 0 and add each incoming number not equal to 55 to it). This way, you won't need any additional tools.

Sample Input 1:

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
55
17
16
15
14
13

Sample Output 1:

18
153
8
Write a program in Python 3
# put your code here
___

Create a free account to access the full topic