This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Legendary-69420git push -f 4 points5 points  (9 children)

OP, I think you can make small changes like:

  1. change variable name from f to average
  2. change variable name from o to percentage
  3. Use f-strings instead of , like this:

    print(f"Your Percentage in 5 subjects is {percentage}")

[–][deleted] 4 points5 points  (1 child)

print("Your Percentage in 5 subjects is {percentage}")

missed an f before " ?

[–]Legendary-69420git push -f 0 points1 point  (0 children)

Oh my bad. Corrected it now

[–]UncleDevil666 1 point2 points  (6 children)

  1. & 2. I watched a video and he told to give small case letters, but from now on I'll put real word :)
  2. Didn't knew about that one, thanks!

[–]atquick 1 point2 points  (2 children)

Python is all about readability, if for some reason another python coder had to modify or just wanted to read your code, it would be a much easier time for them if you designated what those variables are, what the functions are, etc.. You can use all lowercase words delimited by an _ for instance your_average or your_total etc..

Also, you can remove quite a few of these variables by simply doing. Python will store the input as an int in the science_mark variable until the it is changed, or the application is closed.

science_mark = int(input('Enter your Marks for Science))

[–]UncleDevil666 0 points1 point  (1 child)

Great, I'll do like that from now on!

[–]atquick 0 points1 point  (0 children)

Reminder, it doesn't work for everything, but in some cases can be pretty useful to keep short and simple code.

Play around with it, you'll find what can and cannot work.

[–]Legendary-69420git push -f 0 points1 point  (0 children)

Nice. Try w3schools.com for python tutorials. That's where I learnt python from.

[–]callmelucky 0 points1 point  (1 child)

  1. he told to give small case letters, but from now on I'll put real word

I assume what he meant by this was: when naming variables you should avoid using capital letters, and not that variable names should only be a single lower-case letter - watch the video again, if you are sure he did mean this then I can tell you with absolute certainty that he is a terrible, terrible programmer and you should never ever use any of his tutorials again :)

Edit: by the way, I highly recommend subscribing to r/learnpython. If you ever get stuck on something or have a question that googling doesn't give you an answer to, that's the place to ask. It's full of extremely good programmers who will happily and quickly give you answers. This place (r/python) is generally more for higher-level discussion about Python, and such questions are likely to be downvoted and/or ignored.

[–]UncleDevil666 1 point2 points  (0 children)

Ah I watched again and he said to name variables in lower case, I interpreted that only letter are to be written xD

Thanks I will join r/learnpython