代码:
shop_dict={'牛奶':65,'面包':15,'可乐':39,'饼干':45,'糖果':24,'水果':35.8} shop_dict['可乐']=60 num=len(shop_dict) sum=0 for i in shop_dict.values(): sum+=i print("您购买%d件物品,共计:%.2f"%(num,sum))
效果图:
代码:
shop_dict={'牛奶':65,'面包':15,'可乐':39,'饼干':45,'糖果':24,'水果':35.8} shop_dict['可乐']=60 num=len(shop_dict) sum=0 for i in shop_dict.values(): sum+=i print("您购买%d件物品,共计:%.2f"%(num,sum))
效果图: