Python3 代码
def calc_tax(income, base, limit, taxRate):
tax = income - base
if tax > limit and limit > -1:
tax = limit
return tax * taxRate
n = float(input())
tax = 0.0
if n > 2000:
tax += calc_tax(n, 2000, 1000, 0.08)
if n > 3000:
tax += calc_tax(n, 3000, 1500, 0.18)
if n > 4500:
tax += calc_tax(n, 4500, -1, 0.28)
if tax > 0:
print ("R$", f'{tax:.2f}')
else:
print ("Isento")