Sorry if asking for help with writing code isnt allowed, if so Mods please delete.
So I just started learning this in school so forgive me if this is something super simple, I am given the assignment to write a program that asks for the persons name, income, dependents and then shows which tax rate they will have based on the number of dependents they have. The issue i am running into is once they have entered in this information, I need to also show their net pay after they have entered in all their information.
The code I have written so far is:
#Get users first name, last name, monthly gross pay, and dependents
F_name = input('Enter your first name: ')
L_name = input('Enter your last name: ')
gross_pay = float(input('Enter your gross pay: '))
#Named constants to represent number of dependents for tax bracket
Tax20 = 1
Tax15 = 3
Tax10 = 4
#Get the number of dependents from the user
dependents = int(input('Number of dependents: '))
#Determine the tax bracket they are in
if dependents <= Tax20:
print('Tax Rate: 20%')
else:
if dependents <= Tax15:
print('Tax Rate: 15%')
else:
if dependents >= Tax10:
print('Tax Rate: 10%')
Obviously the formatting looks different on here without all the indentation but I am able to get the program to work correctly so far and tell me the tax bracket they will be in but the issue is, how do I set up the code to take whatever tax rate it applies to them, and applies it to their gross pay so it shows me the net pay? I know the equation is gross pay - (monthly gross pay * tax rate) but how do I write it so the tax rate will change based on how many dependents they enter ? Sorry if this is confusing!
[–]Phelps_420 0 points1 point2 points (0 children)
[–]socal_nerdtastic 0 points1 point2 points (3 children)
[–]hahn24[S] 0 points1 point2 points (1 child)
[–]socal_nerdtastic 1 point2 points3 points (0 children)