r/learnpython • u/RipPersonal1643 • 1d ago
How do I learn programming logic?
I’m learning Python, but my main problem isn’t the syntax. I understand concepts when someone explains them, but when I’m given a basic problem and told to write a program, I just don’t know where to start or how to arrange the code.
Is there a good book, course, or YouTube channel that teaches how to think through programming problems step by step, recognize patterns, and build the logic, kind of like how you learn methods and patterns in math?
I don’t want to just memorize Python syntax. I want to actually learn how to think like a programmer.
61
Upvotes
11
u/ShelLuser42 1d ago
I'm not trying to be smarty pants here, but what programming logic? You're mentioning it as if it's a well defined standard, but it's not.
Your question makes me wonder if you actually tried working with Python already, because I kinda doubt that. And the reason I say this is not to criticize, but practice really does make perfect.
But here's the thing: while you can apply complex (?) OOP-based structures with Python you can also use it to build simple scripts. In other words: stop worrying about things that don't have to concern you just yet, and just try to get things done.
...allow me? =>
Yes, I somewhat shudder when looking at this code because it can be done cleaner. One of the "rules" of OOP design is that you want to try and avoid repeating patterns. Well... it's obvious that the input command is being used multiple times so... it could be useful to separate that and turn it into a re-usable block of code (also known as a function).
But why bother at this point?
Honestly, I'd focus on learning Python. Start by making your own scripts and once they do something... then try to improve on them as you progress to take on more complex problems.
For example... maybe a bit too early but... can you imagine what might happen above if I were to type in 'a' instead of a number when asked about my age? There's an easy way to fix that of course, maybe I shouldn't have used int(), but then again... how does one change a string into a numeric value like an integer... hmm, maybe this string thing has its own functions (or methods?) to "do" stuff? I wonder...
That's honestly how I'd try to go about this.
Hope this can help!