How to improve my coding skills and get a handle on debugging?

I have recently started learning python and have completed Learn Python The Hardway, Think Python and Codecademy’s course on Python. And now I have started solving problems on Codewars but after a point of time I just can’t solve the problems. How can I improve my skills? And should I learn some algorithms and if yes then how should I go about the same.

I am looking for a specific approach.
@cpradio

3 Likes

I know this isn’t a specific approach, but it sounds like you have worked hard to learn the syntax and structure of Python. Possibly the next step in improving your ability to solve the problems doesn’t lie with the language itself, but in learning how to analyse problems, break them down into smaller chunks and practice developing strategies. These skills are important to all programming no matter what the language. And a lack of these skills could mean hitting roadblocks in problem solving no matter how many courses you take in a given language.

3 Likes

Hmm… that is a really good question. In short, I think it is a matter of continuing with Codewars and to maybe research techniques on debugging. There is a lot of ways to debug code, the most primitive is adding print() statements and having it output the variable you are concerned about at various points so you can see what values it is receiving that may explain why you are getting an unexpected output.

Then there are utilizing IDEs with built in debuggers, such as IntelliJ, Sublime Text, VSCode (this one is free), and that will allow you to set breakpoints to stop the execution of your code so you can review variable values.

Lastly, I think it simply is a matter of experience that you are battling with here. As you do this more frequently, as you write more programs, you will start to adapt and it will become easier to spot where the issue exists without even having to add a print() statement or use a debugger. You may still have to use either of those approaches, as you may have an idea of where the issue lies, but are uncertain as to why it is getting that value.

As an aside, I’m going to move this topic to a more general category in hopes it gets you more responses. As our Python category isn’t used often. I’m also going to alter the title a bit to make it more generalized. :slight_smile:

Edit:
Oh, and I whole-heartedly agree with @Webmachine, but this is why you should continue Codewars. Codewars is a great way to learn how to take a task and break it into parts. You’ve actually done exceptionally well. You are able to complete the task, you simply are overlooking edge cases or items mentioned in the instructions (such as dealing with None or when a value is < 0).

One thing I would get in the habit of, is write new tests. So Codewars gives you examples, but the examples are not all encompassing of the instructions you were given. In fact, they are entirely “Happy Paths”. Be sure to run cases where the instructions directed you over “Unhappy Paths”, such as, using None, using a negative number, etc. If you start to get in the habit of thinking of “Unhappy Paths”, you will see your ability increase drastically.

3 Likes

And what about algorithms. I mean should I learn them or not. And if yes that how should I approach them.

By algorithms are you referring to more of Patterns? As when I think of algorithms I think more of specific business cases. Such as, in insurance, you may need to be familar with algorithms that identify the principally rated class code for a given location or the entire policy, and so forth. But that would be useless if you were in any other industry.

Patterns on the other hand, such as, any of the ones listed in this article, are something that can cross industries and be useful no matter what industry you work in.

I would not worry too much about algorithms but if you really do want to learn some basics try this book: https://bigmachine.io/products/the-imposters-handbook/ it is very good if like me you don’t have a CS background.

Coding is hard and it takes time to solve problems so don’t get too down on not being able to complete things on Codewars. Leave it for a bit try other things and come back. You might then have a new prospective and be able to solve the problem.

1 Like

There are 4 states of knowledge.
We don’t know something
We do know something
We know there is something we don’t know
We don’t know what it is we don’t know

As far as algorithms or patterns and so forth, it could be that you have some “don’t know what I don’t know” going on. Something is missing, you don’t know what it is, but you know you don’t know it. It’s very mysterious!

I don’t think I’ll be much help here, I can’t point you to any resources and Python is not my language. I just wanted to say that you sound like you know that you don’t know something, but you don’t know what you don’t know, you think it might be algorithms. Maybe, maybe not!

I would only say, go ahead and do some Googling on algorithms then, but DON’T spend much time trying to learn any of it. What you want is a very high-level view of gathering intel on more programming “stuff” that you currently don’t know about.
It’s like when I got started, I used relational databases. I never knew there were non-relational databases until the concept fell from the sky and hit me. I didn’t know what I didn’t know. But had I spent any time browsing any kind of database information at all, I would have come across the concept sooner and at least knew the thing existed as a solution.

So go find some lists of algorithms, just don’t study them much. Get a high-level view of “this thing is possible”. Now you “know” something which you will still “not know” how to do. And should you ever get in a situation where that algorithm might be needed, somewhere in the back of your head you’ll remember “oh yeah, there was some concept I read about once that solves this”. Of course you don’t “know” the solution, but at least you “know what you don’t know” and can go research it again because now you know it exists.

A lot of programming boils right down to basic math operations, string operations, comparisons, editing data in objects and arrays, sending/receiving data, sorting, looping, counting.

Any time you come across a problem, try to break it down into the component parts. What data is incoming that I have to work with? What data needs to be output for the solution? What kind of conversion needs to take place between incoming data, to get output data? What data types are involved? Strings, integers, floats, random numbers? Does some data need to be generated within the logic itself in order to get the output? Do you have to retrieve additional data from another system/function/process/library to complete the challenge?
Functions can be getters or setters. Data can be BREAD (Browse, Read, Edit, Add, Delete). Or with databases, CRUD (Create, Read, Update, Delete). Typically you are doing one of those operations at a time.

Programs can function asynchronous or synchronous. Must one operation finish before another can continue? If so, it is “blocking”. Or can multiple operations happen at once, as soon as they can, and run in any order? There are methods of dealing with it.

How about data storage? What storage techniques are there? How do you maintain state? Do you need to store data to complete the challenge?

There are hooks and injectors, generators. How do multiple pieces of code/functions/classes/objects call each other? What is the scope you’re in? Are there dependencies?

Every different programming concept deserves a bit of a look at the overall picture. Don’t study it, just skim it. Then somewhere in the back of your head you’ll remember “oh, there is a technique for that, I just don’t know it, but I know it’s there.” And then you can go study it for realsies.

Happy learning!

6 Likes

I’m not too familiar with those books or Codewars but you might also enjoy diving into a web framework like django and start making your own web apps. Can be anything that you’re interested in.

The truth is most developers don’t need to use algorithms often, learning a couple like fizzbuzz or quicksort will probably help you, most of the time though you’ll be standing on the shoulders of giants and simply using existing libraries rather than writing algorithms from scratch. e.g. you could learn 15 different ways to sort an array or you could just use python’s sorted

It sounds like you’ve made a great start, the rest you’ll learn as you practice by making working software for things you’re interested in.

1 Like

Surely there are only three? If we don’t know something, either we know we don’t know it, or we don’t know that we don’t know it? :slight_smile:

2 Likes

Philosophers much smarter than me figured out these concepts. I’m sure I goofed it up a little. Think of it as a matrix of two data points. We can know or not know, and we can be aware or UNaware of what we know or don’t know. This creates 4 states.
The poster seems to be unaware of the things they don’t know. So they are guessing, maybe it’s algorithms? They are unaware (or don’t know) what it is they don’t know. They simply know something is missing in their skill. They don’t know what the skill is. They don’t know what they don’t know. Or are unaware of what they don’t know.

The tricky state in the matrix is when we are unaware of something we DO know. It doesn’t seem to make sense. If we know it, how can we be unaware we know it? Or not know that we know it? Perhaps this is something like instincts? Unconscience knowledge or behaviors. Or perhaps we know something but have too much fear to use the knowledge? Like a child unwilling jump across a gap because they think they won’t make it. The parent knows they can make it, the child’s body can make it, but the child themselves is unaware they can make it. They do “know”, but somehow “don’t know” that they know, not until they take a chance and try it. Then they will pass from unaware knowledge, to aware knowledge.
They didn’t know they knew it, until they tried, and now they know that they know it.

I better leave, lol

2 Likes

Well, As per my experience about learning a new language the only way to master it by practice it. If you keep on practicing about the different problems you will get to know that how to create a code or solve a problem in different situations…

1 Like

It would seem that you’ve covered the basics but haven’t picked a programmer’s mindset yet. Other posters have said enough, I would just advise you to try breaking a problem down to smaller problems and work on them one by one. If you run into something you can’t solve by yourself, that’s totally fine. Post the problem and look for help online. Seeing how more experienced programmers solve what I couldn’t has been most helpful to me.

So lately I have been visting a lot of different python tutorial websites.

And this one is one of the best ones I ever came across. So I wanted to know that as a programmer should one remember all the built in methods. If yes then how should I proceed further. I mean it looks daunting to remember all these methods.

@cpradio

In any programming language it is next to impossible to know all the built-in methods from memory, and not necessary because you will not be using all of them.

The important thing is to be aware of what is available (so read over the documentation to get a feel for what is there), and then know how to find the information quickly when you need it.

2 Likes

Thanks a lot.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.