Reputation: 1
How to find mean in python
t = int(input("How many marks do you want entered" ))
g = 0
for i in range(t):
c = int(input('what is your mark'))
g = c/t
print(g)
I need to find the mean of all the numbers entered into c, t amount of times
Upvotes: 0
Views: 208
Reputation: 307
use below code:
t=int(input("How many marks do you want entered" ))
g=0
c=0
for i in range(t):
c += int(input('what is your mark'))
g = c/t
print(g)
Upvotes: 1
Reputation: 49784
You need to keep track of all of the marks. Something like:
t = int(input("How many marks do you want entered" ))
g = 0
marks = []
for i in range(t):
marks.append(int(input('what is your mark')))
g = sum(marks)/t
print(g)
Upvotes: 2