skip to navigation
skip to content

Python Wiki

Python Insider Blog

Python 2 or 3?

Help Fund Python

[Python resources in languages other than English]

Non-English Resources

Add an event to this calendar.

Times are shown in UTC/GMT.

Add an event to this calendar.

EDU-SIG: Python in Education

More and more, Python is making inroads at all levels in education. Python offers an interactive environment in which to explore procedural, functional and object oriented approaches to problem solving. Its high level data structures and clear syntax make it an ideal first language, while the large number of existing libraries make it suitable to tackle almost any programming tasks.

Edu-sig, through its mailing list, provides an informal venue for comparing notes and discussing future possibilities for Python in education. Its origins trace to Guido van Rossum's pioneering Computer Programming for Everybody (CP4E), a grant proposal accepted by DARPA, and which provided a modicum of funding in 1999.

Membership includes, but is not limited to, educators using Python in their courses, independent developers, and authors of educational materials. Discussion focuses on Python use at all levels, from beginning to advanced applications.

Python 2 or Python 3 ?

Recently, a new version of Python (3) was introduced. This new version has some small but significant changes from the previous one. The most visible change for beginners is that print which used to be a Python keyword

>>> print "Hello World!"   # for Python 2

is now a function:

>>> print("Hello World!")   # for Python 3

As a result of the changes, programs written for Python 2 are likely to be incompatible with Python 3 (and vice-versa). Some of you may have not control over which Python version is made available to the students. If that is the case, you should not despair too much if you and your students do not have access to the best/latest version of Python: Python is a fantastic choice as a first language and the relatively minor changes between versions do not change this fact.

If you have some control over which version of Python is made available to the students, then you have a choice to make. In this case, and as a very subjective opinion, we would like to offer the following:

  • Use Python 3, and more specifically version 3.1, if you only plan to teach Python as an introductory language (say in a CS-1 course), making use only of modules included in the standard distribution. Alternatively, if you teach Python in languages other than English, where non-ascii characters could be put to good use in writing identifiers, then Python 3 should definitely be your choice.
  • Use Python 2, and more specifically version 2.6, if you think you might be using third-party modules not included in the standard Python distribution, or if you are not familiar with Python (in which case you may not yet realise that you might need some third-party modules.)
  • Consider the possibility of teaching both Python 2 and 3. If you are teaching beginners, the only significant differences are the print statement/function, the integer division and possibly the input()/raw_input() changes... which you can point out as you go along. Of course, you will have to decide on a common version to install for everyone to use.

Mailing lists, etc.

As mentioned above, the Edu-Sig community has its own mailing list. Two other mailing lists are of potential interest to educators: the python tutor and the general python-list. All three are available in a searchable archive on the ActiveState site which is also hosting the famous Python Cookbook. The python tutor mailing list is useful to beginners learning the language and looking for answers to their programming problems; educators are welcome to join as volunteers; the edu-sig mailing list is more for discussions about uses of Python in educational settings.

Free books and tutorials for educators

There are a number of freely available tutorials for Python. For example, there is a collection of Beginner's Guide to Python available on the Python wiki. In addition, the following may be of particular interest to educators:

  • pyBiblio is a site for teachers using Python to teach computer science and/or programming skills. It includes links to the free book How to Think Like a Computer Scientist Learning with Python as well as links to Gasp lessons adapted from LiveWires. An Introduction to Programming by Eric Rollins is an example of how this open source resource may serve as a basis for a specific course.
  • Think Python, by Allen B. Downey, is a substantially revised version of How to Think Like a Computer Scientist Learning with Python. It is available for free in various formats; printed copies can be purchased as well.
  • Python for Informatics: Exploring Information, by Charles Severance, is another book derived from the freely available How to Think Like a Computer Scientist Learning with Python mentioned above. As of January 2010, this book is only partially completed, with chapters available freely as pdf files.
  • Snake Wrangling for Kids is a free book written by Jason R. Briggs.
  • Dave Kuhlman's free book and other collection of tutorials is also a very good resource for educators.
  • Andrew Harrington's hands-on tutorial is suitable for high school and university-level CS-0 students. Dr. Harrington teaches at Loyola University Chicago.

Textbooks and other non-free books

While there are a number of free books and tutorials available, some people prefer to have an actual copy on paper. If you are among this group, you might be surprised to learn that there are close to one hundred books that have been written about Python programming. Here, we will focus only on a subset that are of potential interest for educators who teach introductory courses in programming. More books can be found here and here, or by doing an internet search.

For children, young and old:

University-level textbooks are also available:

Learning environments

Since Python is an interpreted language, all one needs to start programming is a terminal window. However, for your students, this would not be the friendliest environment; instead, we recommend that you use something like IDLE (which stands for Integrated DeveLopment Environment), which is included in the installation Python files on any platform that supports Tcl, including Windows.

As for yourself, if you prefer programming directly from a terminal window, a better choice than the default interpreter might be IPython.

In addition to IDLE, there are a number of third party tools which you can find out by referring to the Python Editors Wiki and the Python Integrated Development Environments Wiki.

There are also a few other non-traditional Python learning environments that you may wish to consider. First, some general purpose environments - all three work from a browser:

  • Crunchy is a Python program that can transform an otherwise static html tutorial into an interactive Python session within a browser. The basic features of an early version of Crunchy are demonstrated in this screencast.
  • A new "Mathematica-like" environment for Python is Codenode. You may want to try it yourself.
  • PyKata is a new online environment designed as a teaching aid for Python. It includes a small, but growing number of programming exercises that students can try on their own and get immediate feedback. Educators are invited to contribute their own exercises.

Some other notables, with more restricted goals, are the following:

  • Pyro is a Python programming environment for easily exploring advanced topics in artificial intelligence and robotics.
  • GvR, or Guido van Robot, strives to emulate the original Karel the Robot created by Richard Pattis. It uses an indentation-based Python-like language and about 20 lessons designed to teach programming concepts. An online demo is available.
  • RUR-PLE is a Python learning environment that includes an editor, a Python shell and, more prominently, a Karel the Robot clone that is programmable using Python syntax, using either procedural commands [e.g. move()] or an object-oriented approach [e.g. robot.move()]. It includes approximately 40 lessons. RUR-PLE was inspired from Guido van Robot.
  • Python's turtle module is not a learning environment as such, but it has been completely revamped for Python 2.6 and above and is worth checking out. Examples are included in the source distribution (along with a demoViewer program, which also serves as an example on how to embed turtle graphics into a Tkinter application.) For those that have older version of Python installed (2.3, 2.4 or 2.5), a suitable version of the turtle module can be found here., with the examples here. A video of the Pycon 2009 talk demonstrating the turtle module is available.

Videos

There is a growing body of podcasts, screencasts and video presentations for the Python community, many of which may be of interest to educators. For more details, please consult the Audio/Video Instructional Materials for Python

Specialized packages

Given the large number of modules included in the Python distribution, it is often said that Python comes with batteries included. If the standard distribution does not include what you need, you may want to consult the Python Package Index which is a repository that includes close to 7000 additional packages.

The following represent just a small sample of what is available.

  • NumPy is the fundamental package needed for scientific computing with Python. It contains:
    • a powerful N-dimensional array object
    • sophisticated broadcasting functions
    • basic linear algebra functions
    • basic Fourier transforms
    • sophisticated random number capabilities
    • tools for integrating Fortran code.
    • tools for integrating C/C++ code.
  • SciPy (pronounced "Sigh Pie") is open-source software for mathematics, science, and engineering. The SciPy library depends on NumPy, which provides convenient and fast N-dimensional array manipulation. The SciPy library is built to work with NumPy arrays, and provides many user-friendly and efficient numerical routines such as routines for numerical integration and optimization. Together, they run on all popular operating systems, are quick to install, and are free of charge. NumPy and SciPy are easy to use, but powerful enough to be depended upon by some of the world's leading scientists and engineers. If you need to manipulate numbers on a computer and display or publish the results, give SciPy a try!
  • matplotlib is a python 2D plotting library which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms. matplotlib can be used in python scripts, the python and ipython shell (ala matlab or mathematica), web application servers, and six graphical user interface toolkits. matplotlib tries to make easy things easy and hard things possible. You can generate plots, histograms, power spectra, bar charts, errorcharts, scatterplots, etc, with just a few lines of code.
  • PIL, the Python Imaging Library adds image processing capabilities to your Python interpreter. This library supports many file formats, and provides powerful image processing and graphics capabilities.
  • OpenOpt is a free optimization framework which builds upon Numpy. In addition to various numerical optimization packages, it includes:
    • FuncDesigner - a tool to rapidly build functions over variables/arrays and get their derivatives via automatic differentiation. Also, one can perform integration, interpolation, solve systems of linear/nonlinear/ODE equations and numerical optimization problems coded in FuncDesigner by OpenOpt.
    • DerApproximator - a tool to get (or check user-supplied) derivatives via finite-difference approximation.
    • SpaceFuncs - a tool for 2D, 3D, N-dimensional geometric modeling with possibilities of parametrized calculations, numerical optimization and solving systems of geometrical equations.
  • VPython makes it easy to create navigable 3D displays and animations, even for those with limited programming experience. It includes a modified version of IDLE.
  • ReportLab gives Python programs the power to output directly in Adobe's PDF format. The open source version is fully functional in the hands of a Python programmer. Useful for publishing course materials.
  • SymPy is a Python library for symbolic mathematics. It aims to become a full-featured computer algebra system (CAS) while keeping the code as simple as possible in order to be comprehensible and easily extensible. SymPy is written entirely in Python and does not require any external libraries.
  • Sage is not a Python package but offers an environment showcasing Python as a programming language. It is a free open-source mathematics software system licensed under the GPL. It combines the power of many existing open-source packages into a common Python-based interface. Sage's mission is to create a viable free open source alternative to Magma, Maple, Mathematica and Matlab.
  • Blender is a cross-platform 3D modeling suite, offering modeling, animation, interactive creation and playback. Blender is not a Python package but it does use Python for scripting support.
  • An Object-Oriented Graphics Package has been written by Michael H. Goldwasser and David Letscher to use in conjuction with their textbook (referenced above).

Academic papers

A number of academic papers have been written about using Python as a programming language. They include the following:

And finally, while it is not an academic paper, Why Python is a great language for teaching beginners in introductory programming classes by Philip Guo is certainly worth reading.

Game time!

If it weren't for games, there likely would have been many fewer people interested in programming - and much less free software developped as a result. Python has two well-known frameworks for making games:

  • pygame is the original and still very much active package for game development using Python. It allows Python to talk to SDL, a cross-platform, multimedia library. Because it needs to be compiled for each platform and each Python version, there can be a lag when a new Python version comes along.
  • pyglet is the newcomer, based on OpenGL. Because it is a pure Python package, it can be used as is even when a new Python version is released (except for the Python 2 to Python 3 transition).

Miscellaneous

SIG administrivia