Python Forum
Looking for critique on my code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looking for critique on my code
#9
(May-02-2017, 04:57 PM)zeevo234 Wrote:
.......
    CanCalc=True
  • It is customary to surround operators with single space
  • Pythonic variable names are snake-style - can_calc
(May-02-2017, 04:57 PM)zeevo234 Wrote:
    print("Enter the corresponding values of the standard quadratic function: y=ax^2+bx+c")
    a=input("Enter the A value:")
........
Use lsit instead of individual variables - it makes you code shorter and scalable, e.g. - if you wanted to make cubic instead of quadratic equation, just enlarge you list
(May-02-2017, 04:57 PM)zeevo234 Wrote:
    if((a!=0)&(CanCalc==True)):
  • Never compare to boolean directly if CanCalc does the job
  • Brackets are not necessary - matter of taste, but why write redundant symbols?
  • & is bitwise and - it will work, but stick to boolean counterpart, less chances to get in trouble
 
There's more stuff, but I will take a break, In the meantime, please read PEP-8
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply


Messages In This Thread
Looking for critique on my code - by zeevo234 - May-02-2017, 04:39 PM
RE: Looking for critique on my code - by nilamo - May-02-2017, 04:39 PM
RE: Looking for critique on my code - by zeevo234 - May-02-2017, 04:42 PM
RE: Looking for critique on my code - by nilamo - May-02-2017, 04:45 PM
RE: Looking for critique on my code - by buran - May-02-2017, 04:47 PM
RE: Looking for critique on my code - by zeevo234 - May-02-2017, 04:57 PM
RE: Looking for critique on my code - by volcano63 - May-02-2017, 05:19 PM
RE: Looking for critique on my code - by nilamo - May-02-2017, 05:13 PM
RE: Looking for critique on my code - by zeevo234 - May-02-2017, 05:18 PM
RE: Looking for critique on my code - by zeevo234 - May-02-2017, 05:21 PM
RE: Looking for critique on my code - by nilamo - May-03-2017, 04:29 PM
Need help figuring out prod - by zeevo234 - May-03-2017, 04:13 PM

Forum Jump:

User Panel Messages

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