ERB 28 Jan 2026 Exercise Tax Cal

Run Settings
LanguagePython
Language Version
Run Command
# Excerise 1 # Define tax brackets Tax_Gap = [ (50000, 0.02), (100000, 0.05), (150000, 0.10), (200000, 0.15), (float("inf"), 0.25) ] while True: income_str = input("Please input your annual income for Yr 2023: ") # Input checking if income_str == "": print("Nothing input") continue # Number check try: income = float(income_str) except ValueError: print("Please input numbers only") continue # Accumulated tax tax = 0 p_limit = 0 for limit, rate in Tax_Gap: if income > limit: tax += (limit - p_limit) * rate p_limit = limit else: tax += (income - p_limit) * rate break tax = round(tax, 2) # Standard tax tax2 = round(income * 0.16, 2) # Payable tax pay_tax = min(tax, tax2) # Printout print("\nThe Result is as follows:\n") print(f"{'Your income:':<30}${income:>15.2f}") print(f"{'Projected accumulated tax:':<30}${tax:>15.2f}") print(f"{'Projected standard tax:':<30}${tax2:>15.2f}") print(f"{'Payable tax:':<30}${pay_tax:>15.2f}") # Ask user to continue or not cont = input("\nDo you want to continue? (Y/N): ") if cont.upper() != "Y": print("Thank you for using the tax calculator. Goodbye!") break
Editor Settings
Theme
Key bindings
Full width
Lines