Sunday, 9 February 2014

Week #5: Scopes and Namespaces

This week we started with the Towers of Hanoi recursion algorithm. The one which was shown in class was the one used for the 3-stool problem. I had already figured out how to write that one and had implemented it. The result I got was not the optimal solution but thought it could work as I couldn't get the recursion function for the optimal i to work. Luckily after much research, I found a different way to find the i. After that, I worked on a solution to solve the 4-stool algorithm. So I finally completed the assignment with the optimal solution. All I've got left to do is to just go through my code and clean up the docstring and the code by making sure that all the names are coincided and not repeated.

The other things the professor talked about was quite simple. They were things which I had come across while I was writing code in CSC108 and came across many errors. These errors helped me understand how the naming worked.I didn't know there would be a whole lecture dedicated to how it worked. When the professor was showing us the example, I got it straightaway due to experience. For more information on namespaces and scopes check http://docs.python.org/3.3/tutorial/classes.html#python-scopes-and-namespaces.

This week in lab we did some more practice on recursion. We just traced the recursion on paper and then wrote a bit of code which was a bit challenging. But my partner and I got through it with a bit of help from our TA. Other than that this week was a pretty slow week. Not too interesting. Hoped you enjoyed reading this. Until next time.

No comments:

Post a Comment