r/learnprogramming • • Oct 25 '26

Topic Python beginner

I’m a 1st year computer science student. I have no coding experience and my classmates can finished it like under 20 mins.

How do you code a word problem? I’m stuck of what I should code. I can somehow visualize it but I can’t put it code and I have upcoming midterm. Most of my midterm is word problem then create a function and return statement.

13 Upvotes

11 comments sorted by

8

u/ninhaomah Oct 25 '26

Example of a word problem , the code you have done and the error or the place you are stuck at ?

1

u/cutepandao1 Oct 27 '26

Share one question from your practice. People can walk you through how to approach it without just giving you the answer.

1

u/addenrock001 Oct 27 '26

Yeah seeing the actual problem would help a lot.

5

u/BranchLatter4294 Oct 25 '26

Consider practicing. It's worked for many decades.

3

u/EntrepreneurHuge5008 Oct 25 '26

I can somehow visualize it but I can’t put it code and I have upcoming midterm.

Put the process into words before trying to put it into code, then.

That is called pseudocode.

3

u/RajjSinghh Oct 25 '26

When you get to university having never coded before, a lot of your peers already have several years of experience. You just have to get good.

When you say a word problem, I'm guessing you mean the problem is described in words. You should get into a habit of looking at the problem and thinking about what needs to be done first, then trying to think about implementing it. Practice is the best step forward. I'd do leetcode in Python until it feels natural.

2

u/aqua_regis Oct 26 '26

Read this - don't want to repeat myself.

2

u/AssistantNo3545 Oct 27 '26

Those classmates who finish in twenty minutes either coded before or they are just copying code from GitHub repositories without understanding anything.

1

u/SwiftQuest Oct 26 '26

What helped me with word problems was making three tiny decisions before typing anything: what goes in (those are your parameters), what has to come out (that's your return value), and what the steps are in between. Say the problem is "a store gives 10% off if you spend over 50, what's the final price?" Input is the total, output is the price, and the middle is just one if. So def final_price(total): then if total > 50: return total * 0.9, otherwise return total. Write those steps as comments first, then turn each comment into a line of code, and run it with a couple of made-up numbers so you can see where it breaks.