Print
Category: Series
Hits: 209

Series7. An integer N and a set of N real numbers are given. Output in the same order the rounded values of all the numbers in the given set (as integers), as well as the sum of all rounded values.

Solution in Python 3:

import random

N = random.randrange(1,10)
print("N = ",N)
s = 0
for x in range(N):
#x = random.randrange(1,6)
x = random.uniform(0, 10)
y = round(x)
s += y
print(y," : ",s," : ",x)
print()
print('Sum = ', s)