我正在编写部分代码(正如标题中所述)。 所有的elif都在努力工作到第10行(即elif inc< = e和inc> d :),这是IDLE中突出显示的错误。这是代码:
def calc(a,b,c,d,e,f):
if inc <= a and inc >= 0:
tax = 0.10 * income
elif inc <= b and inc > a:
tax = (0.10 * a) + (0.15 * (income - a))
elif inc <= c and inc > b:
tax = (0.10 * a) + (0.15 * b) + (0.25 * (income - b))
elif inc <= d and inc > c:
tax = (0.10 * a) + (0.15 * b) + (0.25 * c) + (0.28 * (income - c)
elif inc <= e and inc > d:
tax = (0.10 * a) + (0.15 * b) + (0.25 * c) + (0.28 * d) + (0.33 * \
(income - d))
elif inc <= f and inc > e:
tax = (0.10 * a) + (0.15 * b) + (0.25 * c) + (0.28 * d) + (0.33 * \
e) + (0.35 * (income - e))
elif inc > f:
tax = (0.10 * a) + (0.15 * b) + (0.25 * c) + (0.28 * d) + (0.33 * \
e) + (0.35 * f) + (0.396 * (income - f)
tax_str = str(tax)
答案 0 :(得分:2)
这一行:
tax = (0.10 * a) + (0.15 * b) + (0.25 * c) + (0.28 * (income - c)
您忘记在最后添加)
。