In: Computer Science
There are two types of taxes: Federal tax and province tax.
1.Federal taxes: Assume that the share of income $35,000 and below is federally taxed at 15%, the share
of income between $35,000 and $100,000 is taxed at 25%, and the share of income over $100,000 is taxed at 35%.
(i.e an income over$ 100,000 is taxed as follows:
-The portion of income up to and including the first $35,000 is federally taxed at 15%.
-The portion of income between $35,001 and $100,000, inclusive, is federally taxed at 25%.
-The income earned beyond $100,000 is federally taxed at 35%
Province taxes: Assume that there is no provincial income tax for income up to $50,000 but is a flat 5% for all income above $50,000.
Write 2 functions to calculate total tax liability for any income.
•Function fed_tax that takes one parameter income as an input and return a number that represents the calculated federal tax.
•function prov_tax that one parameter income as input and return a number that represents the calculated province tax.
Write a testing program named t03.py that tests the functions by asking the user to enter an income
and displays the calculated taxes.
A sample run:
Enter your income: $200000
Federal tax: $56500.00
Provincial tax: $ 7500.00
Total tax: $64000.00
Please comment, if you need any corrections.Please give a Thumps up if you like the answer.
Program
def fed_tax(income):
if(income<35000):
federal_tax=.15*income
elif(income<100000 and income>35000):
federal_tax=(.15*35000)+(.25*(income-35000))
elif(income>100000):
federal_tax=(.15*35000)+(.25*(100000-35000))+.35*(income-100000)
return federal_tax
def prov_tax(income):
if(income>50000):
province_tax=.05*(income-50000)
return province_tax
def main():
income=float(input("Enter your income: $"))
federal_tax=fed_tax(income)
print("Federal Tax: ${:5.2f}" .format(federal_tax))
province_tax=prov_tax(income)
print("Province Tax: ${:5.2f}" .format(province_tax))
total_tax=federal_tax+province_tax
print("Total Tax: ${:5.2f}" .format(total_tax))
main()
Output
Enter your income: $200000
Federal Tax: $56500.00
Province Tax: $7500.00
Total Tax: $64000.00
Program Screenshot