[Edu-sig] Python @ Education: What are your problems?

Michael Williams michael.williams@st-annes.oxford.ac.uk
Thu, 30 May 2002 12:16:23 +0100


On Thu, May 30, 2002 at 12:47:25AM +0200, Ingo Linkweiler wrote:
> are you using python for teaching programing?

We're about to start. We've been running quasi-competetive trials of
Python and C, with a view to replacing the current Pascal implementation
of the undergraduate programming syllabus here as the University of
Oxford's Physics department.

> I am just writing a diploma paper about python and want to know your
> experiences with python.
> 
> What do you like when teaching python?
> For example:
> - Easy readable syntax

Check.

> - High Level language

Check. We would never consider teaching anything ``low-level'' in
scientific programming (C doesn't count).

> - Lists, Tupels, Dictionaries included

Not bothered for our purposes. Lists are mentioned only very briefly in
the context of the range() function, but we got away without discussing
tuples or dictionaries at all. I say ``got away'' because we only have 1
day to teach programming(!) so almost anything we can avoid we will.

> - interpreter: Everything can be tested

I thought this was going to be a big deal. We designed the trial to give
students almost a free reign over whether to use modules or the
interpreter and *none* of them (out of about 40) used the interpreter. I
think this might be due to the length of the programs they were writing
(none more than about 100 lines), so they can derive practically the
same amount of interactivity from repeatedly re-running the the program.
Perhaps when asked to write longer programs, when it becomes unwieldy
to make changes for debugging purposes they might use it.

> - Many tools available

The standard library is nice, but we make particularly heavy use of
Numeric Python and Gnuplot.py

> AND MORE IMPORTANT:
> What are your problems with python? Are pupils/students having any
> problems or often asked questions?

At the moment it's hard to determine if the consistent problems are due
to the way the course is written OR peculiar to Python OR generic
problems that students would encounter in learning programming in every 
language.

We do seem to be having some trouble with the inconsistency of writing
to stdout and file. To make things easier early on we have them write to
screen using the print command. They can then separate abritrary
variables using commas. However then they do fout.write(myfloat, myint,
"Some numbers") and it doesn't work they get confused. It may be better
to teach them to write to screen using sys.stdout.write from the start
as that then provides a consistent writing tool.

> What do you dislike at python?

Input of whitespace separated numbers from file or stdin is relatively
complex in Python:

>>> line = raw_input()
>>> snumbers = string.split(line)
>>> x, y = float(snumbers[0], snumbers[1])

unless I'm missing something obvious. The comparable expression in
Pascal is 

readln(x, y)

> Any similar problems with Python?
> - Why must I set a ":" after "if" or "for" ?  " if x == y : "

I explain this by appealing to their understanding of grammar: A colon
introduces a new idea. (Apologies to whoever it was came up with that
explanation on either this list or tutor). They seem to forget it quite
regularly, but the error message leaves nothing to the imagination.

If you (or anyone) are interested in seeing the handbook for the course,
from which our students work, then I could post the URL to a *work in
progress* version of it here. It's available in HTML, PDF and PS.

-- 
Michael