acgo题库
  • 首页
  • 题库
  • 题单
  • 竞赛
  • 讨论
  • 排行
  • 团队
  • 备赛专区

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
登录
注册
题目详情题解(0)讨论(0)提交记录(0)
  • A30459.【PY】年终大促销

    初始化变量 total_price:用于累加所有输入的价格。 discount_threshold:设定折扣阈值为150元。 discount_rate:设定折扣率为85%(即0.85)。 循环读取输入 while True:无限循环读取输入。 price = int(input()):读取一行输入并将其转换为整数。 if price == 0:如果输入为0,则跳出循环。 total_price += price:将读取的价格累加到总价中。 计算折扣后的价格 if total_price > discount_threshold:如果总价超过150元。 (total_price - discount_threshold) * discount_rate:计算超过150元部分的折扣价。 * discount_threshold:加上未打折的150元部分。 else:如果总价未超过150元,则不打折。 输出结果,保留两位小数 f"{discounted_price:.2f}":格式化输出保留两位小数的浮点数。

    userId_undefined

    氓之蚩蚩

    0阅读
    0回复
    0点赞
首页