请编写一个Python程序,实现全场满200减50的优惠活动

编写一个程序,让用户输入消费金额,然后根据消费金额判断是否满足满减条件,并输出相应的优惠信息。

2 个回答

明记

```python def calculate_discounted_price(total_amount): """ Calculate the discounted price based on the total amount spent. If the total amount is greater than or equal to 200, a discount of 50 is applied. Parameters: total_amount (float): The total amount spent by the customer. Returns: float: The final amount after applying the discount if applicable. """ if total_amount >= 200: discount = 50 discounted_price = total_amount - discount else: discounted_price = total_amount return discounted_price # Example usage: total_spent = 250 final_price = calculate_discounted_price(total_spent) print(f"The final price after discount is: ${final_price}") ```

boynow

```python # 获取用户输入的消费金额 a = int(input(