My question is regarding one programming challenge I created for myself for learning purposes. I'm IT business student.
So, I should be creating a program where user puts yearly income as an input and the income taxation rate would scale according to percentage thresholds (see picture at the end of this post for income range vs. percentage thresholds). For example from 100,000 euro income 50% would be paid from income exceeding 60001 (as according in the table below). 40% betweeen 45000-60000, 20% between 15000-30000 and 10% between 0-10000. Equation should go something like 0.5* 40 000 + 0.4 * 150 00 + 0.3 * 15 000 + 0.2 * 15 000 + 0.1 * 10000 = 35 000.
Outputs should be something like: Give your yearly income: 100000 You pay taxes 35000.0 euro. Your taxation percent is: 35.0 %. Give your yearly income: 54000 You pay taxes 12600.0 euroa. Your taxation percent is: 23.333333333333332 %.
This is what I've tried:
yearly = int(input("Tell your yearly income:"))
one = 0.1
two = 0.2
three = 0.3
four = 0.4
five = 0.5
if yearly in range(1,15000):
print("You pay taxes in total:",yearly*one)
if yearly in range(15001,30000):
print("You pay taxes in total:",yearly*two)
if yearly in range(30001,45000):
print("You pay taxes in total:",yearly*three)
if yearly in range(45001,60000):
print("You pay taxes in total:",yearly*four)
if yearly > 60000:
print("You pay taxes in total:",yearly*five)
The taxation percent doesn't scale like I'd like it to. I assumption is that this should get done by elif and range functions. Maybe min and max values of percentages would help, but I don't know how to turn outputs into percentages. Please note that I might have some comprehension problems here, math is not my strongest gamem but I did my absolute best to describe the problem...
Here is a table of income count vs. taxation percentage used. Income vs. taxation percentage
Aucun commentaire:
Enregistrer un commentaire