Notice: While JavaScript is not essential for this website, your interaction with the content will be limited. Please turn JavaScript on for the full experience.

EDU-SIG: Python in Education

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 ?

Several years ago, 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, we would like to offer the following:

  • Use Python 3, and more specifically version 3.4, if you can, making use of the growing number of third-party libraries available for it. This is especially true if you plan to teach Python as an introductory language (say in a CS-1 course), since Python 3 is the future of Python. Also, 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.7, if you need third-party modules which have not yet been porteded to Python 3.

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:

  • 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.
  • 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:

System Message: WARNING/2 (<string>, line 208); backlink

Duplicate explicit target name: "a primer on scientific programming with python".

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.

Learning resources

These are resources, interactive on-line tutorials, and other educational resources that either help teach python or use Python to teach programming.

  • Online Python Tutor is a free educational tool created by Philip Guo that helps students overcome a fundamental barrier to learning programming: understanding what happens as the computer executes each line of a program's source code. Using this tool, a teacher or student can write a Python program in the Web browser and visualize what the computer is doing step-by-step as it executes the program.
  • The Interactive Python website has live python books that provide learners the ability to run python code in the browser and see visualizations of their running programs.
  • Python for Fun is a collection of small python programs aim at intermediate programmers that explore a wide range of computer science concepts - including logic circuits and AI.
  • Pynguin is a unified editor, interactive console, and graphics display area written using Python and the PyQt toolkit. Pynguin is meant to be an easy environment for introducing programming concepts to beginning programmers. Pygnuin programs generate digital images that can be saved as SVG or PNG files.
  • 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.
  • 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. A new web-based version, Reeborg's World, has more tutorials than those available with the desktop version.
  • 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

  • Python for secretaries: A resource site aimed at showing business users how to use a little bit of Python, focused entirely on helping them with their regular workaday duties.
  • Freely-reusable data: Instructors often have need of meanful data for constructing programming exercises. To support this usage, many in the educational community have contributed freely-reusable data on which to build.
  • Software Carpentry by Greg Wilson is a course on software development skills for scientists and engineers.
  • Kirby Urner's CP4E resources integrate Python programming with topics in mathematics.
  • An Interview with Guido van Rossum, by Phil Hugues for the Linux Journal, is a conversation with the creator of Python about an effort to teach Python to non-computer science students.
  • Hackers and Trackers: CP4E and Teaching Math with Python, both by Stephen Figgins, are older articles about the beginning of the Computer Programming for Everybody initiative.

SIG administrivia