Python薪水计算器

时间:2019-06-05 03:37:27

标签: python

我不确定这在哪里阻止。我将介绍计算工时,工资总额,社会保障,医疗保险的部分。然后停在应计税的部分。

Traceback (most recent call last):
  File "C:\Users\alain\Desktop\CS50Payroll\calculator.py", line 31, in <module>
    NetSalary = GrossSalary - social - medicare - tax
NameError: name 'tax' is not defined

我尝试在多个地方定义税收,但出现相同的错误消息。

payrate   = int(input("How much do you get paid per hour"))
hrsworked = int(input("How many hours have you worked?"))

if hrsworked <= 40:
    GrossSalary = payrate * hrsworked
elif hrsworked > 40:
    GrossSalary = (payrate * 40) + payrate * (1.5 * (hrsworked - 40) )

print(GrossSalary)

social = GrossSalary * 0.065
print(social)

medicare = GrossSalary * 0.145
print(medicare)


def Withholding(tax):
    while true:
        if GrossSalary < 11000:
            tax = 0
        elif GrossSalary > 11000 and GrossSalary < 43000:
            tax = (0.2 * income) - 2200
        elif GrossSalary > 43000 and GrossSalary < 150000:
            tax = (0.4 * (GrossSalary - 43000)) + 6400
        elif GrossSalary > 150000:
           tax = ((GrossSalary - 150000) * 0.45) + 6400 + 42800

NetSalary = GrossSalary - social - medicare - tax

print(NetSalary)

0 个答案:

没有答案