gpt4 book ai didi

Python——古代税收

转载 作者:太空狗 更新时间:2023-10-30 00:45:24 25 4
gpt4 key购买 nike

在这个问题中,它说前 10,000 德拉克不征税,接下来的 20,000 征税 10%,接下来的 40,000 征税 20%,而前 70,000 之后的任何征税 30%。我是 python 的新手,但这是我目前所拥有的。我不确定我哪里出错了。我认为这是因为我没有定义“税”变量,但我不确定。任何帮助将非常感激。谢谢!

**如果用户输入负数,代码也必须终止,我不确定如何将其添加到我的 for 循环中。

def income(drach):

for drach in range(10000):
tax = 0
for drach in range(10000 , 30000):
tax = ((drach - 10000)*0.1)
for drach in range(30000 , 70000):
tax = ((drach - 30000)*0.2) + 2000
for drach in range(70000 , 10**999):
tax = ((drach - 70000)*0.3) + 10000

print tax

最佳答案

我认为这是正确的税收模式:

   def tax(income):
tax=0;
if income > 70000 :
tax += (income-70000)* 0.3
income = 70000
if income > 30000 :
tax += (income-30000)* 0.2
income = 30000
if income > 10000 :
tax += (income-10000)* 0.1
return tax;

关于Python——古代税收,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19120775/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com