# # A simple federal income tax caluclator that doesn't consider any deductions # # # Introduce constants to make it easier to update the program when the # boundaries for the tax brackets change. # TAX_BRACKET_1 = 40726 TAX_BRACKET_2 = 81452 TAX_BRACKET_3 = 126264 RATE_1 = 0.15 RATE_2 = 0.22 RATE_3 = 0.26 RATE_4 = 0.29 income = input("Enter your annual income: ") if (income < TAX_BRACKET_1): tax = income * RATE_1 elif (income < TAX_BRACKET_2): tax = TAX_BRACKET_1 * RATE_1 + (income - TAX_BRACKET_1) * RATE_2 elif (income < TAX_BRACKET_3): tax = TAX_BRACKET_1 * RATE_1 + (TAX_BRACKET_2 - TAX_BRACKET_1) * RATE_2 + (income - TAX_BRACKET_2) * RATE_3 else: tax = TAX_BRACKET_1 * RATE_1 + (TAX_BRACKET_2 - TAX_BRACKET_1) * RATE_2 + (TAX_BRACKET_3 - TAX_BRACKET_2) * RATE_3 + (income - TAX_BRACKET_3) * RATE_4 # # Format output to 2 decimal places # print "Your tax payable is %.2f" % tax