defcomputeTax(status_n, income):
tax =0if status_n ==0:if income <=8350:
tax = income *0.10elif income <=33950:
tax =8350*0.10+(income -8350)*0.15elif income <=82250:
tax =8350*0.10+(33950-8350)*0.15+(income -33950)*0.25elif income <=171550:
tax =8350*0.10+(33950-8350)*0.15+(82250-33950)*0.25+(income -82250)*0.28elif income <=372950:
tax =8350*0.10+(33950-8350)*0.15+(82250-33950)*0.25+(171550-82250)*0.28+(
income -171550)*0.33else:
tax =8350*0.10+(33950-8350)*0.15+(82250-33950)*0.25+(171550-82250)*0.28+(372950-171550)*0.33+(income -372950)*0.35elif status_n ==1:if income <=16700:
tax = income *0.10elif income <=67900:
tax =16700*0.10+(income -16700)*0.15elif income <=137050:
tax =16700*0.10+(67900-16700)*0.15+(income -67900)*0.25elif income <=208850:
tax =16700*0.10+(67900-16700)*0.15+(137050-67900)*0.25+(income -137050)*0.28elif income <=372950:
tax =16700*0.10+(67900-16700)*0.15+(137050-67900)*0.25+(208850-137050)*0.28+(income -208850)+0.33else:
tax =16700*0.10+(67900-16700)*0.15+(137050-67900)*0.25+(208850-137050)*0.28+(372950-208850)*0.33+(income -372950)*0.35elif status_n ==2:if income <=8350:
tax = income *0.10elif income <=33950:
tax =8350*0.10+(income -8350)*0.15elif income <=68525:
tax =8350*0.10+(33950-8350)*0.15+(income -33950)*0.25elif income <=104425:
tax =8350*0.10+(33950-8350)*0.15+(82250-33950)*0.25+(income -68525)*0.28elif income <=186475:
tax =8350*0.10+(33950-8350)*0.15+(82250-33950)*0.25+(104425-68525)*0.28+(
income -104425)*0.33else:
tax =8350*0.10+(33950-8350)*0.15+(82250-33950)*0.25+(104425-68525)*0.28+(186476-104425)*0.33+(income -186476)*0.35elif status_n ==3:if income <=11950:
tax = income *0.10elif income <=45500:
tax =11950*0.10+(income -11950)*0.15elif income <=117450:
tax =11950*0.10+(45500-11950)*0.15+(income -45500)*0.25elif income <=190200:
tax =11950*0.10+(45500-11950)*0.15+(117450-45500)*0.25+(income -117450)*0.28elif income <=372950:
tax =11950*0.10+(45500-11950)*0.15+(117450-45500)*0.25+(190200-117450)*0.28+(
income -190200)*0.33else:
tax =11950*0.10+(45500-11950)*0.15+(117450-45500)*0.25+(190200-117450)*0.28+(372950-190200)*0.33+(income -372950)*0.35returnround(tax)
income_n =50000print(" Taxable Income | \tSingle | Married Joint | Married Separate | Head of a House")print("-"*90)for j inrange(0,201):
b_t = income_n +(j *50)
za = computeTax(0, b_t)
a = computeTax(1, b_t)
b = computeTax(2, b_t)
c = computeTax(3, b_t)# 原始的显示方式# print(b_t, "\t|\t", za, "\t|\t", a, "\t|\t", b, "\t|\t", c)print("\t{:6d}\t\t | {:6d}\t| {:8d}\t | {:6d} \t\t | {:6d} ".format(b_t, za, a, b, c))