Why Teach With Python?
Python is a great object oriented computer language that is very useful in introducing students to computer science. One of the major highlights of Python is the fact that it teaches proper coding technique and concepts, but is much easier to learn than some other, lower level, languages such as C++. C++ is a great language, but in introductory computer science classes using C++, much time must be spent teaching the conventions of C++ before true programming concepts can be addressed. This can be illustrated by comparing the traditional “Hello World” program in C++ and Python:
C++ Hello World Program
#include <iostream.h>
void main()
{
cout << "Hello, world." <<
}
Python Hello World Program
print "Hello, World!"
This example is cited from Jeffrey Elkner’s essay on why he chose to shift from teaching computer science using C++ to teaching with Python. If you would like to read a more indepth explanation of the merits of using Python to teach computer science, see his essay. Elkner is a teacher in Arlington, Virginia, and has had great success in teaching computer science with Python. In fact, Mr. Elkner has translated the textbook How To Think Like a Computer Scientist, originally written for Java, into a textbook to teach CS concepts using Python (this text is freely available, as it is licenced under the GNU General Public Licence, though you can also order it from Amazon if you like). This is a great, free resource that in itself is a compelling reason to consider using Python as the language of choice when teaching computer science. You can print out copies of the text, or simply have your students read it online.
Python is much more than a learning language, though. It is used in many modern applications, from the popular Google web search to a vast array of desktop applications (Python is available on Windows, Mac and *NIX). However, I will leave the task of convincing you that Python is a great language to others, and move on to describing how which resources to use in an introductory computer science course (CS 20 here in Saskatchewan) based on Python.
Computer Science Course Resources
- Guido van Robot
- Guido van Robot is a great unit to begin the semester with. The GvR language consists of 5 basic commands (see the command reference), and provides graphical feedback to the new programmer as (s)he works with the code. Interestingly, GvR was created by Jeffrey Elkner’s computer science class (using Python).
- There are 18 tutorials/mini-lab lessons that you can have your students complete to learn and explore the GvR language, which encapsulates a number of important CS concepts.
- I would recommend using GvR for the first couple of weeks of your CS20 class.
- How to Think Like a Computer Scientist: Learning with Python textbook
- free textbook available for reading online or printing out
- explains the basics of computer science in a very reader friendly way, while using Python examples to illustrate the points
- within the text are exercises that are very good in the classroom to confirm students understanding. These could be either hand-in assignments, or simply in class exercises, at the discretion of the instructor.
- does not assume that an IDE is being used while learning Python, which I believe to be a very good thing. There is no need for the students to worry about learning an IDE while also learning the basics of CS — learning about IDE’s could occur in a second course in CS (CS30). There are many Python IDEs, though one of the best is SPE (also see a tutorial on SPE).
- although I do not believe that an IDE is necessary in an introductory CS course, there is something to be said for syntax highlighting in your text editor. To this end, I would recommend having TextWrangler or SubEthaEdit available on your Mac OS X machines (both are freeware and Python syntax aware, along with a many other languages). On Windows machines, PSPad is a very good text editor.
- CS Practise Problems Archive
- a listing of practise problems that have been used in CS classes while teaching with Python. If you develop your own, submit them and help the archive grow!
- Modules useful for practise problems/fun examples
- a good module to use if you want to have your students retrieve current international weather information for use in their programs is PyMETAR. Makes utilizing current weather information quite simple.
- Fraction.py is a “fairly robust fraction class” that can come in really handy when dealing with fractional representations of numbers.
- PyBlogger is a Python wrapper for the Blogger and MovableType APIs (as of this writing)
- PyGoogle is a wrapper for the Google Web APIs. It allows you to do Google searches, retrieve pages from the Google cache, and ask Google for spelling suggestions.
- PyAmazon is a wrapper for the Amazon web API. Allows you to do Amazon searches by keyword, ASIN, UPC, author, artist, actor, director, manufacturer, list, similar, or best seller.
- IMDbPy is a Python package useful to retrieve and manage the data of the IMDb movie database about both movies and people.
- whois.py contacts the NetworkSolutions/Register.com whois database for each domain and displays the result.
- googlism.py module provides both Python module and command line access to googlism.com, the Web site which sifts through the results of the popular search engine Google and reports information about individual keywords.
- GeoIP Python API identifies the country of a certain IP address.
- dict.py is a module that speaks the DICT protocol used by dictionary servers.
- Various Useful Python Sites


