An Animated Introduction to Programming with Python

Laura Mahoney, Mark Mahoney

This is an introduction to programming using Python. The Python programming language has been around for many years and is incredibly popular. It is a friendly programming language that is intuitive. There are many libraries and frameworks that use Python for things like data science, scientific computation, and web development. It is a great first language to learn.

What you will see in this 'book' is a collection of code playbacks. Playbacks were designed to help guide a reader through code examples. You will get to see how I build programs up from scratch and hear me explain it in comments that I make along the way. These comments will have text, screenshots, and hand drawn pictures. This will allow you to get inside my head and hopefully this will demystify the programming process. When you click on a playback title below it will open a new tab. Then, just click on the comments on the left hand side of the screen and you will be guided through the code.

Some of the programs that I will show you use the Jython Environment for Students (JES). JES was developed to make it easy to introduce programming to people using examples of 'media computation'. This means that the JES allows people to write Python code that manipulates images, sounds, and videos. You are not required to use JES to get the most out of this book. There is a lot of general Python knowledge explained in these programs that uses plain old Python. Whether you use JES or not I believe it will be valuable to view the playbacks that invlove it. They are marked with JES below.

If you'd like to stay connected and get updates when I add new playbacks you can follow me on twitter: @markm208.

You are ready to begin! Click on the first playback below to begin your journey to learn how to program.

1.1 Printing and 'flow'
1.2 Arithmetic and comparing numbers
1.3 Programming with Data
1.4 Distance Between Two Points
1.5 More with Strings
1.6 *JES* Prompting the User for Some Information
1.7 *JES* Showing a Picture
1.8 *JES* Accessing Pixels
1.9 *JES* Adding a Caption to a Picture
2.1 Iterating Through a String
2.2 Lists and Iteration
2.3 Splitting Strings
2.4 Ranges
2.5 Reading from a File
2.6 Writing to a File
2.7 *JES* Iterating Through Pixels
2.8 *JES* Graying an Image
2.9 *JES* Copying an Image
2.10 *JES* Enlarging a Picture
3.1 Comparisons by the Computer
3.2 if, if/else, and if/else if/else Statements
3.3 Logical Operators
3.4 Loops
3.5 *JES* Adding a Border to a Picture
3.6 *JES* Finding the Predominant Color in a Row
4.1 Python Lists
4.2 Python Dictionaries
4.3 Python Sets
4.4 *JES* Storing User Supplied Data in a Dictionary
5.1 A First Function
5.2 Function Return Values
5.3 Parameters
5.4 Scope of Variables
5.5 Pass by Reference or Pass by Value
5.6 Sorting with Functions
5.7 *JES* Adding Text (Again) and Saving a File Using Functions
5.8 *JES* Shrinking a Picture
5.9 *JES* Making a Movie with Moving Text
6.1 Classes
6.2 Class with Data and Methods
6.3 Classes that Interact with Each Other
6.4 Inheritance
6.5 *JES* Photo Resizing/Rotating Class