Quick actions

cmd+k|ctrl+k

Navigation

Languages

Tax exercise

Snippet info

Language

Python

Visibility

public

Author

tonyngswell

Created

2026-05-21T13:05:36.87434Z

Updated

2026-05-21T13:59:03.837251Z

counter = 0
while counter < 5:
    counter += 1
    salary = input("input your salary")
    if salary == "":
        continue
    if not salary.isdigit():
        continue
    else:
        if salary <= 50000: #add int() to all salary
            tax = salary * 0.02
        elif salary <= 100000:
            tax = 50000 * 0.02 + (salary - 50000) * 0.05
        elif salary <= 150000:     
            tax = 50000 * 0.02 + (50000) * 0.05 + (salary - 100000) *.1     
        elif salary <= 200000:     
            tax = 50000 * 0.02 + (50000) * 0.05 + 50000 * 0.1 + (salary - 150000) *.15
        else:
            tax = 50000 * 0.02 + (50000) * 0.05 + 50000 * 0.1 + 50000 *0.15 +(salary - 200000) *.25
        print(tax)    
INFO