Session Overview
In this session, we expand on programming, introducing other programming paradigms and indicating features of Python that tie in to notable programming concepts. We also introduce state machines. State machines model systems that are functional, but also have memory. State machines are incredibly general, but incredibly powerful, and can be used to model all kinds of systems, as you'll see in future sessions. You can use state machines to control, model, and predict behaviors in systems. The overview handout provides a more detailed introduction, including the big ideas of the session, key vocabulary, and what you should understand (theory) and be able to do (practice) after completing this session. |
Session Content
Readings
Read chapter 4 of the course notes.
Lecture Video
Watch the lecture video. The handout and slides present the same material, but the slides include answers to the in-class questions.
-
Lecture 2: Primitives, Combination, Abstraction, and Patterns (01:20:09)
Lecture 2: Primitives, Combination, Abstraction, and Patterns
> Download from iTunes U (MP4 - 181MB)
> Download from Internet Archive (MP4 - 181MB)
About this Video
Discussion of imperative, functional, and object-oriented programming styles. State machines are introduced, using a turnstile as an example.
Recitation Video
These videos have been developed for OCW Scholar, and are designed to supplement the lecture videos.
Session Activities
The problems in the tables below are taken from the 6.01 Online 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.
Software Lab
- Software Lab 2: State Machines (PDF)
- Code for Software Lab 2 (ZIP) (This ZIP file contains: 1 .py file.)
PROBLEM # | QUESTIONS |
---|---|
2.1.1 | State machines (PDF) |
2.1.2 | Turnstile state machine (PDF) |
2.1.3 | Double delay state machine (PDF) |
2.1.4 | Comments machine (PDF) |
2.1.5 | First word machine [optional] (PDF) |
Design Lab
- Design Lab 2: Controlling Robots (PDF)
- Code for Design Lab 2 (ZIP) (This ZIP file contains: 1 .py file.)
Additional Exercises
PROBLEM # | QUESTIONS |
---|---|
2.3.1 | Inheritance I (PDF) |
2.3.2 | Inheritance II (PDF) |
2.3.3 | Inheritance and state machines (PDF) |
2.3.4 | Introduction to recursion (PDF) |
2.3.5 | Slow mod (PDF) |
Check Yourself
Nano-Quiz
Nano-quiz problems and solutions are taken from a previous version of the 6.01 Online Tutor. Do not try to answer these questions in the PDF files; answers will not be checked, and cannot be submitted.
Homework
Homework 1 refers to five questions in the Online Tutor. In this case, PDF files for each question have not been provided, since they do not contain any additional content beyond what is described in the handout below.
- Homework 1: Calculator (PDF)
- Code for Homework 1 (ZIP) (This ZIP file contains: 1 .py file.)