Programming with Python

This set of episodes will introduce some features of Python which will hopefully help you be more productive.

Some of the things you learn here will show you a different way to do things you’ve probably done before - this does not mean that either way is “right” or “wrong”, but as you become more experienced you’ll become aware of when it’s more appropriate to use particular techniques.

Most of the episodes in this lesson are relatively abstract, rather than following a story like the novice Carpentry courses do; however, hopefully you will see places in your own code that you will be able to use these techniques.

As with the novice courses, we believe that the best way to learn is by practicing and following along with the code. The helpers are around so please feel free to ask if you can’t get something working.

Prerequisites

You need to understand the concepts of files and directories and how to start a Python interpreter before tackling this lesson. This lesson sometimes references Jupyter Notebook although you can use any Python interpreter mentioned in the Setup.

The commands in this lesson pertain to any officially supported Python version, currently Python 3.7+. Newer versions usually have better error printouts, so using newer Python versions is recommend if possible.

Getting Started

To get started, follow the directions on the “Setup” page to download data and install a Python interpreter.

Schedule

Setup Download files required for the lesson
00:00 1. Creating Functions How can I define new functions?
What’s the difference between defining and calling a function?
What happens when I call a function?
00:30 2. Errors and Exceptions How does Python report errors?
How can I handle errors in Python programs?
01:00 3. Defensive Programming How can I make my programs more reliable?
01:40 4. Debugging How can I debug my program?
02:30 5. Functional Programming What is functional programming?
Which situations/problems is functional programming well suited for?
03:30 6. Command-Line Programs How can I write Python programs that will work like Unix command-line tools?
04:00 7. Verifying Code Style Using Linters What tools can help with maintaining a consistent code style?
How can we automate code style checking?
04:25 Finish

The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.