用python语言实现以下程序 购买地铁车票的规定如下: 乘1-4站,3元/位;乘5-9站,4元/位;乘9站以上,5元/位。 输入人数、站数,输出应付款。
时间: 2024-02-10 14:45:20 浏览: 35
好的,这是一道简单的Python编程题目。以下是可以实现这个程序的代码示例:
```
num_people = int(input("请输入乘车人数:"))
num_stations = int(input("请输入乘车站数:"))
if num_stations <= 4:
cost_per_person = 3
elif num_stations <= 9:
cost_per_person = 4
else:
cost_per_person = 5
total_cost = num_people * cost_per_person
print("应付款为:{}元".format(total_cost))
```
希望这个程序能够解决你的问题。如果你有其他问题,请继续提问。
相关推荐
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![jpg](https://img-home.csdnimg.cn/images/20210720090814.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)