tax = income_tax(income=45000)
effective = tax / 45000
tax, effective(3220.0, 0.07155555555555555)
Taxes are the biggest bill most people pay, and two questions come up again and again. How much federal income tax do you owe on your salary? And how much of a raise do you keep once a higher bracket takes its share? The Taxes chapter of the book answers both by slicing income into brackets. In this page I’ll answer the same questions with income_tax() and raise_kept(), using the chapter’s numbers so you can check every result against the book.
Both functions take single numbers only (see the conventions table in Get started). To compare several incomes, loop over them; the Variations section shows how.
| Function | Returns | Units |
|---|---|---|
| income_tax() | 2026 federal income tax for a single filer | dollars per year |
| raise_kept() | the part of a raise left after federal income tax | dollars per year |
The chapter’s example is a $45,000 salary for a single filer in 2026. The question is the federal income tax bill, and what share of the salary it takes.
Think of the salary as one long bar. The first $16,100 is covered by the standard deduction and isn’t taxed. The next $12,400 is taxed at 10%. The last $16,500 is taxed at 12%:

income_tax() subtracts the deduction, multiplies each slice by its own rate, and adds up the slices:
The tax is $3,220, an effective rate of 7.2%. That is well below 12%, the marginal rate on this salary’s last dollar. The effective rate is a decimal here because we divided it ourselves; income_tax() returns dollars, not a rate.
Now imagine you earn $66,000 and get a $2,000 raise. Taxable income goes from $49,900 to $51,900, which crosses the 22% line at $50,400. The fear is that the higher bracket eats the raise.
The bar below is just the raise. The first $500 fills the rest of the 12% bracket, and only the last $1,500 is taxed at 22%:

raise_kept() takes the tax on the new income, subtracts the tax on the old income, and takes that difference out of the raise:
kept = raise_kept(old_income=66000, raise_amount=2000)
extra_tax = income_tax(income=68000) - income_tax(income=66000)
kept, extra_tax(1610.0, 390.0)
You keep $1,610 of the $2,000 raise, and the extra tax is $390. Crossing into a higher bracket never makes a raise cost you money; only the dollars above the line pay the higher rate.
raise_kept() doesn’t have its own bracket table. It calls income_tax() twice, once on the new income and once on the old income, and subtracts the two results. The tree below shows that relationship:
raise_kept()
├── income_tax(old_income + raise_amount)
└── income_tax(old_income)
Any change to the brackets in income_tax() flows straight into raise_kept().
Because both functions take single numbers, a list comprehension compares several salaries. The table below puts the tax and the effective rate side by side:
incomes = [30000, 45000, 66000, 100000, 150000]
taxes = [income_tax(income=i) for i in incomes]
pl.DataFrame({
"income": incomes,
"tax": taxes,
"effective_rate": [t / i for t, i in zip(taxes, incomes)],
})| income | tax | effective_rate |
|---|---|---|
| i64 | f64 | f64 |
| 30000 | 1420.0 | 0.047333 |
| 45000 | 3220.0 | 0.071556 |
| 66000 | 5740.0 | 0.08697 |
| 100000 | 13170.0 | 0.1317 |
| 150000 | 24734.0 | 0.164893 |
The effective rate climbs with income, but it stays below each salary’s top bracket. The same pattern works for raises. Here is a $2,000 raise at each salary:
pl.DataFrame({
"income": incomes,
"kept": [raise_kept(old_income=i, raise_amount=2000) for i in incomes],
})| income | kept |
|---|---|
| i64 | f64 |
| 30000 | 1760.0 |
| 45000 | 1760.0 |
| 66000 | 1610.0 |
| 100000 | 1560.0 |
| 150000 | 1520.0 |
income_tax() hard codes the 2026 federal brackets for a single filer and a $16,100 standard deduction. A few other limits apply:
deduction (for example, itemized deductions), but not different brackets.ValueError; text raises a TypeError.Back to the $45,000 salary. Federal income tax is only part of what comes out of the paycheck. FICA (Social Security and Medicare) takes 7.65% of every dollar, with no deduction. percent_of_income() from the Budgeting page shows how much of the salary the two together claim:
salary = 45000
fica = salary * 0.0765
federal = income_tax(income=salary)
total = fica + federal
total_share = percent_of_income(expense=total, income=salary)
fica, federal, total_share(3442.5, 3220.0, 14.805555555555555)
FICA takes $3,442.50 and federal income tax takes $3,220. Together they claim 14.8% of the salary, before any state tax.
Next, a $2,000 raise on the same salary. All of it stays in the 12% bracket, so you keep a little more than in the $66,000 example:
This number is before FICA, which takes another 7.65% of the raise.
Tax brackets apply to slices of income, not the whole salary. income_tax() adds up the tax on each slice, and dividing by income gives the effective rate. raise_kept() calls income_tax() twice to show that a raise always leaves you with more money.