price = int(input("请输入价格:")) dic = {'apple':6, 'orange':5, 'banana':3, 'pear':8, 'watermelon':10} total_price = 0 for fruit, fruit_price in dic.items(): if fruit_price > price: total_price += fruit_price print("高于用户输入价格的水果的总价为:", total_price)

已知字典 dic= apple6 orange5 banana3 pear8 watermelon10 存放了水果的名称和价格。试编写程序实现以下功能:1、接收用户输入的价格假设为整数2、计算 高于用户输入价格 的所有水果的总价

原文地址: https://www.cveoy.top/t/topic/fWEl 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录