Yes, i got very tired week! It was not because of CSC148 first assignment which i already finished last week, it was all of the quizzes, midterms, assignments from other courses, that drove me crazy. Moreover, when i checked my A1 file yesterday night, i realized that the TA only gave me 1 out of 4 for my Slog, they said that i missed the post on Object Orientated Programming (Week3) but it was right there, so i submitted a remark file on Markus and hopefully that one of TAs will check it out and remark my Slog.
During the lecture this week, we were introduced "Tree" which is a very common data structure in any programming languages. We talked about different terminologies used in Tree data structure, such as parent, children, node, root, leaf, edge ... which are fairly interesting and understandable. However, when the professor implement Tree in Python, i was kind of lost! Not only me, but my partner who sat next to me also had no idea. I am little bit worry about it now since the mid-term is coming soon in less than two weeks. Luckily, i have 9 days off from school, so i definitely will go over all of the course's material and hopefully be ready for the midterm before the class start again.
The practical tasks for this week was really interesting. We were asked to rewrite 4 functions , but instead of using list comprehension like in the sample codes, we had to write the codes in the traditional line-by-line form. I learnt how to use some of the very useful Python built-in functions such as any() and zip(). I especially like zip(), it is extremely useful and efficient when i have to iterate over several lists. Below are some of the common uses of zip():
Example1: Turning column into row! In MAT223 midterm that i sat about 6 hours ago, one of the easiest question was to find the transpose of the matrix ([1, 2, 3], [2, 4, 5], [1, 3, 2])! So i developed a program to solve the question.
def transpose():
Row1 = [1, 2, 3]
Row2 = [2, 4, 5]
Row3 = [1, 3, 2]
Matrix = [Row1, Row2, Row3]
Matrix_inverse = []
for d,e,f in zip(Row1, Row2, Row3):
Matrix_inverse.append([d, e, f]) # the rows now are turned into columns.
print(Matrix_inverse)
Example2: Turning 2 corresponding list into dictionary with key and value.
def transfer(instructor_list, course_list):
'''
>>> transfer(['Paul', 'Tom'], ['CSC108H1', 'CSC165H1'])
{'Paul' : 'CSC108H1', 'Tom': 'CSC165H1'}
'''
return dict(zip(instructor_list, course_list)) # return a dictionary with names of the instructors as the #keys and the corresponding course that they are teaching as the values.
That is, that are all that i want to share for this week! Over the reading week, i will make some extra posts when going over the course material!
As usual, I would like to give my-self a grade of for my overall learning experience! 3/5 seems to be a reasonable grade, since i yet have a completed understanding about "Tree" data structure.
No comments:
Post a Comment