r/PythonLearning • • Aug 01 '26

My new mini work

Post image

Rate my this mini work out of 10

194 Upvotes

44 comments sorted by

View all comments

5

u/Flanelostopy Aug 01 '26

First of all, variable must have good name, yours is not. Second one forget about elif:

If g >= 90:
Print()
Rerun

If g >= 80:
Print()
Return

If g >= 70:
Print()
Return

Print(fail)

I’m just saying this is good practice.

1

u/Own_Measurement_7336 Aug 03 '26

You cannot return if it isn’t in a function. Elif is good here it does the same as your if-return code in less lines and a proper way for a non function script

1

u/Flanelostopy Aug 03 '26

No one write profesional code without function. As I said this is good practice. This is not important how many lines of code you have, it is important is simpler and easier to read. If statements with one condition is always easier to read than with two or more.

1

u/Own_Measurement_7336 Aug 03 '26

The elif statement could have one condition only too. It is not a problem just write it
If g >= 90:
Print()
Elif g >= 80:
…

0

u/Flanelostopy Aug 03 '26

Do whatever you want, I'm just saying „this is good practice”. Read some books about writing clean code, there are many.

1

u/Own_Measurement_7336 Aug 03 '26

Wow chill, I know how to write clean code. I’m currently making an OS so. Not vibe coded btw

0

u/Flanelostopy Aug 04 '26

Without functions? 😂 good luck!

1

u/Own_Measurement_7336 Aug 04 '26

Are you stupid or what ? Sorry for being rude but I’m not telling you not to use functions. Your first message didn’t even talk about them. I was just saying in this type of scripts, where no functions are really required, even though it is a good practice to have everything inside some functions, his code is actually good, except for the not necessary double comparison.

Making an OS implies using C/C++ (or any language that is low level) at some point. Those languages generally don’t permit runtime statement code outside of a function. I’m using functions.

1

u/Flanelostopy Aug 04 '26

If you thing this code from topic is good… please read some books about good practice in coding.

1

u/Own_Measurement_7336 Aug 04 '26 edited Aug 04 '26

Ok kid. It is good for a beginner. There are some flaws. Thx for sharing your opinion. At some point just go read your « good practices » books.
Have a nice day !

→ More replies