Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON CODE NEED HELP WITH THE FOLLOWING CODE: Write a program to compute tax using the table given below: For example, from the taxable income

PYTHON CODE NEED HELP WITH THE FOLLOWING CODE:

Write a program to compute tax using the table given below:

image text in transcribed

For example, from the taxable income of $400,000 for a single filer, $8,350 is taxed at 10%, (33,950 8,350) at 15%, (82,250 33,950) at 25%, (171,550 82,250) at 28%, (372,950 171,550) at 33%, and (400,000 372,950) at 35%. The six rates are the same for all filing statuses, which can be represented in the following list:

rates = [0.10, 0.15, 0.25, 0.28, 0.33, 0.35]

The brackets for each rate for all the filing statuses can be represented in a two dimensional list as follows:

image text in transcribed

image text in transcribed

**************************************************************************

limitsSingle = [0, 8350, 33950, 82250, 171550, 372950] limitsJoint = [0, 16700, 67900, 137050, 208850, 372950] limitsSeparate = [0, 8350, 33950, 68525, 104425, 186475] limitsHead = [0, 11950, 45500, 117450, 190200, 372950]

def calculateTax(limitArray, income): limitArray.append(income) rates = [0.10, 0.15, 0.25, 0.28, 0.33, 0.35] tax = 0 for i in range(1, len(rates) + 1): if income > limitArray[i]: tax = tax + (limitArray[i] - limitArray[i - 1]) * rates[i - 1] else: tax = tax + (income - limitArray[i - 1]) * rates[i - 1]

return tax

taxableIncome = input('Enter the taxable income: ') category = input('Enter 1 for Single, 2 for Married Jointly, 3 for Married Separately, 4 for Head of Househond: ')

if category == 1: tax = calculateTax(limitsSingle, taxableIncome) if category == 2: tax = calculateTax(limitsJoint, taxableIncome) if category == 3: tax = calculateTax(limitsSeparate, taxableIncome) if category == 4: tax = calculateTax(limitsHead, taxableIncome) print('The tax is: ' + str(tax))

main()

Marginal Single Married Filing Jointly Married Filing Separately Head of Household Tax Rate $0-$8,350 $0-$16,700 $0-$8,350 S0 -$11,950 10% $11,951-$45,500 $8,351-$33,950 $16,701 $67,900 $8,351-$33,950 15% s33,951-$68,525 $33,951 $82,250 $67,901 $137,050 $45,501 $117,450 25% 28% $82,251 -$171,550 $137,051 $208,850 $68,526 $104,425 $117,451 -$190,200 33% $171,551 $372,950 $208,851-$372,950 $104,426-$186,475 $190,201 -$372,950 $372,951+ $372,951+. 35% $186,476+ S372,951+

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions