I know I'm a little late, but better late than never!
This week, we were instructed to discuss about tracing recursion from Week 4. Recursion essentially involves repeating the entire function until each element of the input is reached. If you have ever experienced recursive functions in math, that's exactly what it is - except that we view as Python instead of just mathematical symbols. I have to say, tracing recursive code was pretty simple. At first it was confusing, particularly with list nested in a list, which is nested within another list. However, after doing the examples in lecture and in lab, you start to pick up the format. It's especially helpful that we did not need to write down the function if we already figured out what it does for a certain input. For instance, if we figured out what a function did with a non-list, we would just write the output and skip all the elementary steps. This kept the solution very clean. As well, if the docstring is not given, you can also tell what the function does by simply tracing it and/or picking up the pattern. Overall, with practice, recursion becomes quite simple and actually fun! I can't wait until we learn how to write recursive functions.
Besides tracing recursive codes, we had our first term test. The test was fairly straightforward. It was much like what we had done in lecture and in our labs exercises. This made extremely happy. The test also involved tracing recursion, which also made me shriek inside. We're getting our results this week and I'm hoping that I did well. Wish me luck!
No comments:
Post a Comment