Python Forum
Feedback on salary calculator.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Feedback on salary calculator.
#2
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


Messages In This Thread
Feedback on salary calculator. - by FloppyPoppy - Jan-09-2021, 05:28 PM
RE: Feedback on salary calculator. - by j.crater - Jan-31-2021, 09:18 AM

Forum Jump:

User Panel Messages

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