コンテンツへスキップ
メニュー
この質問にフラグが付けられました
4 返信
6679 ビュー

c = Taxable Income if c <= 170000:

    result = c

elif 170000<c<=360000:

      result = round(0.09 * (c - 170000))

elif 360000<c<=540000:

      result = round(17,100 + (0.2 * (c - 360000)))

elif 540000<c<=720000:

      result = round(53100 + (0.25 * (c - 540000)))

elif c>720000:

     result = round(98100 + (0.3 * (c - 720000)))

else:

       result = 0

アバター
破棄
最善の回答

Yes, Python recognize code blocks by indentation. Niyas, you missed out the variable assignation..

c = [Taxable Income] -> this should be a value or a variable calculated in another rule.

if c <= 170000:
    c = Taxable_Income
    result = c
elif 170000 < c <= 360000:
    result = round(0.09 * (c - 170000))
elif 360000 < c <= 540000:
    result = round(17, 100 + 0.2 * (c - 360000))
elif 540000 < c <= 720000:
    result = round(53100 + 0.25 * (c - 540000))
elif c > 720000:
    result = round(98100 + 0.3 * (c - 720000))
else:
    result = 0
アバター
破棄
最善の回答

Hey, Your code seems correct. May be you are doing mistake while write the same code in your rule. Just remind you Do not add any space before your statement in rule. in your case c =Taxable_income start with first column in rule.

アバター
破棄
最善の回答

Try this,

# -*- coding: utf-8 -*-
if c <= 170000:
c = Taxable_Income
result = c elif 170000 < c <= 360000:
result = round(0.09 * (c - 170000))
elif 360000 < c <= 540000:
result = round(17, 100 + 0.2 * (c - 360000))
elif 540000 < c <= 720000:
result = round(53100 + 0.25 * (c - 540000))
elif c > 720000:
result = round(98100 + 0.3 * (c - 720000))
else:
result = 0

Just corrected the syntax and white spacing.

Thanks

アバター
破棄
著作者 最善の回答

Still not working


アバター
破棄