Teaching Python to Beginners

One idea from a book that left a deep impact on me was about the surgeon’s culture of teaching. Residents practice the philosophy of “see one, do one, teach one,” with the implication that first you watch how a procedure is done, then you do it yourself, then you can teach it to others. When you can teach a skill to others,  you’ve mastered it. 

In software, we don’t really have this formalized apprenticeship structure  (as I wrote about for the Increment), but it’s still generally understood that if you can teach something you know to beginners, then you understand the concept well yourself. 

I was recently invited to teach Python for Beginners at WSDS, the American Statistical Association’s Conference for Data Science, and got to try out this idea in practice.

I thought it would be relatively easy to put together a slide deck that focused on a two-hour intro course, but it was, of course, much harder than I anticipated, for several reasons. 

Teaching what you forgot is hard

Teaching  beginners is tricky for many reasons, but the most important is that, usually, the  teacher has forgotten what it’s like to be a beginner. As I’ve written before:

The amount of cognitive overhead needed to be a developer today results in a problem I’ve seen with senior developers sometimes. They forget how much context people need to learn in order to become proficient at development. And they forget that they were beginners once, too.

Think about how complicated computers are in general, and how many layers of things need to work together, and how you need to have at least some high-level understanding of how those layers of things work, and you’ll get a better understanding of what a junior developer is up against. 

In creating the content for this course, for example, here are some things I forgot that beginners to Python, coming from other statistical programming packages, probably don’t know: 

  • How to use the command line.
  • Whether to use Python 2 or 3.
  • What a Jupyter notebook is in the context of Python.
  • How to import libraries and what pip is.
  • Formatting a Python script.
  • How to run Python.
  • Where to find it on your computer.

There are probably tons that I’m missing. Because I use Python every day these things have become second nature to me through lots and lots of repetition. 

The best way I’ve found to combat this is a couple of different approaches:

  • Go slowly and don’t combine too many concepts, or introduce them piece by piece. In my course, I needed to teach an introduction to Python, how to write a Python program, how to use Colab notebooks, and then how to use them for data science. I broke out each piece sequentially so that each concept built on each other. 
  • Being able to do small bits of work right away. If you’re trying to teach people to use Python, the most important thing is to have students writing code as quickly as possible. As soon as people feel empowered to write a tiny piece of code, they’ll want to write more right away. Theory can be hard from the get-go, especially if you’re trying to explain several concepts at once. 
  • Teach to use cases. My use case was analyzing a data set of avocado prices. I find it much easier to help beginners through a specific task and explain components as I go rather than delve into theory without any practical applications. 
  • Explain abbreviations, or ask the class to stop you if they come across one they don’t know. As experts, we use things like API and CLI all the time without thinking about it, forgetting that beginners are learning not only a new language but also the acronyms we use when we talk about it. 
  • Teach through analogy. It’s much easier to explain things in familiar terms rather than using technology-based examples when beginners are just starting out. Later on, it’s possible to build on concepts. 

Python is hard to install

Python is a fantastic language for beginners because its syntax is more like reading English than other languages. However, within this ease, there is a lot of complication around setting up and installing Python, and it’s always the case that, even for seasoned experts, Python environments can break.  

In a remote class, especially one that’s only several hours long, there’s not really the luxury of helping everyone set up and fix their Python environment, so I wanted to abstract all that way from beginners.

I looked into a couple of different solutions. In the end, I chose Colab notebooks from Google. Ultimately, this is the easiest way to teach Python these days, I think, because it offers everyone (who has a Google account) the exact same environment and experience. They’re easy to run, easy to save, and easy to share. They also have the added bonus of version control, the same kind built into Google Docs. It’s another plus for them that they are similar to other products people use already. It ended up going really well. The only issue we had was of pointing to other files in Google drive as people had different folders. 

Teaching online requires a different kind of empathy

Teaching in-person is built a lot on understanding people’s cues, looking for confusion, being able to pause, the ability to raise your hand, and ask questions. As teachers all around the world can attest, this has become pretty hard with the onset of digital learning. 

I didn’t mandate that my students do video so they could be comfortable, so it was really hard to see whether something made sense to people, or whether I should pause and spend more time on a given concept.

A couple of things I did during the course to help: 

  • Tell people that they’re free to have their camera on or off, and to make themselves comfortable.
  • Get a sense for the members of the class by taking a quick poll of their backgrounds at the beginning.
  • Ask people to raise their hand if they don’t understand something, and monitor the chat box to see if there are questions that others may have.
  • Reiterate the question to everyone in the class so that everyone’s on the same page.
  • Give people my email address to reach out afterward.
  • Take a deep breath and talk more slowly than I would have initially so I could go over each slide in detail. 

Ultimately, once I navigated these issues, I think the course went well. I’m excited to use the material again for teaching more people about the wonderful data ecosystem that is Python.

One thought on “Teaching Python to Beginners

  1. Most learning experiences in computing are enhanced by having a specific project or task – if you have to eventually print out a report that puts together pieces from various places into a title, for example, you will pay more attention to how to concatenate.

    That’s why lessons have homework in school.

    Online, and at a conference, it might be hard to do the same.

    I wish everyone paid as much attention to the basics as you did.

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s