# Compute the amount of federal income tax payable # Use constants for the tax bracket limits and the tax rates so that it # is easy to update the program when these values change. LIMIT_1 = 43561 LIMIT_2 = 87123 LIMIT_3 = 135054 RATE_1 = 0.15 RATE_2 = 0.22 RATE_3 = 0.26 RATE_4 = 0.29 # Read the user's income income = float(input("Enter your income: ")) # Compute the amount of tax owing if the user's income is in the lowest bracket if income < LIMIT_1: tax = RATE_1 * income # Compute the amount of tax owing if the user's income is in the second bracket elif income < LIMIT_2: tax = RATE_1 * LIMIT_1 + RATE_2 * (income - LIMIT_1) # Compute the amount of tax owing if the user's income is in the third bracket elif income < LIMIT_3: # The \ character at the end of a line is the "line continuation character". # It allows you to continue your expression on the next line. The \ must # be the last character on the line without any spaces after it. tax = RATE_1 * LIMIT_1 + RATE_2 * (LIMIT_2 - LIMIT_1) + \ RATE_3 * (income - LIMIT_2) # Compute the amount of tax owing if the user's income is in the highest bracket else: tax = RATE_1 * LIMIT_1 + RATE_2 * (LIMIT_2 - LIMIT_1) + \ RATE_3 * (LIMIT_3 - LIMIT_2) + RATE_4 * (income - LIMIT_3) # Display the result formatted so that it has two digits to the right of # the decimal point. print("Your tax payable is $%.2f." % tax)