r/learnpython • u/That_Rich_Guy • Mar 22 '23
What do you even code?
I am a beginner to python and all coding. I don't know much. All the recommendations are "code everyday". Practice every day is great but what do I practice? Do I open up an empty IDE and code what? I don't know how to do any projects on my own. Do I just YouTube crap and copy them or what? What do I actually code?
341
Upvotes
1
u/MikalMooni Mar 22 '23
The part you’re missing is abstraction. It’s the central pillar of programming; the thing that makes it all make sense. Programming is numbers, math and logic states. That’s all it is. Programming languages make it easier to implement and understand control flows (if this is true then do that; try this, do this if it succeeds and that if it fails…) and it can handle arithmetic very quickly.
Your job, as a programmer, is to take those limited tools and use them to represent a more complicated idea.
For example, let’s say you need to keep track of the food in your fridge, and all of it’s expiration dates. You could mark everything in a paper ledger by hand, but that takes a lot of time and you have to do it every single time.
You could make an excel sheet or something, but it probably won’t be able to tell you on it’s own what needs to go and when, plus you’d still have to manually fill out the various tables and cells.
The obvious solution is to write a program to do it all for you. Now, it’s up to you to decide how to do that. Depending on your programming language of choice, this could take any number of different forms, but I’ll stick to Java, since I know it.
First off, you would need to break down each item involved into it’s most basic representation. You’re trying to track items of food inside of a fridge, so you need a fridge object and you need food objects.
What are things that each and every food object have in common, no matter what they are, as long as they have to go inside of a fridge? They have an expiration date and they have a quantity (or a weight/volume remaining; this is different from saying, “I have two cartons of eggs”. That’s two objects. Each carton might originally carry twelve eggs, and you consume eggs from the carton over a period of time…)
They also probably have names, but assuming you buy a lot of the same things over and over again, you’d probably want to make objects to represent each individual food type, since you would want an easier way to create the food objects faster.
Now, the question becomes, “what can I do with the programming language of my choice to make managing the food in my fridge easier?”
You could approach this any number of ways, but the exact implementation is better left up to you.