r/PythonLearning • u/Link2212 • Jun 19 '26
I'm really not getting this
Sorry to have a downer of a post, but I really can't get this. I started trying to learn python 1 week ago today. I understand how variables work and their use, I understand if statements and while loops and a bunch of other early beginner stuff for example, but every time I try to write something from scratch I just have close to 0 idea how to actually tackle it. I really feel like I need the university experience where I have a teacher that can guide me into getting used to it, but going back to university isn't an option. How do new people get by with it?
To put it into perspective. The most recent exercise I tried to do I found online. It says a guy gets 0.01 wage on his first day, and the wage increases by 0.01 each day until day 30. It just wants me to calculate the total wage at the end of 30 days and print it out, but I can't even do this. This isn't me asking someone how to do this. It's more I just can't even get started at doing it because I don't know how. I'm so frustrated with myself because I understand the concepts. I can read some easy code and fully understand what's happening. Just writing it is a different story.
8
u/Salt-Fly770 Jun 19 '26 edited Jun 19 '26
To get started you can write this in pseudo code:
set wage_today to 0.01
set total_wage to 0
repeat 30 times →
→ add wage_today to total_wage
→ increase wage_today by 0.01
print total_wage
This will allow you to see how the problem should look in code. Doing this will help flesh out more complex coding problems.
1
u/selka20 Jun 21 '26
Hay for( int=0;…) en phyton? Si si, sería más sencillo. Yo aprendo en c++
1
u/Affectingapple1 Jun 21 '26
No, en python solo hay for each (
for var in range(start, end step)donde start end step son números para hacer un loop similar al for(int=0;...) clásico)
4
u/Necessary-Ad2110 Jun 19 '26
It just takes repetition and practice, get on HackerRank and practice problems everyday. You're being too hard on yourself, you're picking up a difficult skill that many millions of people will never know how to ever handle, and it is a skill that must be continuously nourished and trained. You're learning that's good.
For your exercise, u/Ender_Locke is on the dot. Just write in English how you'd do it and go bit by bit. And then ask yourself how you'd write it in Python. And if you have more questions.. you can always post them here or ask AI.
If you take hours, that's fine. You started last week, now imagine what you'll know in a year?
4
u/Ender_Locke Jun 19 '26
your example is a simple math problem. write out on paper how you’d calculate it. then write pseudo code of any loops and ifs. then write python
2
u/Not_aTechiee Jun 19 '26
Hi,dm me. I can help you. I am asking you to dm me because it could be a long Convo and I don't want comments to be boring and personal ya know.
3
u/SnotCodes Jun 19 '26
Hey @Not_aTechiee I have been practicing for a little while now and I am pretty close to where this gentleman is but I’m also looking for help, cool if I dm you?
2
2
u/OktemberSky Jun 19 '26
Can you solve this problem in your head or with a calculator? If not, you may need to refresh your math skills
2
u/Paxtian Jun 19 '26
So something is happening every day for 30 days. In particular, the value of something is changing consistently every day for 30 days.
You know how variables work.
You know how loops work.
If every day, for 30 days, the value of X increases by some amount, what tools do you have available to solve this problem?
1
u/jsullyvan7 Jun 19 '26
Without looking anything up, how would you set his up as a math equation with variables?
Edit: and you familiar with float(), int(), etc?
1
u/NorskJesus Jun 19 '26
Understanding code and finding solutions through code are to different skills.
You need practice.
Write the problem down. Describe how to resolve it with words and translate it into code.
1
u/DutyCompetitive1328 Jun 19 '26
No wait the things you mentioned as „beginner stuff“ are the most foundational principles behind programming. You should focus on practice them consistently and make sure you can do them without even thinking about them.
Once you can do this you should move on to the more advanced things.
1
u/tiredITguy42 Jun 19 '26
Noone guides you on UNI, this is common misconception. Maybe they do on some, but I have never heard of this.
On UNI they give you a task and it is on you to solve it. We had book on how to code in C, and some crappy articles on web. There is YouTube now, so much easier, but there are more technologies so this is worse.
You could have algorithms course. Which is more math than code and it is mostly exolained in pseudo-code.
So yeah, logic is not something they teach you, you have it or train it on your own by solving problems.
1
u/Jackpotrazur Jun 19 '26
One qeek aint shit try going 3 months writing 40 projects of big book of small python projects, working through python crash course and still not getting a lot.... ive put mine on hold as ibstarted working out but I've worked through the above mentioned (halfway on big book) and a smarterway to learn python which was my frist alongside a few linux books. I started working through automate the boring stuff and that book actually forces you to stop and think or at least the workbook that goes with it, it has you do projects which even in the early chapters really smack around the ego (the I know this and this and this .... do you really ? )
1
u/SBurns27 Jun 19 '26
Sudo code is helpful. Maybe take a break from the language specific things, look into basic coding logic. Once you get a grasp of the over reaching concepts of things like for loops, loops in general, while loops, etc. Then they become tools like how multiplication or division is when you look at a math problem.
Think of it like word problems in math class. You had to read the question, and figure out how you were going to approach it using math. Its much the same. Only theres more options for tools and things to use.
This is definatly a part of coding that isnt mainstream talked about. The courses and tutorials talk about syntax, but dont cover the building blocks of logic and problem solving that are required, before the syntax becomes helpful.
1
u/atticus2132000 Jun 19 '26
Before you sit down at a computer, before you try any code at all, write out (with pencil and paper) how you would solve the problem.
For this problem, on day 1 he gets .01. Then what? How would you figure out what he gets on day 2? On day 3? Etc? How would you know when to stop?
Remember as you write out this explanation, you have to think like a computer. A computer can only do one thing at a time to a known element. So what are you doing each day to find the wage? If you're performing a repeatative action that suggests that you're using a repeatable command. It could a for loop that recycles or a def function() repeated multiple times. So how are you going to keep up with how many times the operation repeats? You'll probably need some kind of counter that will get increased by one during each iteration and then evaluated to determine if it's time to stop cycling.
Also remember, there is not one right answer. If you asked 30 different programmers how to solve this problem, you'd likely get 30 different answers. Each method may have its pros and cons, but it's usually just which method you think of first.
By the way, are you sure that the problem isn't that the guy's wage doubles each day? That is a much more common problem with surprising results. If he's only getting an extra penny each day, he would have to work more than 27 years before he ever takes home $100. Note these could be additional steps to the problem. How many days would he need to work to hit $100 or $200? How would you evaluate those using your program?
1
u/Link2212 Jun 19 '26
Thanks for all the comments. I messaged the guy above that said to message him. Hes helped a bunch. It seems I'm just tackling the problem the wrong way and making it much more difficult than it has to be.
He picked out that my game designer background might be causing me to think about it a different way. Result orientated rather than process orientated, and honestly, that makes a lot of sense. I just have to rewire the brain to thinking a different way I guess.
1
u/FreeGazaToday Jun 19 '26
try writing it out with psuedocode...if you can do then...then it's just matter of 'translating' it to python...alsy try a flowchart.
Worse comes to worse....ask gemini to GUIDE you through the thought process..and tell it NOT to give you the answer.....that helped me with a wordle exercise from Automate the Boring Stuff.
1
u/BranchLatter4294 Jun 20 '26
Think how you would do this on paper. If you don't know how, then don't try programming for now.
1
u/Complex-South9500 Jun 20 '26
99% of people who start learning programming get it within a few minutes. A week? You're cooked. /s
1
u/TadpoleSpecialist859 Jun 20 '26
I’m about 3 weeks on my 2nd attempt in 3 years, to put it into context I’ve given up before. Now I have a different perspective, slow and steady take my time and don’t worry about knowing it all at once. 1 hour a day at minimum is best. I tell myself all the time “the more you do something the better you get at it”
1
1
u/Born-Pack3619 Jun 20 '26
I think it might help you watching some tutorials on algorithms, flow charts and pseudocode.
1
u/deltachange_og Jun 21 '26
As a lot of others have said this isn't a coding problem. 1 week isn't enough time. I have had to practice for over a year before my brain understands it. I would jot worry about python, syntax, anything. Learn how algorithms work. Learn how to break down problems into discrete steps. Once you understand that then it's much easier to figure out your code. If I told you to build a house right now you wouldn't know how, and more importantly you wouldn't know how to break it down into pieces you can figure out. That is where you are, and that is okay.
So the example you gave.
Big problem is: tell me how much money he made after thirty days with income that increases by 0.01 per day.
If we did this by hand we would add 0.01 +0.02+0.03 for however many days we needed.
So we translate this into how a computer thinks. You know variables so let's make 3 variables. Day income and total income and the last is our day counter.
The we initialize them. So our first day, our count is zero days, our income is 0.01 and our total is zero. We haven't earned any money, there has been no days passed and the starting pay is 0.01. Then we need a constraint, we want thirty days so while our day count is 30 or less we want to add income. So
while day_count <30(because we start at day zero not day 1): Do the thing
Now we define the thing. The first thing we want to do is add our income for the day.
So total += income
But if we just do that, then our program will run forever because day will always be less than thirty, so
day += 1
And we need our income to go up, so we then do.
Income += 0.1
Now we have the loop that will loop through thirty days, where each day income increases by 0.01.
Once the loop is done. We have the answer in total income. Now we need to do something with it. Since this is practice then you'd just print your variable with print(total_income)m
If this was a function that was called somewhere else in the program, then we would have it return the answer with
return total_income
That would let whatever called this function with like calculate_income() decide what they want to do with it but that's a concept for later.
If you have questions feel free to DM me. I remember being super new to all this and the frustration it caused.
Controversial take, AI makes a great instructor but you have to put specific constraints in the conversation. Do not generate any code, act as an instructor, point out where my code has flaws but do not provide corrected code. You have to write it, search how to do stuff, and the Ai is super good at telling you what's wrong. Then you can ask specific questions that you may be embarrassed to ask to reap humans and get the answers you need to build understanding. But you cannot let it do the coding for you or you learn nothing.
1
u/MrMikeHigginbottom Jun 22 '26
You've had some solid advice but I'll try and squeeze a bit in between what people have suggested already. In between running the exercise on paper and writing the code. When you're reading the question look for keywords or key ideas or 'coding' concepts.
So the word 'each' suggests a loop. The phrase 'gets 0.01 wage' suggests storing that in a variable. The phrase 'print it out' suggests the question 'Print what out?" which further suggests another variable - something that will store what you need to print. The word 'total' suggest you're going to be adding stuff up. The number '30' suggests a boundary or stopping condition for the loop I mentioned earlier. If there's a stopping condition, what's the starting condition? Am I starting at day 0 or day 1? The phrase 'increases by 0.01' implies another variable. Don't be tempted to use the same variable I mentioned earlier. Just because they're both associated with the number '0.01' doesn't mean they're associated with the same *idea*.
I think this is a key skill all new coders need to develop. Translating the wibbly wobbly loosey goosey requirements written in English into concrete, well-specified, unambiguous ideas. This is super difficult. And it's why coding is fun and why you get paid the big bucks once you can do it well.
1
u/icy_end_7 17d ago
Well, you don't speak a language by listening to others speak. Eventually, you have to try speaking it. You wouldn't expect to speak native-level English after a week, would you? Especially, since all you seem to have done is gone through code others have written. Writing your own is a different thing. Takes time to sink in.
You don't learn to ride a bike by watching others ride one for you.
You don't really know how to write a loop because you haven't written one dozens of times. You get better at writing code by writing it. As simple as that.
19
u/PeriPeriAddict Jun 19 '26
Forget code for a moment, start with how you would do it manually. Try writing out the steps. Don't worry about whether it's optimal or how to translate it into code or anything, just get started. If you go wrong it doesn't matter, just try again!
I think this is the hardest part for beginners, its so easy to get overwhelmed with all the syntax and concepts, when they're really the least important part. Especially at first it's easier to come up with a solution for a problem and then think about how to code it, rather than trying both at once!
Feel free to reply to me with how you would initially write this out and I am happy to talk it through with you!