Session Overview
This lecture introduces Python tuples, lists, and dictionaries, as well as the concept of mutability and how to avoid problems relating to it. Image courtesy of enter on Flickr. |
Session Activities
Lecture Videos
- Lecture 5: Objects in Python (00:50:59)
About this Video
Topics covered: Tuples, lists, dictionaries, methods, identifiers, modifying objects, aliasing, mutability.
Resources
Check Yourself
What is mutability?
› View/hide answer
A mutable object's values can be changed; we must be careful when working with mutable objects not to inadvertently change them.
What is the important difference between a list and a tuple?
› View/hide answer
Tuples are immutable (as are strings).
What is cloning?
› View/hide answer
Cloning creates a copy of a mutable object, so that the values can be manipulated without mutating the original object.
What are the important aspects of a dictionary?
› View/hide answer
A dictionary is mutable, with immutable keys, and unordered.
Further Study
These optional resources are provided for students that wish to explore this topic more fully.
Readings
After watching the lecture, you may want to read some of the following resources:
- 8. Lists. How to Think Like a Computer Scientist.
- 9. Tuples. How to Think Like a Computer Scientist.
- 10. Dictionaries. How to Think Like a Computer Scientist.
- 5.1 More on Lists. Python Tutorial.
- 5.3 Tuples as Sequences. Python Tutorial.
- 5.5 Dictionaries. Python Tutorial.