Wednesday, 27 January 2016

CSC148 Week 3

I've actually never created a blog before. This is my very first entry, so... here goes nothing!

I feel like I've been doing pretty decent with the CSC148 material so far. I understand subclasses, stacks, special methods (__init__, __str__, and so on), and how to raise exceptions.

One of the things I learned this week that I found interesting was how you can use a for loop in one line. Here's an example:
>>> L = [0, 2, 4, 6]
>>> # Every item (x) in list L has a 1 added to it. The resulting list is then assigned to L.
>>> L = [x+1 for x in L]
>>> L
[1, 3, 5, 7]

I thought that way pretty cool. It'll definitely save me quite a few lines of code while writing Assignment 1.