Click here to Skip to main content
15,667,355 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Input format

First line contains the number of numbers, n

Next ‘n’ lines contain the numbers in the collection

Output format:

Print Average in two decimal format

What I have tried:

Python
n=input()
for i in range(0,n):
    ni=input()
print(ni)
for i in range(0,n):

i am not really able to understand how to take unknown no. of inputs and then their average
Posted
Updated 10-Nov-20 4:34am
v2

1 solution

You may store the entered numbers into a list (and then perform the computations) or, alternatively, you may compute their sum 'on the fly' and then compute the average.
In the following code, I show you how to store the numbers into a list
Python
n = int(input())
l = []
for i in range(0,n):
  l.append(float(input()))

print(l)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900