Saturday, January 31, 2015

week 4 , my impression of first few weeks

In first week and second week,we talked about object-oriented programming. It was not a hard topic for me, because I had just finished CSC108 and we had known what was class, how to write "__init__", "__str__". I got confused with method "__repr__". I didn't know the difference between it and "__str__". But now, after going through assignment one and consulted some materials, I understand "repr" is a method which returns a string that can construct an object with the same value. It represents a string for computer itself rather than people and "__str__" is designed for people.

Also, "self" was very trick for me. But I decided not to understand but to remember it! For every method in a class, remember writting "self"!!!

In third week, we started to talk about inheritance,we wrote subclass and let them inherit methods from super class.


I like the example which we talked in the class so I post here and I should remember how to write a subclass.

















NOTICE that we inherit "__init__" from super class!



And this week, we started to talk about recursion! I heard about it when I was a senior high school student and I will post my impression for recursion next week.

No comments:

Post a Comment