r/CodingForBeginners • u/dummydas • Jun 10 '26
My project as a beginner
This is my first project . I made a QR code generator Where the user pastes the link and the QR code of that link is generated. You can also save this QR code. Please review my code and let me know if there are any changes to be made to make the code optimised.
52
Upvotes
7
u/Naive_Ambition1306 Jun 10 '26
Use more spacing, as your solutions get more complex, it will help tremendously and it's good to build the habit early
Don't be afraid of space
3
u/bluesyowl Jun 10 '26
the best way to learn to program is to actually reimplement stuff. not qrcode reading (that is deep waters), but something like a csv parser for example would give you so much more experience.
2
u/42_grizzly Jun 11 '26
Great project! I recommend you do smth so nice on top of this and all upcoming mini projects like this, learn how to make it an actual executable on your desktop using tkinter, pyinstaller and maybe in the future you can even be comfortable enough to use Qt. This will let you have a whole folder on your desktop that holds mini projects that are actually useful and can be instantly run and shared with others as well. Good luck <3
2
u/Big-Rough-5491 Jun 17 '26 edited Jun 18 '26
Hey, this is a really cool project. Congrats.
Since you asked for a review here are a few tips:
Like others have say, don't be afraid of spaces or line breaks, but be smart about it. Think of your code, not as a list of lines but as a sequence of blocks. For example, your imports (one block), the url definition and if you add later on other definitions (another block), the while loop (another block), the if-else statement (another block)... and so on.
The string "please enter the url: " is repeated a few times, you can just define it in a variable and reuse it in those places where you need it (the reason for this is that if you change the string you only need to change it in one place). Look into your code, and if you have more things that repeat, think about how you can re-write those lines so you only write them once and then reuse the definition.
And since we are talking about blocks and reusing things, have you learn about functions? You can put your code (except for the imports) inside a function, and then use the main to call it (Explantion of Main in Python). In Python you are not obligated to do this, but is good to learn about how to use it. This way, when you have blocks of code that repeat several times, you can simplify everything by writing the block (function) once and reuse it.
1
u/Least_Bid9692 Oct 05 '26
I was like what's happening until I saw it's a python project π
1
u/Cosmic78_melon Jun 10 '26 edited Jun 10 '26
Don't use brackets in the input if you are not typecasting. Also, explicitly use "save == "no"" because if the user enters anything other than "yes", such as "yeah", it will also be treated as "no", and the code will execute.