Week 4: Recursions
For this week's lecture, we mainly dealt with recursions, functional programming and unit testing . I found making nameless functions with lambda very efficient as it saves name for other functions if you're only using that nameless function once and it can also be done in one line which I found pretty neat, like the one line structure for making a list from the previous weeks. We also dealt with some unit testing which I found pretty easy as we've done it in this week's lab and a little in CSC108 last semester so that wasn't very hard to understand.
Now the hard part was the recursion, we were presented with more complex recursion examples in class such as the Sierpinski Triangle. This wasn't very easy to understand at first glance, so what I did was understand and trace the recursion example codes posted online and played with them for a bit. I would also try to make my own simple recursive programs in the next few days to solidify my understanding and maybe trace more recursive programs!
On this week's lab we were mainly working with inheritance and unit testing. The lab went pretty smooth, we finished most of the tasks except fixing the code to make it more efficient (reducing the redundant lines) as we ran out of time. Although I did finish it at home and found it to be very simple as you simply need to call the __init__ method from the parent class. Implementing the unittest wasn't very difficult although it required a bit of research mainly for testing the exception.
Now the hard part was the recursion, we were presented with more complex recursion examples in class such as the Sierpinski Triangle. This wasn't very easy to understand at first glance, so what I did was understand and trace the recursion example codes posted online and played with them for a bit. I would also try to make my own simple recursive programs in the next few days to solidify my understanding and maybe trace more recursive programs!
On this week's lab we were mainly working with inheritance and unit testing. The lab went pretty smooth, we finished most of the tasks except fixing the code to make it more efficient (reducing the redundant lines) as we ran out of time. Although I did finish it at home and found it to be very simple as you simply need to call the __init__ method from the parent class. Implementing the unittest wasn't very difficult although it required a bit of research mainly for testing the exception.
No comments:
Post a Comment