2026年编程语言高级应用题库如PythonJava等.docxVIP

  • 1
  • 0
  • 约1.03万字
  • 约 20页
  • 2026-08-03 发布于福建
  • 举报

2026年编程语言高级应用题库如PythonJava等.docx

第PAGE页共NUMPAGES页

2026年编程语言高级应用题库如Python、Java等

Python题目(共5题,每题10分)

题目1(10分)

背景:某电商平台需要对用户购买记录进行数据分析,统计每种商品的总销售额。假设已有以下用户购买记录列表,其中每个元素为一个字典,包含商品名称(`product_name`)、购买数量(`quantity`)和单价(`price`)。

python

purchases=[

{product_name:手机,quantity:2,price:3000},

{product_name:耳机,quantity:5,price:200},

{product_name:手机,quantity:1,price:3000},

{product_name:充电宝,quantity:3,price:100},

{product_name:耳机,quantity:2,price:200},

{product_name:手机,quantity:3,price:3000},

]

要求:编写Python代码,统计每种商品的总销售额,并以字典形式返回结果,其中键为商品名称,值为总销售额。

答案:

python

fromcollectionsimportdefaultdict

def

文档评论(0)

1亿VIP精品文档

相关文档