降价提醒机器人pta
时间: 2024-03-10 20:40:31 浏览: 79
以下是一个降价提醒机器人的示例代码:
```python
def price_alert(target_price, prices):
for price in prices:
if price < target_price:
print("On Sale!", format(price, ".1f"))
target_price = 99
prices = [98.0, 97.0, 100.2, 98.9]
price_alert(target_price, prices)
```
输出结果为:
```
On Sale! 98.0
On Sale! 97.0
On Sale! 98.9
```
阅读全文