DEV Community

Isaac
Isaac

Posted on

Tax Calculator

We are going to make a simple program to calculate two different taxes based on the user's income. We are going to call this tax PIB.
First we set the variable for the yearly income that is going to cut between the two taxes:

citincut=85528
Enter fullscreen mode Exit fullscreen mode

Second we define our variables for the two different tax operations base on the user's input:

print("Best rewards loyal citizen, today its time to contribute your Personal Income Tax for the Kingdom of Thalia.")
citinput=float(input("Introduce Year Income:"))
citix=citinput-citincut
Enter fullscreen mode Exit fullscreen mode

We set the logic operation for the two different taxes.
As you can see for the people with a lower income than 85528 we are going to apply a tax of the 18% of the income minus 556.2:

if (citinput<=citincut):
    tax=citinput*18/100-556.2
    print(round(tax),"Is your annual PIT, thank you loyal citizen.\n")
Enter fullscreen mode Exit fullscreen mode

To avoid having a negative tax we introduce a if statement:

    if (tax<=0):
        print("Move Punk") 
Enter fullscreen mode Exit fullscreen mode

For the people with a higher income we are going to set a tax of 14839.2 plus 32% of the surplus over 85528:

elif (citinput>=citincut):
    tax=citinput-(14839.2+(citix*32/100))
    print(round(tax),"Is your annual PIT, Hail Thalia!\n")
Enter fullscreen mode Exit fullscreen mode

You can change the value of the variable and use it for your own purposes.

Top comments (1)

Collapse
 
ijosbuttler profile image
jacobhales

Thanks for sharing. Gonna try it for my calculadoradeiva blog.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.