Quick actions

cmd+k|ctrl+k

Navigation

Languages

Payable tax calculator 27/5

Snippet info

Language

Python

Visibility

public

Author

tonyngswell

Created

2026-05-27T12:39:44.357461Z

Updated

2026-05-27T12:39:44.357461Z

while True:
    while True:
        income= input("Pls input your annual income for Yr 2023: ")
        try:
            income=float(income)
            break
        except ValueError:
            print("please input your income in numbers!")
            
    
    
    if income <= 50000:
        accum_tax = income * 0.02
        
    elif 50000<income <= 100000:
        accum_tax = 1000 + (income - 50000) * 0.05
        
    elif 100000<income<=150000:
        accum_tax = 3500 + (income - 100000) * 0.10
       
    elif 150000<income<=200000:
        accum_tax = 8500 + (income - 150000) * 0.15
        
    else:
        accum_tax = 16000 + (income - 200000) * 0.25
        
    
    standard_tax = income * 0.16
    payable_tax=min(accum_tax, standard_tax)
    
    income = round(income, 1)
    accum_tax = round(accum_tax, 1)
    standard_tax = round(standard_tax, 1)
    payable_tax=round(payable_tax, 1)
    
    print("The result is as follows:")
    print(f"Your income is:$ {income}")
    print(f"Your projected accumulated tax:$ {accum_tax}")
    print(f"Your projected standard tax:$ {payable_tax}")
    while True:
            quit_choice = input("Do you want to calculate another tax result? (y/n): ").strip().lower()
            
            if quit_choice == 'n':
                print("Thank you for using the tax calculator. Goodbye!")
                # This breaks out of the OUTER loop to close the program
                break 
            elif quit_choice == 'y':
                print("Starting next calculation...\n")
                # This breaks out of the quit loop so the program can loop back to the top
                break 
            else:
                # If they typed anything else, the loop repeats and asks again
                print
    if quit_choice == 'n':
        break
INFO