“楼+之Python实战第9期”实验报告

挑战:实现个税计算器
import sys

try:
    if len(sys.argv[1:]) == 1:
        s_income = int(sys.argv[1]) - 3500
        if s_income > 80000:
            tax = s_income*0.45-13505
        elif s_income > 55000:
            tax = s_income*0.35-5505
        elif s_income > 35000:
            tax = s_income*0.30-2755
        elif s_income > 9000:
            tax = s_income*0.25-1005
        elif s_income > 4500:
            tax = s_income*0.20-555
        elif s_income > 1500:
            tax = s_income*0.10-105
        elif s_income > 0:
            tax = s_income*0.03
        else:
            tax = 0

        print(format(tax, ".2f"))
    else:
        print("Parameter Error")
except:
    print("Parameter Error")
copy
最新评论
暂无评论~