Since spring break the class has learned about
lists, 2D lists, and data structures in Python.
All about lists-
Lists
are the third most common type of sequences in Python after strings and ranges
and it involves the storing of multiple elements as opposed to characters or
integer. Elements can be integers or characters. They are like the less
specific sequence in this programming language and mutable. Lists are also 0
indexed and use [] to access a given element or that memory location to call
the ith element of the list, use the
syntax a[i] where a is the variable
that stores the sequence and i is the
ith element in the sequence. In order
to get a number of elements in the list (as opposed to hard coding), python has
a len function. Advanced list operations include reverse, remove, index,
append, insert and extend
2D
lists are a little different. Although this type of list is not predefined, it
can be thought of like a matrix indicated by Rows encoded from left to right
top to bottom. Altogether, this list of lists creates a data structure which
allows the user to use math-like notation. One thing to note however, is the
importance of order in which loops are written and the values assigned to the
variables. Along the same lines, one can also work with text files in python.
With special notation, one can write and read files in and to python.
Other data structures:
After experimenting with lists, the class moved on
to work with dictionaries and tuples for the final unit in this course.
Dictionaries in this programming language create associations between key and
value like a mini variable of sorts. Although one can accomplish a similar task
using lists, one is not restricted by having to use integer indexes when accessing
the desired elements. Dictionaries are denoted by {} and [key] is used instead
of [index]. One key difference between dictionaries and lists is the fact that
dictionaries are unordered. Key are specified and do not depend on any explicit
ordering. So, when should one use dictionaries? When one wants to store relational
data as opposed to ordered data.
Good Riddance? Not entirely:
Okay, I admit it, I’m inwardly jumping up and down
like a treat-obsessed dog at the prospect of washing my hands of python. But to
be fair, I think I did learn a lot, if not about python then at least about my
personal strengths and weaknesses. I’m not touching computer programming in
college if I can help it. At least that’s the plan. After nearly six months of
programming computer languages or dealing with conceptual programs meant to
prepare you for the real deal, I have to say that I do appreciate the
experience. Although the learning process was rather stressful and emotional at
times (and I imagine will continue to be for the remainder of the year), I don’t
doubt that the concepts we’ve learned in this class and the problem-solving
skills have stretched my brain in some way.
No comments:
Post a Comment