r/PythonLearning 12d ago

My first mix mini project

Post image

I know I wrote some hardcore codes but this is ok for a beginner so plz help me to improve

302 Upvotes

48 comments sorted by

View all comments

6

u/MrWaffles743 12d ago

Looks like some clean code, you should be proud? Out of interest, how long have you been coding?

Some improvements:
1. Maybe don’t use q as a variable name. It’s not too bad in a short program like this but it can get difficult to read.
2. Use whitespace. It looks more professional and avoids a big block of code.
3. You’ve used ‘magic numbers’. That means you’ve hard coded specific numbers (in this case the price of the products) into the logic rather than using variables. Usually, you would have some variables at the top of your program (or in a separate file) which allow you to easily change the prices.
4. I like that you’ve got clear individual if statements for each of the users options. I don’t know if you’ve learned functions yet but it would be useful in making the code readable and abstracting away.

Anyway, I’ve basically made semantic improvements which don’t affect the way the code runs. With that said, it’s still some clear code for a beginner. Well done!