Thursday, February 20, 2014

Week 6 - Some Fantastic Blogs that I Read


            During the weekend, since the reading week is coming up, I had some free time that I can browse some of my classmates’ Slogs. It surprised me that some of them even have pictures and many paragraphs to go with it. For instance, these blog sites:


            → http://cscslogging.wordpress.com/

            This person put down ideas of his/her own, and yet also reading some web pages to research for his/her blog. Therefore, he/she provided some links that he/she had referenced. This is really formal in the way of reading, and he/she is really aware about plagiarism and respect other people’s work as well.


            → http://csc148courslog.blogspot.ca/
This is also a very cool blog. This person utilized tons of pictures so that the reader would not get bored while reading the entries. He/she also put in a cool GIF stool picture in one of the entries,

And also some interesting photos illustrating recursions.
One of the favourite is his/her last sentence for the first entry, which was about the object-oriented programming. When he/she was talking about we were going to learn recursions, he/she put down this.. :D 


            → http://hepingsheng.wordpress.com/
This blog is one of my favourites! He/she included lots of colorful picture and quotes from link. Sometimes, one can even find some useful link he/she suggested to watch about some certain topics. The links re in brackets right after the quotes. He/she made them so stand out to illustrate them as quotes.

From the contents and the lengths of it, one can see that this person did not do his/her entries in rush or just want to finish them as soon as possible; he/she did them really detailed and with his/her person ideas and thoughts. I enjoyed really much reading his/her writing. Also, he/she included a picture to show the method about stools in Assignment 1, the picture looks really nice and neat. :D 

He/she did put a lot of thoughts when he/she was creating his/her entries.
I had a really great time seeing other students’ blogs; it would also be a pleasure to have my classmates to leave comments for me as well. :D I sincerely hope someone would read my blog and give me some feedback.


Sunday, February 9, 2014

Week 5 - Inspired Week

Since last week, we have been learning/doing codes about recursions, yet recursions will be the writing topic for week 7. So, I would like to write about the class in general. :D
I personally was not used to the professor’s teaching style when the semester just started, maybe because 108 was very slow speed and its professors would ask if we had any questions every 10 minutes-ish. Yet, 148’s professor started the lectures very fast and purely focused on the lecture materials. Now, I have to say, I like his style better. :D In his class, I actually pay more attention to the material, keen to learn more and I can even gain some new details about the things I learned before. Even though the prof looked kind of serious sometimes, but I can feel that he is passionate and excited about the contents he is teaching. He always ask students’ names after they answer/ask questions, and he will remember those names. None of my other courses’ professors have done that before.
I feel really lucky to have him as my 148 professor, he inspired me to take more interest in python, and computer science in general. Also, some example functions he used in class were very cool. :D For instance, this week’s turtle recursion code is really fun to play with, and learn to predict its results from different input was really difficult at first. After the input 3, I started to get a handle of it; I can see the results will slowly form a complete triangle. Learning tracing codes with him was a very fun experience, and he is always patient to take the time with us with varies of inputs.
Unfortunately, Assignment 1 will be due this Thursday, so much pressure. L Luckily, the reading week is coming, I can finally take a little break between weeks of learning. 

Monday, February 3, 2014

Week 4 - Exceptions

This week, we started with something that we have never learnt before: Exception. Exceptions should be class objects. The exceptions are defined in the module Exception; it is a built-in class and I can always build new exception as subclasses of it and the python will automatically know it will deal with exceptions. The following Exception can only used as a superclass classes for other exceptions. A typical look of Exception will be this:
class E1(Exception):
       """
       An exception class that is a subclass of Exception.
       """
       pass

class E2 (E1):
       """
       An exception class that is a subclass of E1.
       """   
       pass

def exception_raise_function(x) -> None:

       try:   

        if something:
               raise E1

        else:
               raise E2('hey, I’m E2')
       
        except E1:
               # can print/return/etc. things

        except E2:
               # can print/return/etc. things
In class Exception, a try statement with an except clause that mentions a particular Exception subclass, that clause also handles any exception classes derived from that class. A exception message that coded within the bracket in the raise statement can also be printed when this exception is been raised. A test class could be designed to test the exception code:
def test_exception_raise_function(f, x) -> None:
       """
       f is the name of the exception function, x is the input of the                               functions.
       """

    try:
           if f(x) is None:
                  # can print/return/etc. things
       
    except E1:
           # can print/return/etc. things
   
    except E2:
           # can print/return/etc. things
The raise of a exception can sometimes return something long and messy. Yet, by using designed testing function, one can see whether the exception function was correctly coded by the things it returned.
Python raises exception in case of errors, and I can design codes to deal with these errors. I can use the try statements and except statements to raise exceptions when an error is produced. All exceptions are designed/subclassed from the built-in superclass, Exception class. I am still a little bit confuse about the differences of put try and except statements into different orders or levels of indented if statements, yet I think I have already got some grasp about exception; I just need a bit more practice :D.