Wednesday, February 5, 2025

Pythone code to calculate tax for annual salary

  
#define a function 
def tax_salary(salary):
    if salary < 5e5:
        tax= 0.01*5e5
    elif salary <7e5:
        tax = 0.01*5e5 + (salary-5e5)*0.02
    elif salary < 10e5:
        tax =0.01*5e5 + 2e5*0.02+ (salary-7e5)*0.1
    else:
        tax = 0.01*5e5 + 2e5*0.02+ 3e5*0.1+ (salary-10e5)*0.02
    return tax
#Example
salary = 75e4
tax = tax_salary(salary)
print(f'For annual salary of {salary}, the tax is {tax}')

No comments:

Post a Comment