购买餐具
类型:程序题

题目说明

学校食堂购买 110个餐具,总共花了 2200元 。已知:盘子25元一个,碗20元一个,勺子10元一个,请列出盘子、碗、勺子各买多少个的所有组合。

为解决上述问题,小明编写了以下Python程序,运行结果如后图。请将下面数字序号①②③④⑤⑥处的代码补全:

plate = 0
bowl = 0
spoon = 0
price = 0
b =[]
for plate in range(1,round(2200/25)):     #盘子数量从少到多
    price =        ①        #计算盘子价格
    for bowl in range(1,        ②        ):    #碗数量从少到多
        price1 = price + bowl * 20           #计算盘子加碗的价格
        for spoon in range(1,round(2200/10)):    #勺子数量从少到多
            price2 = price1 + spoon * 10              #计算盘子加碗再加勺子的价格
            if        ③        :           #如果总价等于2200元
                if          ④         == 110:          #如果个数等于110个
                    b.         ⑤         ([plate,bowl,spoon,price2])  #将当前数据加入到数组中
for a in        ⑥        :
    print('盘',a[0],'个;碗',a[1],'个;勺',a[2],'个;价',a[3])    #打印出数组中符合要求的数据

图

评分标准

(1)plate * 25 或等效答案;(2分)

(2)round(2200/20) 或等效答案;(3分)

(3)price2 == 2200 或等效答案;(3分)

(4)plate+bowl+spoon 或等效答案;(3分)

(5)append 或等效答案;(3分)

(6)b 或等效答案。(2分)

代码编辑器 加载中...
留空使用题目默认限制
{{resultStatus.text}}
正在加载运行记录...
乐编题库AI助手
人工客服
微信扫码联系客服
历史对话
{{ s.title || '未命名对话' }}
{{ s.created_at }}
暂无历史对话
我能帮助你什么?