How IPython Notebook and Github have changed the way I teach Python

A live notebook about how to use lists in Python.

A live notebook about how to use lists in Python.

I teach in a small high school in southeast Alaska, and each year I teach an Introduction to Programming class. I recently learned how to use IPython Notebook, and it has completely changed the way I teach my classes. There is much to improve about CS education at the K-12 level in the United States, and sharing our stories and our resources will go a long way towards improving what we offer to students.

My first programming classes

3d Modeling

How I tend to use Python: A model of a koch snowflake, and the real thing printed in stainless steel. I wrote a Python program to generate the OpenSCAD code for printing the model.

Like many people who teach Intro to Programming classes, I don’t have a formal CS degree. I started programming as a kid, and then went on to a degree in Physics. I have always programmed for fun, however, and recently I have started to take my programming more seriously. As I have taken my own programming more seriously, I have been looking for ways to bring it into my teaching.

The first time I taught an introductory programming class, I created lessons each day and came up with exercises and challenges for students to try. Students loved the class, because they spent most of their time trying to apply what they were learning to problems they could solve. They felt like real programmers from the first day of the session. The class was a nice start for me as a programming teacher, but we didn’t get very far. It was just too hard to create curriculum at a pace that kept up with my more capable students. As someone without a formal CS background, there was also plenty I had to clarify for myself along the way.

The second time around, I tried to base the class on an established curriculum. I tried to use Zed Shaw’s Learn Python the Hard Way, because I had heard such consistently good things about it in all the tech communities I participate in. It didn’t work out though, because students just did not catch on to the approach of LPTHW. I know LPTHW asks students to write their own programs, but for people brand new to programming, there was just too much left to them to figure out, even with a teacher in the room. I have one student who really enjoyed it, but for most students we didn’t get a whole lot further than my first class, and they had a lot less fun along the way. This is not a criticism of Zed’s work, it is an admission that I did not use his curriculum in a way that captured my students’ interest in programming. My students seemed to respond better to very specific exercises based on what they just learned, with a more gradual transition into exercises and challenges that ask them to apply their own ideas to what they have just learned.

This year’s class

This time through, I wanted to go back to creating my own lessons, with more efficiency than I had before. I also needed a backup plan for students who might outpace my teaching. I heard about IPython Notebook every day at PyCon this past year, so I decided to take a look at it. Once I got used to it, I couldn’t believe how effective it could be as a tool for teaching.

An active editing session in IPython Notebook. Each cell can either be text or code, and code cells can be run as independent programs.

An active editing session in IPython Notebook. Each cell can either be text or code, and code cells can be run as independent programs.

If you are unfamiliar with IPython Notebook, it basically lets you mix Python code and text on the same page, and lets you run your code blocks as separate programs. IPython Notebook was developed for scientific programming, where you want to solve a larger problem through a series of smaller programs, with notes in between about your progress. This approach allows for a much more efficient workflow than having to write a bunch of separate program files, with your notes in separate text files.

As a teacher, I found this was a perfect tool for creating lessons. I write a few notes about a topic, then write a small program to illustrate how to implement the topic in code. IPython Notebook makes it easy to develop these lessons locally, and GitHub makes it easy to store these notebooks in a publicly accessible place. The IPython Notebook Viewer then makes them available in a reader-friendly format.

My basic workflow:

  • I created a notebook for the syllabus I’d like to follow.
  • For each topic in the syllabus, I create a local notebook which will hold lessons for that topic.
  • When I have time, I create lessons at home and push them live.
  • I always teach with my computer hooked up to a projector. When I clarify something during a lesson, I push the changes to GitHub as soon as the lesson is over.
  • If I cover a new topic in class, I write my examples directly in one of the notebooks. If the live work is clean enough, I push it straight to GitHub. If the live work needs a bit of cleanup, I commit locally and then push it live after class, when I have the chance to look it over more carefully.
  • If a student starts to outpace me, I can steer them into something more established such as Udacity or Coursera. These are the students who are likely to be successful in more independent learning settings.

Results so far

This workflow has been extremely satisfying so far, for me and for my students. We are having as much fun as we had the first year I taught a programming class, but we are covering things much more quickly as well. I can see a number of benefits in this workflow:

  • Students can have a copy of all class materials open on their own computers, and accessible outside of class.
  • We can add and modify exercises and challenges at will, throughout the class.
  • Students get to see some of the tools they will use when they become more proficient, such as git, GitHub, IPython, and others.

What’s next?

I really want to figure out a way to embed programming in my school culture throughout the year. A few thoughts about how to move forward on this goal:

  • Continue to develop the notebooks throughout this session. Some of this involves converting old blog posts into IPython notebooks.
  • Develop a core set of assignments that students can do in any class, that use their programming skills to help them in their other classes. For example, use your understanding of Python’s dictionaries to keep track of the key words you are learning in each of your classes.
  • Set up a system where students who reach a certain level of skill and understanding begin to teach newer students, using our class materials. This would take the pressure off of me to always teach introductory courses, and would let me teach some more advanced classes.
  • Clean up the notebooks, so they stand on their own rather than serving as class notes. Right now, they don’t read well for independent learning. This could be improved, although they probably shouldn’t get too wordy.

Collaboration

If you’d like to play with these notebooks, check out the project page on GitHub. I’d be happy to collaborate on building out these resources, so get in touch if you’d like to contribute. I can be reached through email, ehmatthes at gmail, or twitter @ehmatthes. If you are active on GitHub, you can also leave feedback on Issue #10.

About ehmatthes

I'm a writer and a programmer, and I like to spend time outside.
This entry was posted in programming and tagged , , , , , . Bookmark the permalink.

12 Responses to How IPython Notebook and Github have changed the way I teach Python

  1. jjmerelo says:

    Great job, and thanks for sharing. I didn’t know Python; I do use GitHub in class, but it’s university-level in something that could be described as Cloud Computing 101 http://jj.github.io/IV
    There are similar literate programming tools like Knitr or SWeave that work with R, and there’s probably something like that for Ruby… I’ll check it out.

  2. Palak Mathur says:

    Nice work and nice to learn about IPython Notebook. I am a Java programmer trying my hands on Python. This looks a nice way to create tutorials, etc.

    I appreciate the effort you are making in teaching CS to your students. All the best.

  3. jjmerelo says:

    Man, does that look ugly, so much JSON an’ stuff; so much markup gets in the way of writing your thoughts fluidly. Did you try other things like PyLit? http://pylit.berlios.de/tutorial/index.html Just curious.

  4. I love it! I’m also trying to use IPython Notebook to teach, albeit in a much more decentralized way. You might also benefit from the use of Vagrant in combination with IPython Notebook depending on which environments that you need to support. I write about some of my experiences at length in this post that also includes a link to a companion screencast illustrating the whole process – http://miningthesocialweb.com/2013/08/24/reflections-on-authoring-a-minimum-viable-book/

  5. Brad says:

    I love iPython, and use it in several of my classes. Here’s another free online resource that you might find useful for introductory programming for high schoolers. http://interactivepython.org

  6. Really great post, thanks for sharing!

    A friend of mine just recently open-sourced a student-centric learning platform he built using Python. Perhaps it’d be useful for your class: http://vikparuchuri.com/blog/open-sourcing-movide/

    • ehmatthes says:

      Thank you for sharing Vik’s project, it looks really interesting. I left a note on his blog post, and I look forward to taking a closer look at movide.

      I’m also looking forward to getting in touch with him. There is some really important work to do in bringing education up to speed as far as open source goes, and it is a pleasure to keep finding people who are doing really strong work in this direction.

  7. ashleearda says:

    I write on online free note book. It is very easy to use and open. Some times I take my laptop with me and I write all important points on It.

Leave a comment