99问答网
所有问题
Python 2.7练习 要求不能使用内建sum函数,也不能使用list列表,请大神指教
Python 2.7练习
要求不能使用内建sum函数,也不能使用list列表,请大神指教
举报该问题
推荐答案 2014-10-30
score=int(raw_input("Enter a score(enter 0 to stop):"))
total=0.0
num=0
average=0
while score!=0:
num+=1
total+=score
score=int(raw_input("Enter a score(enter 0 to stop):"))
if num!=0:
average=total/num
print "The average is %.2f"%average
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://99.wendadaohang.com/zd/7WXWBBXv7WXjvjeOjv.html
相似回答
大家正在搜
相关问题
python练习,不能使用find函数,命令中至少构建3个函...
请问Python中 for in是怎么用的
python的sum函数怎么用
用python设计函数 输入一个2维列表 用该函数计算每一列...
python如何定义一个函数求列表各项数据平均值?
Python中dict为什么比list浪费内存?求大神,感激...
如何从python的list中提想要的值
谁说Python性能差的