You are given a non-empty sequence of non-negative integers terminated by a -1. The -1 is not part of the input sequence. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

You are given a non-empty sequence of non-negative integers terminated by a -1. The -1 is not part of the input sequence.

You are given a non-empty sequence of non-negative integers terminated by a -1. The -1 is not part of the input sequence. The sequence has length at most 100, including the -1. There will be at least one non-negative number. You have to output the sequence of running averages, where: The first average is the first input number. The second output is the average of the first two input numbers. The third output is the average of the first three input numbers, and so on. Output Format: You should output exactly 2 digits after the decimal place. Different numbers in the output should be separated by spaces. At the end, you should print a newline.

25th Sep 2019, 3:34 PM
Kartik Singh
1 Answer
0
sum=0 n = 1 inp = input().split() for i in inp: i = int(i) if(i== -1): break sum = sum+i print("{:.2f}".format(sum/n)) n=n+1
18th May 2022, 12:11 PM
Garima Dewangan