已知字典 dic= apple6 orange5 banana3 pear8 watermelon10 存放了水果的名称和价格。试编写程序实现以下功能:1、接收用户输入的价格假设为整数2、计算 高于用户输入价格 的所有水果的总价10分可参照以下程序框架进行填充补全:dic= apple6 orange5 banana3 pear8 watermelon10price=_______________
dic={ 'apple':6, 'orange':5, 'banana':3, 'pear':8, 'watermelon':10} price=int(input()) #输入价格 s=0 for k,v in dic.items(): #遍历字典 if v>price: #判断当前水果的价格是否高于用户输入的价格 s+=v print(s) #输出结果
原文地址: https://www.cveoy.top/t/topic/gusM 著作权归作者所有。请勿转载和采集!