This is a collection of notebooks that form the "lecture" notes for an Introduction to Programming class that I teach each year.
I put "lecture" in quotes because these are really presented as brief mini-lessons. After participating in a mini-lesson, students are presented with a set of exercises and challenges that ask them to use and apply what they have just learned. Students have access to the notebooks as they are working through the exercises and challenges.
This approach aims to maximize the time students spend applying what they have seen, which is the fun part of programming. This approach minimizes the time students spend asking me to repeat what I showed them in the lesson, which is the boring part of teaching and learning.
In this notebook, you will learn to store more than one valuable in a single variable. This by itself is one of the most powerful ideas in programming, and it introduces a number of other central concepts such as loops. If this section ends up making sense to you, you will be able to start writing some interesting programs, and you can be more confident that you will be able to develop overall competence as a programmer.
By this point, you have learned enough Python to start building interactive apps. If you are set on the larger projects such as building a video game, making a visualization, or making a web app, you can skip this section. But if you would like to start building some simpler apps that run directly in your terminal, check out this notebook.
Terminal apps are a great way to build the core functionality of a program you are interested in, which can then be extended into a more accessible format.
So far we have learned about Python's core data types: strings, numbers, lists, tuples, and dictionaries. In this section we learn about the last major data structure, classes. Classes are quite unlike the other data types, in that they are much more flexible. Classes allow you to define the information and behavior that characterize anything you want to model in your program. Classes are a rich topic, so we will learn just enough here to dive into the projects you'd like to get started on.
The programs that we write can quickly become complicated, and with complexity comes bugs. Programmers have long accepted that every program will have its share of bugs. To deal with this, we have come up with many ways to defend against avoidable bugs. Learning to write tests is one of the best things you can do to guard against avoidable bugs creeping into your own programs. Basically, you write a set of tests that you then run against your program every time you or someone else changes the program. These tests, if written correctly, prove that changes to the code do not break anything that was working previously.