##### Feedback on salary calculator.
 Feedback on salary calculator. FloppyPoppy Unladen Swallow Posts: 4 Threads: 2 Joined: Mar 2019 Reputation: Jan-09-2021, 05:28 PM Hi all looking for any feedback for my little calculator that I made this morning. A couple of us are looking at taking some weekend work to boost our income but couldn’t find an calculator for two incomes so decided to make one following the local governments guidelines for tax/wages/national insurance this was done entirely on a phone so hopefully the formatting isn’t too bad! ``` #Author Harry O'Neill Job_One_Income = float(input("What is the hourly rate of your first income? :")) Job_One_Hours = float(input("How many hours are you paid for working in your first job per week? :")) Job_One_Yearly_Income = float(round(Job_One_Income * Job_One_Hours * 52,2)) Job_Two_Income = float(input("What is the hourly rate of your second income? :")) Job_Two_Hours = float(input("How many hours are you paid for working in your second job per week? :")) Job_Two_Yearly_Income = float(round(Job_Two_Income * Job_Two_Hours * 52, 2)) National_Insurance = 12 # 12% after £183 Tax_Limit = 37000 Tax_Allowance = 12500 Yearly_Income = Job_One_Yearly_Income + Job_Two_Yearly_Income Weekly_Income = Yearly_Income / 52 Weekly_NI =((Weekly_Income - 183) * 0.12) Yearly_Taxable_Income = Job_One_Yearly_Income + Job_Two_Yearly_Income - Tax_Allowance Weekly_Taxable_Income = Yearly_Taxable_Income / 52 if Yearly_Taxable_Income <= (Tax_Limit + Tax_Allowance): Weekly_Tax = (Weekly_Taxable_Income * 0.20) else: Weekly_Tax = (Weekly_Taxable_Income * 0.40) Yearly_Tax = round(Weekly_Tax * 52,2) Weekly_Take_Home = round(Weekly_Income - Weekly_NI - Weekly_Tax,2) Yearly_Take_Home = round(Weekly_Take_Home * 52,2) Monthly_Take_Home = round(Yearly_Take_Home / 12,2) print("\n") print(f"Yearly Income : £{Yearly_Take_Home} \n") print(f"Monthly Income : £{Monthly_Take_Home}\n") print(f"Weekly Income : £{Weekly_Take_Home}\n") if Yearly_Income <=(Tax_Limit + Tax_Allowance): print(f"your income is within the lower tax bracket and you will be taxed £{Yearly_Tax} per year ") else: print(f"You are earning above the tax limit and will be taxed highly at £{Yearly_Tax} per year")```What do you think to this? Would you have done anything differently? Looking to improve my python hence my posting today. Reply Posts: 1,152 Threads: 42 Joined: Sep 2016 Reputation: Jan-31-2021, 09:18 AM Hello, it looks pretty good to me. ```National_Insurance = 12 # 12% after £183 Tax_Limit = 37000 Tax_Allowance = 12500```Usually constants are found in the beginning of code (and after imports, if there would be any, but not in your case). ```Yearly_Tax = round(Weekly_Tax * 52,2) Weekly_Take_Home = round(Weekly_Income - Weekly_NI - Weekly_Tax,2) Yearly_Take_Home = round(Weekly_Take_Home * 52,2) Monthly_Take_Home = round(Yearly_Take_Home / 12,2)```I would not leave any blank lines between these statements, but that is up to your preference. ```Monthly_Take_Home = round(Yearly_Take_Home / 12,2) Monthly_Take_Home = round(Yearly_Take_Home / 12, 2) # a whitespace after comma```Also in cases like this, a whitespace after comma is recommended. Otherwise, pretty good! You can try to open the file in a code editor and select code formatting option to do an automatic check for you. Or run a PEP8 check on the code. It seems like online checkers exist too, I wasn't aware of that before: http://pep8online.com/ Reply

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020