提问:python问题
网友回答:
程序参考:
#-*-coding:utf-8 -*- myDict={"方糖":99,"X1":499,"魔盒":399,"曲奇":299} s=0 ct=0 maxp=0 maxn='' for i in myDict: print("%s…………%d元"%(i,myDict[i])) s+=myDict[i] ct+=1 if myDict[i]>maxp: maxn=i paxp=myDict[i] print("平均值为",s/ct); print("价格最高的是:",maxn)
测试结果: