python - Python:计算不同输入价格的增值税金额
问题描述
嘿,我在计算不同价格的增值税时遇到了麻烦。如果 priceR250 则增值税率=7.5%。当我运行我的代码时,我没有收到增值税金额。
item_price1 = int(input("Enter the item price: R "))
def vat_calc(price):
if price<100:
vat_amount=price*0.15
elif price>101 and price<249:
vat_amount=price*0.10
else:
vat_amount=price*0.075
print("VAT amount: R", vat_calc(item_price1))
解决方案
你永远不会返回任何东西,return
在你的函数末尾添加一条语句:
item_price1 = int(input("Enter the item price: R "))
def vat_calc(price):
if price<100:
vat_amount=price*0.15
elif price>101 and price<249:
vat_amount=price*0.10
else:
vat_amount=price*0.075
return vat_amount
print("VAT amount: R", vat_calc(item_price1))
推荐阅读
- python - 将对象转换为日期时间。超过 24 小时的时间格式
- python - 如何在 Python tkinter 中使用选项卡制作滑动菜单
- python - Python Pandas - 将 12 列乘以一列以创建 12 个附加列
- c - 在 C 中存储和解压很长的整数数组
- c++ - 如何将包含构造函数的 C++ 类转换为 C 结构?
- ios - 在 UITableViewCell 中定义手势
- node.js - firebase_functions/internal 指定区域时响应不是有效的 JSON 对象云函数,为什么?
- hangfire - 如何将所有 Hangfire 作业的重试次数默认设置为 0?
- android - 如何以编程方式识别android中的HDMI端口和电视开关?
- ios - 发送欢迎电子邮件 iOS Firebase 身份验证