上周报名了reboot python 课程,终于下决心要把python 搞好了,希望自己能坚持下来,并得到自己想要的成绩
#coding:utf-8 #用户输入名字和分数,并保存到list。如果输入为空,打印并结束循环。并算出平均值 list1=[] count=0 num=0 while True: x=raw_input(‘please input your name:‘) y=raw_input(‘please input your grade:‘) if y.isdigit() and x.isalpha(): list1.append(int(y)) list1.append(str(x)) count+=1 num=int(num)+int(y) elif len(x)==0 or len(y)==0: avg=num/count print list1 break else: print ‘input is error‘ print ‘平均值是 %s‘ %(avg)
时间: 2024-10-12 19:14:21