In this week of the lecture, we talked about recursion. To be honest I am still a bit confused about the format/idea of it, but through the labs and exercises that we've done, I am understanding it slowly - that it is basically it is the ability for the code to call itself. I found the drawing turtle super interesting and I am very fascinated by how much a simple code can do. I've learned that recursion is a very powerful format to simplify your codes in a few lines. One of the confusions i have right now is when to use recursion/for loops (at this stage they both seem pretty simialr to me.)
During the exercise, i further understood the use of exceptions and how to properly format my classes. It is very useful for computing since the other users of the computer might not know which part did they mess up.
You are right about the fact that recursion and for loops are very similar. They can basically do the same thing and recursion is SOMETIMES preferred because it can simplify your code but you have to be careful not to introduce unnecessary bugs/complications.
ReplyDelete