早教吧 育儿知识 作业答案 考试题库 百科 知识分享

怎么用Python的for循环和while循环算平均数分别用for和while在1到10里任意输入五个数然后算出他们的平均值.求大神

题目详情
怎么用Python 的for循环和while循环算平均数
分别用for和while 在1到10里任意输入五个数然后算出他们的平均值.求大神
▼优质解答
答案和解析
m = 0
for i in range(5):
s = raw_input()
m += float(s)/5.0

print 'the average is: ',m


i = 0
m = 0
while i < 5:
s = raw_input()
i += 1
m += float(s)/5.0
print 'the average is: ',m