Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
50466 杨骐恺 2023经开区信息技术合格性考试-1 Python3 解答错误 0 41 MS 4492 KB 864 2024-12-24 14:48:42

Tests(0/8):


def calculate_discount(total_amount): if total_amount >= 4000: discount_rate = 0.6 elif total_amount >= 3000: discount_rate = 0.7 elif total_amount >= 2000: discount_rate = 0.8 else: discount_rate = 1.0 discounted_price = total_amount * discount_rate return discounted_price def main(): try: total_amount = float(input("请输入购物总金额: ")) if total_amount < 0: print("输入的金额不能为负数,请重新输入。") return final_price = calculate_discount(total_amount) print(f"原价: {total_amount}元") print(f"折扣后的价格: {final_price:.2f}元") except ValueError: print("输入无效,请输入一个数字。") if __name__ == "__main__": main()


测评信息: