Python3 练习题
print("simple counter")count=0total=0clist=[]while True: line=input("input integer:") if line: try: number=int(line) clist.append(number) count+=1 total+=number except ValueError as err: print(err) continue else: breakif count: print("numbers:",clist) clist.sort() if len(clist)%2!=0: zjz=clist[len(clist)//2+1] else: zjz=(clist[len(clist)//2]+clist[len(clist)//2+1])/2 #print("count=",count,"total=",total,"min=",clist[0],"max=",clist[len(clist)-1],"avg=",total/count) print("count=",count,"total=",total,"zjz=",zjz,"min=",min(clist),"max=",max(clist),"avg=",total/count)
?