我想从此计算器计算应纳税所得额,而且我一直收到错误消息“错字不是可下载的”。该错误出现在calcPEP函数中。我试图从我的TaxReturn对象中将AGI传递到我的计算器中,以计算免除的逐步淘汰,并随后计算应纳税所得额。错字不是可订阅的
class TaxReturn:
def __init__(self, AGI):
self.AGI = AGI
#import math program to retrieve rounding function
import math
#assign name to TaxReturn class
txreturn = TaxReturn()
#class for pesonal exemption phaseout (PEP)
class PEP:
#define phase in rate, personal exemption amount, AGI phaseout thresholds
def __init__(self, phase_in_rate, personal_exemption, dependents):
self.phase_in_rate = phase_in_rate
self.personal_exemption = personal_exemption
self.dependents = dependents
#calculate PEP using AGI attribute from TaxReturn object
def calcPEP (phase_in_rate, personal_exemption, dependents, txreturn):
#thresholds by filer status where PEP phase-outs begin
#[single, HOH, married joint, married separate]
phase_out_threshold = int[258250, 284050, 309900, 154950]
for i in phase_out_threshold:
if txreturn.AGI >= phase_out_threshold:
#calculate the amount to which PEP applies
PEP_amount = txreturn.AGI - i
#calculate PEP multiplier
PEP_amount /= 2500
#round up PEP multplier
PEP_amount = math.ceil(PEP_amount)
PEP_amount = (PEP_amount*phase_in_rate)/100
#calculate total reduction of exemptions
PEP_amount *= personal_exemption*dependents
#calculate taxable income
if personal_exemption*dependents - PEP_amount > 0:
taxable_inc = txreturn.AGI - (personal_exemption*dependents - PEP_amount)
else:
taxable_inc = txreturn.AGI
else: taxable_inc = txreturn.AGI - personal_exemption*dependents
return taxable_inc
testPEP = PEP(2, 4000, 2)
print(testPEP.calcPEP(4000, 2, 350000))
@AIG是的,你是对的。谢谢您的帮助。 –