income_tax(income) that computes tax using progressive brackets: 0% on the first 10,000, 10% on the portion from 10,000 to 40,000, 20% on the portion from 40,000 to 100,000, and 30% on anything above 100,000. Return the total tax owed as a number. For example, someone earning 50,000 pays 0 on the first 10,000, 10% of 30,000 (=3,000) on the next slice, and 20% of 10,000 (=2,000) on the remainder, totaling 5,000.income_tax(50000)
5000
0 + 3000 (10% of 30000) + 2000 (20% of 10000).
income_tax(5000)
0
Entirely within the 0% bracket.
income_tax(150000)
30000
0 + 3000 (10% of 30000) + 12000 (20% of 60000) + 15000 (30% of 50000) = 30000.
Use if/elif on which bracket the income falls into, then compute the tax for each slice below it.
Careful: each bracket only taxes the portion of income that falls within it, not the whole income.