Friday, 20 March 2015

slog for week 10

  This week we learnt about assertion. In the slides it is written in the form as below:
      assert <condition> , <error_string>
---> if not condition: raise AssertionError(error_string)
I understand this form but I do not really see the point of this. Is it just a simpler form of if statement? Why and where do we use it? It is disappointing that I did not find any real examples in the course material. And there was no TA in the tutorial either. When I asked my friends, the answer was not clear and I can tell that this is not just my problem.
   Besides the course, I also used computer science elsewhere, which is really cool to me. In physics, we had practicals using python and vpython, to make the diagram and animation of waves. And for linear algebra, my friend and I tried to create classes of matrix, vector and vector spaces. And we even tried to write codes so that it will solve the polynomials we input. I have been focusing on learning how to use Sqlite these days. I think I am slowly falling in love with computer science. This is a great change of mind, since I used to hate it somehow. Now, the feeling that I can actually command the computer to do what I want in a much easier way than doing by hands is of great satisfaction. I hope I can learn more about coding, and use it more. 

   May the passion be always with me. And I will try to figure out the assertion of course.

  Thanks for listening to me.
  
  Tschuss!

  Dark Fox

2 comments:

  1. Assertion is mostly used for testing; it raises an error if a condition is not met. When you use an if statement, you don't cause an error if the condition isn't met. Assert is roughly equivalent to:

    if not (condition):
    raise AssertionError()

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete