0

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

Mithilesh_Kunal
  • 873
  • 7
  • 12
  • Possible duplicate of [Calculating arithmetic mean (one type of average) in Python](https://stackoverflow.com/questions/7716331/calculating-arithmetic-mean-one-type-of-average-in-python) – snakecharmerb Feb 14 '19 at 08:11

2 Answers2

2

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)
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
1

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)
Pradeep Pandey
  • 307
  • 2
  • 7