I’m brand new to this, 10 days in.
Ive been thinking how I could solve this for 30 min. Please help.
Find Average
You need to calculate the average of a collection of values. Every value will be valid number. The average must be printed with two digits after the decimal point.
Input-
On the first line, you will receive N – the number of the values you must read
On the next N lines you will receive numbers.Output-
On the only line of output, print the average with two digits after the decimal point.
Input 4 1 1 1 1 Output 1.00 Input 3 2.5 1.25 3 Output 2.25
From what I see, I figure I need to create as much inputs as the N of the first one is and then input the numbers Id like to avarage and then create a formula to avarage them. I may be completely wrong in my logic, in any case Id be happy for some advice.
So far I tried creating a while loop to create inputs from the first input. But have no clue how to properly sintax it and continue with making the new inputs into variables I can use
a=int(input())
x=1
while x<a or x==a:
float(input())
x=x+1
>Solution :
a=int(input('Total number of input: '))
total = 0.0
for i in range(a):
total += float(input(f'Input #{i+1}: '))
print('average: ', total/a)
Modified a bit on your version to make it work