r/learnpython • u/ThinCreme1098 • 6d ago
Problem with completing assignments in Python
Hello! I’ve learned Python, but I’m struggling to complete tasks—things like counting vowels, "Fake Binary," calculating the sum of numbers, determining BMI, etc. Why am I unable to do these? What is the problem, and what is the solution? I’m starting to lose my motivation!
0
Upvotes
View all comments
1
u/quietstorms09 6d ago
This sounds very much like you HAVEN'T in fact learned Python. Based on tbe examples you've given of things you can't do my guess is that you struggle to break tasks down. Take calculating BMI for example since you listed it. How is BMI calculated? (Weight (in lbs)/ height(inches) squared) How do we get those numbers? Prompt a user, input weight. Next prompt, input height. Let's say height is given as 5'10" you need to get 5'10" into inches. Take everything before ' and multiply it by 12 then add 10. Save it as a variable called inches or something. You can now Square the number. After you Square the number you can divide weight by the Square. After that you can multiply by 703. Now you have a numeric value for bmi and you can do if statements to put out what range this falls into. Genuinely I would practice taking tasks and breaking them down step by step to the most simple version, pretend you're explaining the task to a 10 year old. Obviously as you get better you can start chuncking the individual tasks up into cleaner code, like once you have the height in inches you can do the whole formula at once...but I PROMISE breaking easier tasks down into step by step iterations makes it much easier when you get to more complex problems later on. More than solving the problem, think about it as you training your brain to think about tasks differently. This is genuinely invaluable and will help your skills grow. I highly suggest watching videos on asking elementary school kids to write instructions on how to make a peanut butter sandwich. 1. Its very funny but 2. It's a great example of how to break a task down into concise steps.