1 Réponse
+ 1
length=int(input("How Many Numbers? "))
average=0
for i in range(length):
x=int(input())
average=average+x
print(average/length)
'''
There are alot of ways. This code asks how many numbers and then averages them together.
You could use a while loop that takes numbers indefinitely until told to stop.
Ultimately, you have a problem. break it down.
What do you want? For user to input how many numbers they want to average together.. ok, take the input
howMany=int(input("How many numbers?")
now you want to take that many numbers and average them together. ok. you already know how many there will be. put it thru a loop to ask for that many numbers.
for i in range(howMany):
now for each run of the loop, get a number and add it to the numbers you already have. have them all?
divide by howMany and you will have your average.
Take things 1 step at a time. before you know it, you have a code that does what you want
'''