如何在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)
我需要找到输入到c,t次的所有数字的平均值
答案 0 :(得分:2)
您需要跟踪所有标记。像这样:
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)
答案 1 :(得分:1)
使用以下代码:
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)