小明的妈妈让他用Python记录购物清单的价格,并计算总花费。已知购物列表为:prices = [5, 8, 3, 10, 2], 依次为牛奶、面包、苹果、鸡蛋、糖果的价格,计算总花费正确的选项是?( )
A:total = prices[0] + prices[-1]
B:total = sum(prices)
C:total = prices[1] + prices[2] + prices[3]
D:total = len(prices)
正确答案:B
题库首页 › 青少年软件编程(Python) › 题目 17372
正确答案:B