- Read the chapter entitled Lists
from section "Nested Lists" through section "Glossary".
- Lists can be nested, e.g. [["Montana", 1015165], ["Wyoming", 582658]]
- A list can be created from a string
- declaration = "Four score and seven years ago"
- A string can be created from a list
- seuss = ["green", "eggs", "and", "ham"]
- glue = "*"
- Sequences can be converted into lists, e.g. list("Bozeman Hawks")
- A tuple is like a list, except that it is immutable,
e.g. today = ("Monday", "February", 13)
- This page
contains 2013 census information when the total population of the U.S.
- The file nested-lists.py contains
information about the 10 most populous states.
- Add a pure function to nested-lists.py that calculates and
returns the total population of the information passed into it.
Print this value after the function returns it.
- Modify the program to also print the percentage of the U.S. population
that lives in the 10 most populated states.
- Modify the populations variable to include information
about whether each state is landlocked. Consider
a landlocked state to be one that does not touch the
Atlantic Ocean, the Pacific Ocean or the Gulf of Mexico.
- Modify the program to also calculate and print
the percentage of the population
in the 10 most populated states that live in a landlocked state.
- Time permitting, make other interesting enhancements.