Lab 3: Functions and Selection Statements
Logistics
- Due: Tuesday, September 12th no later than 11:59 p.m.
- Partner Information: Complete this assignment individually.
- Submission Instructions: Upload your solution, renamed to
YourFirstName-YourLastName-Lab3.py to the BrightSpace Lab 3
Dropbox.
- Deadline Reminder: Once this deadline passes, BrightSpace will no
longer accept your Python submission and you will no longer
be able to earn credit. Thus, if you are not able to fully complete
the assignment, submit whatever you have before the deadline so that
partial credit can be earned.
Learning Outcomes
- Gain experience writing a Python function.
- Gain experience writing Python selection statements.
Assignment
- Download lab3.py and rename
it according to the instructions above.
- Modify the program by adding the missing function. The
missing function will use Python selection statements
to calculate the amount of tax that a single (unmarried)
taxpayer owes using the table below. If the missing function
is implemented correctly, this output
will appear. Make sure your solution is general and works
for any taxable income.
Note: the federal tax is progressive. For example, if a person has
a taxable income of $15,000, the first $11,000 is taxed at a rate of 10% and
the remaining $4,000 is taxed at a rate of 12%.
Rate |
For Unmarried Individuals, Taxable Income Over |
10% |
$0 |
12% |
$11,000 |
22% |
$44,725 |
24% |
$95,375 |
32% |
$182,100 |
35% |
$231,250 |
37% |
$578,125 |
Grading - 10 points
- 7 points - Your program calculates the income tax for each
of seven test cases correctly (1 point each). The test
cases might or might not be the ones that appear in the
starting code above.
- 3 points - A function with the correct name (1 point), correct
parameters (1 point) and correct return value (1 point) is
used in the solution.
Test Data
def main():
process(10000) # test case 1
process(33333) # test case 2
process(65000) # test case 3
process(150000) # test case 4
process(222222) # test case 5
process(500000) # test case 6
process(1000000) # test case 7
Expected Output for Test Data
The 2023 taxable income is $10000.00
An unmarried individual owes $1000.00
The 2023 taxable income is $33333.00
An unmarried individual owes $3779.96
The 2023 taxable income is $65000.00
An unmarried individual owes $9607.50
The 2023 taxable income is $150000.00
An unmarried individual owes $29400.00
The 2023 taxable income is $222222.00
An unmarried individual owes $49943.04
The 2023 taxable income is $500000.00
An unmarried individual owes $146894.50
The 2023 taxable income is $1000000.00
An unmarried individual owes $330332.00
If Time Remains
If you want to work with a partner on Program 1 (due 9/15), use
this time to identify a partner or ask your lab TA to help you find
someone. Note: For the vast majority of computing jobs and internships,
the ability to work with one or more teammates is a crucial skill!