Home>

### python : While cycle (job for beginner)

We just started passing while the While cycles. And the teacher did not explain how to use the "Sum" and "Round". And I collected this ???? Code for pieces from the forum. But something is missing. I post the task and the best (in my opinion) code option.

Write a program that reads numbers until the user enters 55. After entering 55, stop reading the input, print how many numbers it was entered, their total amount and the average value (rounded). You do not include 55 in your calculations and printing of each value obtained on the new line in order.

code

``````Number= int (Input ())
i= 0.
While Number <
55:
i= i + 1
S= SUM (Number)
R= Round (Number)
Print (I)
Print (s)
Print (R)
``````

There is not enough string Number= int (input ()) at the end of the cycle. And the comparison should be!= 55.

GrAnd2021-07-21 14:39:20
``````num= int (input ())
nums= []
While Num!= 55:
nums.append (NUM)
Num= int (INPUT ())
S= SUM (Nums)
Length= Len (Nums)
Print ("Len=", Length)
Print ("Sum=", s)
Print ("Average=", S /Length)
``````

In the task, the average value (rounded), and you have Float there. and perhaps lists they have not yet passed and can not append

Интик2021-07-21 16:17:31
``````num= int (input ())
nums= []
While Num!= 55:
nums.append (NUM)
Num= int (INPUT ())
S= SUM (Nums)
Length= Len (Nums)
Print ("Len=", Length)
Print ("Sum=", s)
Print ("Average=", S /Length)
``````

In the task, the average value (rounded), and you have Float there. and perhaps lists they have not yet passed and can not append

Интик2021-07-21 16:17:31