USE PYHTON ONLY. PLEASE SHOW PICK OF THE CODE The United States federal personal
ID: 644354 • Letter: U
Question
USE PYHTON ONLY. PLEASE SHOW PICK OF THE CODE
The United States federal personal income tax is calculated based on tiling status and taxable income. There are four filing statuses: single filers, married filing jointly, married filing separately, and head of household. The tax rates vary every year. Table 3.2 shows the races for 2009. If you are, say, single with a taxable income of $10,000, the first $8,350 is taxed at 10% and the other $1,650 is taxed at 15%. So. your tax is $1,082.5. You are to write a program to compute personal income tax. Your program should prompt the user to enter the tiling status and taxable income and compute the tax. Enter 0 for single filers, 1 for married filing jointly, 2 for married filing separately, and 3 for head of household. Here are sample runs of the program: Sample 1: Enter the filing status:0 Enter the taxable income:100000 Tax is 21720.0 Sample 2: Enter the filing status:1 Enter the taxable income:300339 Tax is 76932.87 Sample 3: Enter the tiling status:2 Enter the taxable income: 123500 Tax is 29665.5Explanation / Answer
Python Progarm:
import sys
# Prompt the user to enter filing status
status = eval(input(
"(0-single filer, 1-married jointly, " +
"2-married separately, 3-head of household) " +
"Enter the filing status: "))
# Prompt the user to enter taxable income
income = eval(input("Enter the taxable income: "))
# Compute tax
tax = 0
if status == 0: # Compute tax for single filers
if income <= 8350:
tax = income * 0.10
elif income <= 33950:
tax = 8350 * 0.10 + (income - 8350) * 0.15
elif income <= 82250:
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(income - 33950) * 0.25
elif income <= 171550:
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(82250 - 33950) * 0.25 + (income - 82250) * 0.28
elif income <= 372950:
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
(income - 171550) * 0.33
else:
tax = 8350 * 0.10 + (33950 - 8350) * 0.15 +
(82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 +
(372950 - 171550) * 0.33 + (income - 372950) * 0.35;
elif status == 1: # Compute tax for married file jointly
print("Left as exercise")
elif status == 2: # Compute tax for married separately
print("Left as exercise")
elif status == 3: # Compute tax for head of household
print("Left as exercise")
else:
print("Error: invalid status")
sys.exit()
# Display the result
print("Tax is", format(tax, ".2f"))
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.