Sunday, February 9, 2014

Week 5: Scopes and Recursion

For this week, I will be writing about what I learned during this week's lectures and labs: scope and more recursion.

During lectures, our professor gave us hints and tips for the assignment given to us, which involves the Towers of Hanoi. It really helped me and I'm sure others to find a starting point for the assignment. I haven't quite finished the assignment yet and so, I will save it for next week's post.

Another interesting topic which was covered during the lectures was scopes and namespaces. This is the first time I had ever heard of the terms and the examples given in class helped me greatly in understanding what local, nonlocal, and global scopes are, how python searches for similar variable names within a program, and also how python searches for similar methods within different classes and subclasses.

Finally onto the last topic, recursion. Again. During this week's lab, my partner and I worked through several exercises which involved recursion and we had a little trouble with coding the searchLists program. At first we tried recursively searching through every element in the list and nested lists and checking whether it was the number we wanted. The program worked, however we knew this was an inefficient method. What helped us find a better method was to try and trace the problem on paper. This allowed us to find the base case as well as modify the code, which reduced the amount of lines and worked more efficiently.

Sunday, February 2, 2014

Week 4: Exceptions, Unit Tests, and Recursion

Hello again! This week on I will be writing about my experiences this past week, learning about and implementing exceptions, unit tests and recursion.

I never really understood why exceptions were important. During lectures when I first learned about them, they just seemed like empty classes in Python that did nothing. However, during the exercise I found out that they can be used for some exceptional situations. The exercise was simple for me and I finished it quickly, however it made me realize that exceptions, in addition with a try block, can be used to stop your program from causing errors and run normally. Additionally, I figured this can be useful when debugging your code to fix the bugs and errors in your program 

Moving onto unit tests, last Tuesday, I had a lab which involved the making a Vehicle class and using unit tests to test the code. At first, my partner and I found it difficult to implement a unit test with a variety of test cases. What we found helped us were looking at previous week's lectures and documentation for unit test as well as brainstorming test cases.

Finally onto the last topic,  recursion. This past week, we learned about recursion through the use of nested lists and a class called Turtle. I thought that the Turtle class was really cool because it helped me (and I'm sure many others) visually see how recursion works which helped further my understanding of recursion and the levels of recursion.