Today I completed Lists: A Data Structure, Module 2 of the self paced EdX class Microsoft: DAT208x Introduction to Python for Data Science.
This was more challenging than Module 1. I was really grateful for the command line Python shell to experiment with how lists work.
Python lists are a compound data type, meaning they can mix all other kinds of variables in a list. So data about families or houses could all be stored in a single list. You can also create lists of lists. I believe that a Python list could also be referred as an array.
The module did a clear job of walking me through how to create lists, how to view and change elements within a list and how to add and delete list elements. Once again, I was troubled by the upselling by the Datacamp site. I do think this is likely to confuse some people into buying subscriptions to Datacamp that they don’t have to. On the other hand, I think it is an environment to be somewhat proud of.
The lists module was also very clear about a potential trap. If you copy a list like a regular variable, say:
list2 = list1
You’re not really making a copy of the list values, merely the references in memory. What this means is that if you change a value in list2 (list2=”vanilla”), it changes the value of list1 to “vanilla” as well. If you want to make a copy you can make independent edits on, you need to use one of two commands:
list2 = lists(list1) or list2 = lists1[:] (This selects all values in list1 and copies them over to list2.
This weekend I hope to get to module 3, Functions and Packages. When I do, I’ll report back.