Lecture 11 — Lists¶
Overview¶
So far we’ve looked at working with individual values and variables.
We realized that this is cumbersome and so we started working with iterables like Tuples.
This is a way to aggregate multiple values and refer to them using a single variable.
With Lists we will get acquainted with an extremely flexible iterable object type in Python.
Unlike tuples or strings, Lists are mutable as we will learn.
This lecture is largely based on Sections 8.1-8.3 of Practical Programming.
Lists are Sequences of Values¶
Put together values that have common meaning.
As a first example, here are scores of 10 students for a test:
scores = [95, 78, 63, 63, 68, 84, 88, 93, 71, 80]
As a second example, here are the names of the planets in the solar system:
planet_names = ['Mercury', 'Venus', 'Earth', 'Mras', 'Jupiter', 'Saturn', 'Neptune', 'Uranus']
Notes on syntax:
Begin with
[
and end with]
.Commas separate the individual values.
The spaces between values are optional and are used for clarity here.
Any type of object may be stored in a list, and each list can mix different types.
Lecture Video (s)¶
https://www.youtube.com/watch?v=IXg-03Di4iA&feature=youtu.be