2015年2月22日星期日

148 SLOG #7

Earlier last week we learned about the 'ternary if'. With this mathod, we can combine the 'else if' code into a single line. It can help us to make our code easier to read.
For example:
if temp >= 15:
    outcome = 'Hot'
else:
    outcome 'cold'
can be combine into:
outcome = 'Hot' if temp >= 15 else 'Cold'

Later we were introduced to the Tree function. We learned about the definations of the term Tree such as 'leaf : a node with no child' and 'internal node: a node with one or more children'. These definations are easy to understand after I built a Tree by myself for exercise. In order to use the Tree efficiently, we need to fully understand how 'recursion' works, because we need to use 'recursion' in each subtree. Hence it will be very confusing to deal with a Tree class if we are not used to use recursion.

In the Lab7, we did the exercise about implement the recursive function respect to the Tree class. My partner and I were struggled on the 'implement list_leaves', because both of us were not familiar with using recursive function. We did not finish all the exercises in the Lab, so I believe we need to practise more on these functions at home.

2015年2月9日星期一

Week 3 SLOG

This is the third journal I write about CSC148.

It's a quite busy week, lots of tests and review sessions I need to take. We just finish the mid-term of CSC148 on wednesday. Although it's not that difficult, I'm still worry about some details about docstring and __repr__ typr and so on. The most difficult part of the test I think is the limited time. Normally when we write code for the assignment or practise, we do not have a time limit. Hence after I finished first question of the test, I found I spend too much time on it. So it's quite hurry for me to do the last two questions. To avoid this situition on the final exam, maybe it will be helpful if I force myself to finish the assignment or pranctise in a limited time.

In last week's lecture, we learned about how to use sum and isinstance in python. By using these build in function, the code we need to write become shorter and easier to understand. These method make the code we design clean and logical. As prof Diane saied on the lecture, 'As programmers, our job is to make our code easy and logical, which is a very difficult job.' These build in function can help us to clarify our design. This is also what the 'class' do in python, to make the code easier.

2015年2月1日星期日

Week 4 SLOG

Since last week I wrote about why geeks should write, I will conclude how I feel about this course in the first few weeks.

In the first 4 weeks, the thing we mostly talked about is 'Class'. Although I've already learned about class at the end of CSC108, it's still not that easy for me to understand. The definition of 'self' is what I think the most difficult part to understand. What's more, how to use class to store the message is always confuse me a lot, especially the relation between the memory address of each class. 

On wednesday last week, we finished our first assignment of CSC148, we worked until the last min. Along with working together, I was getting used to use class to store and varify the data. And I also figure out what's the job of '__str__', and '__eq__' in the class. In a sentence, although we spent tons of time in this assignment, I learnd what I would not know if I work with myself.

In these weeks, the bigget achievenment I think I got was that my work is more orgnized that before. By using class, the code I wrote was much more clean than before and easier to read. 

There's also many things I'm not doing will in the first few weeks, for example, Sometimes I'm not able to get up at 8'oclock morning to attend the lecture at 9. To avoid it, I need to sleep earlier at the night before class. More over, I also need to review the lecture slides and codes from the class every day ,so that I can keep the knowledge fresh in my brain.