r/learnprogramming • • 1d ago

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.

11 Upvotes

11 comments sorted by

8

u/ninhaomah 1d ago

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

3

u/themintyoxygen 1d ago

no example no help, you gotta show us where your brain locks up

1

u/cutepandao1 4h ago

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

1

u/addenrock001 2h ago

Yeah seeing the actual problem would help a lot.

5

u/BranchLatter4294 1d ago

Consider practicing. It's worked for many decades.

3

u/EntrepreneurHuge5008 1d ago

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.

2

u/RajjSinghh 1d ago

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 1d ago

Read this - don't want to repeat myself.

1

u/SwiftQuest 23h ago

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.

1

u/AssistantNo3545 1h ago

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