Python Tutorial

Arrays as Lists of Lists

« Previous | Next »

Python doesn’t have a formal array data type (although there are some very nice libraries for numerical computation, such as numpy, that support arrays). But we can make two-dimensional arrays using lists of lists, which we’ll explore in the next few problems.

The problems in the table below are taken from the 6.01 Python Tutor, an interactive environment that is not available on OCW. Do not try to answer these questions in the PDF files; answers will not be checked, and cannot be submitted.

6.1.1 What a bunch of zeros (PDF)
6.1.2 Setting an element of a vector (PDF)
6.1.3 A bigger bunch of zeros (PDF)
6.1.4 Setting an element of an array (PDF)
6.1.5 Add ’em up (PDF)

« Previous | Next »

Learning Resource Types
Lecture Videos
Recitation Videos
Problem Sets
Exams with Solutions
Lecture Notes
Online Textbook
Instructor Insights