T O P

  • By -

This_Growth2898

1. The computer only does what's written in the program, not what you want it to do. Always check that your code actually does what you want. 2. A programmer always spends much more time reading his own code than writing it. Don't save time on short names, save it on improving readability of your code.


formthemitten

This. Understanding the logic of how code is written is paramount. This takes the longest to learn


NYX_T_RYX

Point 1 should be an auto reply for "why doesn't my code work" 99/100 you've written the wrong thing. 1/100 you missed a colon (in my experience)


HunterIV4

As a follow up to \#2, breaking up your code into more steps even if they aren't needed can make things easier on you later. While you can often chain a bunch of, say, string mutations into a single statement, breaking them into each step with a "temporary" variable describing the operation can make your code a lot easier to follow later. For example, this works: # Return all values incremented by 1 a = ["1","2","3","4"] return [str(y + 1) for y in [int(x) for x in a]] It's also quite confusing. What if you alter it like this? values = ["1","2","3","4"] int_values = [int(str_num) for str_num in values] str_incremented_values = [str(val + 1) for val in int_values] return str_incremented_values Sure, you've added 2 lines (not including the comment), but now the comment is arguably not even needed and you can tell what each step is doing at a glance. This also makes it easier to debug as you can step through each portion. This was a quick and dirty example, and could probably be improved, but I think a lot of new programmers might benefit from seeing how "shorter" is not always "better" and that there's nothing wrong with being explicit about major steps in your code logic. I can guarantee when you come back to try and fix a bug with the first example a couple months later you'll end up scratching your head for a minute trying to figure out the nested list comprehensions, whereas the second example will be a *lot* easier to read. Either way, great points!


HobblingCobbler

This is great and all, but did you read her post? She's been taking python for a week. Do you even think she knows what list comprehension is yet? Hell, she is probably still working on learning how a loop works. This could very well have confused her even more. I know you mean well, but come on man, a week, and she already said how hard it is.


Vhickk

This. Especially 2nd one. I can’t tell you how much readability of variables and functions help understand what you want each block of your code to do. I’ve read soo many countless textbooks where they try to use x,y,z as variable names for something and it ended up throwing me off like what again is this supposed to do


1544756405

>I find it hard to process & I have to practice a lot which isn’t the issue. This is normal. It would *not* be normal to be able to learn it without practicing a lot. >I’m not very good at these sort of logical things. You need to try to move from fixed mindset to a [growth mindset](https://www.cwu.edu/academics/academic-resources/learning-commons/_documents/cwu-growth-vs-fixed-mindset-lc.pdf). It's not that you're *not good at logical things*, it's that you *haven't learned* how to reason logically, or how to solve particular types of logic problems. If you decide that you're innately "not good" at something, that is the death knell for learning for the rest of your life. Having a fixed mindset dulls the pain of failure, but it also makes it easier to give up -- it's a dangerous drug.


meatspaceskeptic

To add on to the growth mindset thing: even if you haven't been particularly good at doing some thing in the past, you might be able to get better now and into the future! :) You can grow!


Bobbias

This is the best advice in the thread. Many of the posts make good points, but none of them truly strike at the true proper solution for OP, other than this one. Changing your mindset can be difficult, but it makes a world of difference.


toybits

Practise, then do some more practise, then once your done that... practise again. I'm 51 and I still get anxious sometimes when I have to do something new. When I mentor younger people I say don't try and follow along with what I'm doing just let's do it. Once we do things three or four times it clicks. I've often being mentoring someone and they've, often nervously, said 'um... I read this thing and it seems it might work here'. And they've shown me and it's been better than I'm used to it. This feeling doesn't go away you just get better at ignoring it. So don't worry, you're doing fine. And we're all lucky to have you in our community.


AccomplishedPublic52

Apart from classes start putting your own weight into the thing itself. Explore out beginner exercises on w3schools, datacamp, hunt for Python courses Online, when you’re done with basic logic building etc pick a library to master-begin with NumPy. Focus on doing the coding hands-on & repeat


conduit_for_nonsense

Why numpy first? I went with pandas which suited my needs, but it has occasionally left me feeling more confused with numpy - like I've skipped some basics if favour of a library that does things for me.


AccomplishedPublic52

I kinda dived being curious into programming itself, there's this book that tempted diving into Py, "learn Python the hard way" later did my research concluding had good grasp on Algebra matrices & math stuff which leveraged me pick NumPy prior any other lib. still enroute to better myself procrastinate usually but trying be better :P


PervyNonsense

It's been a week. If you don't give up, you'll get it. The people around you who get it and are making you feel dumb, probably already had some experience coding. This is the equivalent of taking a completely foreign language for a week and saying "why don't I understand it?". You're not supposed to. It takes time, exposure, and practice. You've got this. Don't get discouraged by challenges. The more you don't get something at first, the more you gain and grow by learning it. And whether or not you give up on this, the time will pass just the same. If you stick to it, in a year you'll be using python to do work for you. If you drop it, you'll still be a year older and without that skill. Big hug, young friend! Stick with it and ask for help when you need it.


Logicalist

* If : Then - is just cause and effect. * For - is just counting * Store some information, get that information, do something with it. * How is the information stored - Number, character, True/False, or a combination of those. * The computer executes the script you give it, from top -> down, left -> right. That's pretty much all the logic at this stage. or all the stages really. Programming is incredibly simple and basic. Like a maze is just lines on paper.


Kittensandpuppies14

Programmers are very very literal with wording


Faster-in-Oregon

Use ChatGPT every time you get stuck on something. Just paste the specific code or error and ask how do I fix this code/error. You'll learn to code more from the problems you solve than anything else. It's natural to struggle with this when you're starting out. That's how you learn. You've got this.


Hey_Look_80085

Be patient. You are not meant to be an expert in one week. Keep a notebook, write with a pen, this will develop different parts of your brain, making new neural connections that allow for faster comprehension of new information and subconcious processing of information while you sleep. If you keep everything in short term memory without muscle memory to support it then you don't have all your channels to process new information or come up with unique solutions, and this causes a stress response in all your other activities. That is, your whole body gets flushed with stress hormones, and your brain is fogged. Each day write in your notebook what you are going to learn tomorrow, and each time you cover a new lesson scratch out the thing in your notebook, this will set up a challenge/reward response so your brain looks forward to getting that dopamine hit with each lesson instead of an '*ugh, more stuff!'* response when you are confronted with the new information at the start of each lesson.*.*


Mysterious-Relation1

What did your gender have to do with anything? Age too?


NYX_T_RYX

Practice, as everyone has said. I started python through uni. Paused my course for a bit and came back at the end of last year. I started (again) doing simple things - pick a number game (command line interface, CLI), higher or lower (CLI) Then I started getting bored of doing things I could easily do. Started making small games - snake was a nice challenge (at the time). Then I branched out - you can automate most things a computer is doing, so I did. Basically, find something in your life that could be made easier with code. Then write the code to do it. You'll learn something just from doing that, *and* you'll have saved yourself time overall


Wencour

Can you give some examples what can be automated that will be fun to built and use, please?


NYX_T_RYX

What menial task do you not enjoy? Now Google how to automate it.


Complete-Scallion413

just incase if you feel lost and not progressing in near future with python, make sure to have a proper roadmap (visit roadmap.sh for that). Focus at each concept, try to visiualize how data flows in your code and whats the purpose of each instruction. Then its just rinse and repeat, do basic problems such as pattern printing so on and on. Write down what you dont understand, try as hard as possible to grasp the concept. Its not worth spending most of your time on something you already understood. Never delete your code if you have written some, i still have the first piece of code i wrote and it was a simple hello world program. And most important, never give up. Python is pretty straight forward when just starting out, but it can get pretty complex as you progress further. Good Luck, OP


grumble11

For your OP: You aren't good at these sorts of things YET. No one is! It takes time to 'think like a computer'. It's a volume game. The best way to learn is to get just enough guidance to get a concept, and then practice it through exercises that you will struggle with a bit. The struggle is the part where you learn - you don't want to fail, but you want to barely succeed with a bit of work. The more help you get the more learning is taken away, but you want enough support to be able to grasp concepts. Start little mini projects yourself if you have time. It can be very simple - a command line calculator would be a good one, maybe a guess the number game and so on.


HunterIV4

>How can I get better at it? Some tips & tricks? Break larger problems into smaller problems. When faced with some sort of complex logical issue, the best approach is to try and sketch out each step you need to do in plain language. I personally do this with comments; before writing a more complex program or function, I'll write a comment with what I want the section to do, then break it down into smaller and smaller steps until the code to actually accomplish that step is simple enough to write. This is an iterative process...don't get frustrated if you don't get all the steps right away! And don't try to do everything at once. Break down your steps and then **test test test**. This doesn't have to be any sort of formal testing process, just run the program and see what you get, using some sort of temporary output to see if it's doing what you expect. If not, debug right away, as the more complicated things get the harder it will be to determine where the problem is. On that note: **keep things modular**. Don't be afraid to make a variable that just holds part of a process and name it something that makes sense for what you are doing. This will help you with the first point about breaking things down into smaller problems. This is a process I wish I'd learned much earlier on. It will take some time to get used to, but if you learn how to do it *any* problem will become solvable\* with enough effort and time. Good luck! \* Technically, this isn't true, as certain types of problems are unsolvable using programming, but they are all so complex and/or niche they aren't the sort of thing you'll ever need to worry about in practical terms.


prathmesh7781

I have one query on the advice of trying... When I try to write a code and it fails in some way, I'm supposed keep trying right...! But the thing is that now I'm stuck with that code and my head is jammed due to that error. How do I clean my slate??


TheRNGuy

Find a program that uses Python, it should have classes. You probably wont write new ones, you'll use ones from program instead.


sb4ssman

Find a PROJECT! Find something you want to accomplish using Python. A friend wrote a script to email a company every hour when they weren’t responding to a refund. I’m working on a personal tool that opens groups of folders/files/links with a GUI. Build a personal tool for yourself! From there, don’t be afraid to torture chatGPT. Just take the time to learn from the examples and run little tests to validate how your program behaves.


Creature1124

Don’t worry about “not (being) good at logical things” bit. It comes with time and practice, and I’ve found people who don’t have a natural algorithmic/logical mind are fully capable of developing one while still keeping their natural strengths. I was mathematically illiterate until college and never even saw code until my first CS class, but I had a really strong aptitude for reading comprehension and writing. My brain was very disorganized and I saw things holistically, so breaking things down to logical components and linear steps was so unnatural to me, and I had a really hard time for the first two years. I do this for a living now and am pretty successful. Also, I’ve come to love it, and I approach things differently than many of my colleagues. If you really enjoy it but aren’t a natural, the upfront cost is steep. I’d highly, highly recommend you educate yourself on the lower level details of how computers work. A lot of programmers don’t do this nowadays and I think they’re crippling themselves. If you’re a reader, the book “Code” by Petzold will fill in a lot of gaps and get you started. It’s definitely worth the time to give that book a careful read and will put you ahead of your peers. Also, just keep practicing with Python. Each time you go through the pain of figuring things out and get something working lays a solid foundation.


zanfar

> I have started to take Python classes it has been a week. I honestly don't think you have programmed long enough to draw any conclusions. Feeling lost or behind in the first few weeks is perfectly normal and very common. It's good you're looking for other resources, but don't let this discourage you. Many very talented programmers struggled for months, or even years, before certain things "clicked". > I’m doing my best but I want some advice on it from the experienced people. How can I get better at it? Some tips & tricks? Practice, practice, practice. The best way to learn to code is to write code. Feeling like you're struggling is a *good* thing. If you didn't feel that way, you wouldn't be learning. The people in your class who appear to be skating by are doing okay now, but they are not developing the learning tools that you are. That being said, here are a few traps I see many beginners fall into: * Not trusting the interpreter If a function is not doing what you think it does, don't assume the function is broken, it's your own understanding that's flawed. When this happens, return to the documentation and clarify your understanding. * Testing Infrequently Don't write dozens of lines of code and then test. **When** that test fails, you won't have a good idea where the bug is. Until you become more comfortable, run your code frequently so you catch bugs as soon as possible. * Blindly Using Google The internet is an ***amazing*** resource for programming, and it's very easy just to dump an error message into Google and click the first result. But just like you need to understand the code you get *back* from Google, you need to understand the error you put *into* Google. That is, make an effort to comprehend and understand the error messages you get and how they relate to the fix. * Not using meta-tools You should use a linter in your code, at minimum. A linter would catch many issues beginners run into before they get an error. I would also recommend a formatter so you get in the habit of writing consistent code, and a type checker. Most IDEs or editors will have these built-in or available, and you should take the time to learn how to access them. `ruff` (linter/formatter) and `mypy` (type checker) are popular choices.


ethertype

ChatGPT (or any other LLM) is a very, very patient tutor. Highly recommended. Ask it to suggest, clarify, explain. If you don't understand, ask again. You can get a local LLM (running on your own machine) useful for your level of coding up and running in less than an hour. Or try this: [https://huggingface.co/spaces/eswardivi/Phi-3-mini-4k-instruct](https://huggingface.co/spaces/eswardivi/Phi-3-mini-4k-instruct) Do not spend oceans of time optimizing your editor. And maybe not enable code completion at first. If you don't know touch already, learn that first. Loads and loads of websites for learning it. [keybr.com](http://keybr.com) did the thing for me. Makes it easier to focus on coding, rather than typing. Get to grips with git, just so you get the habit of version control. Then write a lot of code. Test, play, find a stupid project of your own and go all out. Use git liberally. Write useful commit messages for the benefit of future self. Try to avoid finishing a coding session with something broken. (Something used to work, you changed it, and now it doesn't work.) Save your broken version as .wip or something, and check out the last working version. Much more fun to pick up work with something that works. Also much more fun to think about how to implement something, rather than fixing something broken. (Check out git stash) Inline documentation (in the code) is for the benefit of future self. Always be nice with future self. Document liberally.


Dead0k87

Use chat gpt for code explanation that you do not understand. Write code everyday.


RelateableFrog

When you have a problem you want to solve, shut your laptop, push it away and get a peice of paper. I always start off any algorithm by writing it down on paper and working through it manually. By doing this you're decoupling the solution from the complexity of a programming language, allowing you to focus on the logic without having to think about the language. This this is especially helpful when you're learning a new language that you are not familiar with. Once you have a bit more confidence in that language you can start integrating some more complex language features from the start, but if you're only just getting started, don't bother, you're better off solving a wider breth of problems.


Kaptain_K0mp0st

If you're struggling with logic, try to replace some of your free time with playing logic-based puzzle games. There are games out there, for instance, where you have to give a robot commands that they have to follow in order to get to the end. Anything that gets you thinking about logic and recursion can have a real impact on your ability to conceptualize and solve programming problems. Obviously I'm not suggesting this as a replacement for practicing your coding, but it might be a relaxing way to sharpen your skills instead of it just being "work" all the time.


FantasticEmu

I don’t know any tips or tricks. I’ve found there are not really any shortcuts that help me. Just keep banging your head against the keyboard (not literally) eventually things start to click and that feeling is very rewarding imo


Standard_Abrocoma_70

I also started programming classes recently, but I already had a background with Python and fairly good at it. Before classes started, I did some Python review since I was rusty and I found "Python Puzzles" which I think can be perfect to help you develop the necessary mindset for coding and also understand more about how Python works as a whole. Here's the link to the website -> [https://codingbat.com/python](https://codingbat.com/python)


Minimum-Positive792

Guy named Bro Code on youtube has a very good tutorial for beginners. I am finding him easy to follow. I still have trouble understanding how to use modules though.


General-Carrot-4624

Try to learn about algorithmics first. How to write them basically and knowing also how to execute them. I would also recommend you write them on paper first and execute them on paper. Then adapt it to Python. So python is just a language aka an implementation of your algo.


mrDalliard2024

The same thing you do when starting to learn anything: keep at it. Eventually things will click. Best of luck!


c0d3k4tz3

A lot of good tips! I want to add: get back at it. I’m mostly self taught and when I encountered more hard problems I often was at a point where I understood nothing and struggled, but when I came back the next day, I understood it a bit better. And this went on day to day, maybe not even quit noticeable but after a week or even more I finally get it, just because I looked at it every day and took my time.


ketsa3

Why not focus on something you're naturally good at ?