Think Python
by Allen Downey, 2012
Olin College, MA
This textbook is open-source; we have reorganized and edited it to match our course syllabus.


Python 3


Introduction to solving computational problems, including the fundamentals of computer programming. Topics include imperative programming constructs (variables, loops, conditionals, functions, recursion), basic object-oriented constructs (classes, objects), and some fundamental algorithms and data structures (dictionaries, arrays, linked lists, basic sorting). Student learn these concepts through studying the Python programming language.

At the end of the course, you will be expected to be able to:

  • Read, understand and execute a computer program written in Python.
  • Read a set of requirements for a computer program in English, and write a short Python program (100 lines or less) that corresponds to them.
  • Test a Python program and identify and fix programming errors.
  • Identify some errors in a Python program without testing it.
  • Without using a computer, write a very short Python code fragment (10 lines or less) that correctly implements a set of requirements.
  • Understand and apply variables, loops, strings, lists, conditionals, and functions.
  • Write programs to perform mathematical calculations.
  • Understand the concept of a module.
  • Write a Python program that is separated into at least two modules.
  • Understand the concepts of class and object, and distinguish between them.
  • Write a Python program including objects of at least one student-designed class.
  • Write and understand appropriate comments in a Python program.
  • Understand the concept of an algorithm and compare the efficiency of different algorithms for a simple task.


It is the policy of Hendrix College to accommodate students with disabilities, pursuant to federal and state law. Students should contact Julie Brown in the Office of Academic Success (505.2954; brownj@hendrix.edu) to begin the accommodation process. Any student seeking accommodation in relation to a recognized disability should inform the instructor at the beginning of the course.

Academic Integrity

All Hendrix students must abide by the College’s Academic Integrity Policy as well as the College’s Computer Policy, both of which are outlined in the Student Handbook.

For specific ways the Academic Integrity policy applies in this course, please refer to the Computer Science Academic Integrity Policy.

The short version is that academic integrity violations such as copying code from another student or the Internet are easy to detect and will be taken very seriously.

If you have any questions about how the Academic Integrity policy applies in a particular situation, please contact me.


Please do not bring laptops to lecture. This may seem strange in a computer science class. But lab is the place where you will get plenty of experience working on the computer; lecture is a time for thinking and learning without the distraction of a computer.

Exceptions may be made on a case-by-case basis if you can prove to me that you really do benefit from using your laptop to take notes.


PDF syllabus

We will be covering most of the material in the textbook, approximately one new chapter each week. You should view your textbook as another perspective on the material presented in class and covered in the labs. We will also be using additional supplemental material such as relevant web pages and background material for the lab assignments. Readings will be assigned before material will be covered in class. You are expected to review the material and come to class prepared.

Homework and quizzes

There will often be short homework assignments to be completed over the weekend, assigned on Friday and due Monday, along with a corresponding quiz at the beginning of class on Monday.

These quizzes and homework assignments together will comprise 15% of your final grade.

HW Due
0: Who Are You January 20
1: Communication and Origami January 23
2: Logic puzzles January 30
3: Function reading February 13
4: DNA Strings February 22
5: While, string, and list reading February 27


Much of your experience with programming in this course will be through weekly labs, which will comprise 25% of your final grade. Each lab will be assigned Thursday morning in lab with time allotted to work through the materials, and will be due by the following Tuesday at 10pm. All labs are weighted equally within the lab portion of your final grade.

Each student has four late days to spend throughout the semester as they wish. Simply inform me any time prior to the due date for an assignment that you wish to use a late day; you may then turn in the assignment up to 24 hours late. Multiple late days may be used on the same assignment. There are no partial late days; turning in an assignment 2 hours late or 20 hours late will both use 1 late day. Note that late days are intended to cover both normal circumstances (you simply want more time to work on the assignment) and exceptional circumstances (you get sick, travel for a game or family obligation, etc.). Aside from late days, late assignments will not be accepted.

On these labs, you may work with a partner on the lab assignments if you choose. Their name must be listed on any code you hand in as joint work. A partnership need only turn in a single copy of the assignment. If students working as partners wish to turn in a lab late, both students must use a late day.

Lab attendance is required. Labs take place in the Snoddy Computer Lab, in the Bailey Library. As you go through the exterior door of the library, turn immediately to your left and enter the Snoddy Academic Resource Center, through this door:

Continue through the door at the far end of the hall (just visible in the picture above) into the first computer lab, and then enter the second lab at the back.

You will be handing in your lab work via Moodle. Instructions to do so will be included in each lab.

Labs should follow the Python style guide. You may use the automated style checker to help you catch common style errors.

Lab Name Assigned
1 Minecraft Hour of Code Jan 19
2 Kepler and Newton Jan 26
3 Diagnosing Heart Disease Feb 2
4 Guess My Number Feb 16
5 Mutation is the Word Feb 23
7 Caesar’s Secrets Mar 2
8 Fractal Recursion Mar 16


You will have three projects in this course, one about every five weeks, for a total of 35% of your final grade. These projects will cover concepts we have discussed in class and in labs, and will be due approximately one week after they are assigned.

You must work individually on the first two projects. You may discuss concepts and ideas with your classmates, but the code you turn in must be your own. You will be graded not only on correctness, but also technique, documentation and evaluation of your solution. Further details on the grading standards and handin instructions for each project will be given when they are assigned.

Project Name Pct Assigned Due
1 Question-Answer 5% Feb 9 Feb 16
2 Word Games [ Sample project start ] 10% Mar 9 Mar 16
3 Final Project 20% Apr 10 Friday, May 5, 2pm


There will be three in-class exams, the first worth 5% and the last two each worth 10% of your final grade. They will consist of short answer questions along with writing and debugging code.

  • Exam 1: Wednesday, February 8, covering input/output, math, numerical data, conditionals, and binary encoding (Practice exam)
  • Exam 2: Wednesday, March 8, covering functions, while and for loops, lists and strings (Practice exam; Practice exam solution code; Bonus functions due Wednesday after spring break (March 29))
  • Exam 3: Friday, April 21, covering recursion, dictionaries and object-oriented programming

There is no final exam; you will complete a final project instead, as described above under Projects.


Your final grade for this course will be based on the Labs, Projects, Quizzes, Exams and Participation described above.

Component Percent
Labs 25%
Projects 35%
Quizzes, HW, participation 15%
Exam 1 5%
Exam 2 10%
Exam 3 10%