[Edu-sig] How do we tell truths that might hurt

Anna Ravenscroft anna at aleax.it
Fri Apr 23 06:43:48 EDT 2004

On Friday 23 April 2004 06:18, Terry Hancock wrote:
> On Thursday 22 April 2004 07:25 am, Anna Ravenscroft wrote:
> > On Wednesday 21 April 2004 19:36, ajsiegel at optonline.net wrote:
> > > Yes, a Literature student might be enticed to know that programming
> > > could be made useful in finding semantic patterns in the works of
> > > Joyce. The problem is that its hard.
> >
> > Yep - it's hard. And continuing to present programming that way is going
> > to *keep* people away.
> >
> > So you start with something easier.
> >
> > Do a simple word count program - find out the number of occurrences of
> > "word" in a particular file -a fairly simple program that shows the
> > prospective learner that they can use it for things *they're* interested
> > in, without having to be a wizard! Once they can do that, show them how
> > they can turn it into a concordance program.
> Just for the heck of it one day I did a little interactive
> programming with Python to find the 500 most common words (in
> order) that occured in a combination of three highly unrelated
> Project Gutenberg texts.  I was trying to create a "throw-out"
> list for a program I use in my forum software that I'm writing
> to convert subject lines like "A Thousand and One Arabian Nights"
> to a mnemonic legal id such as "1001_arabian_nights".
> The idea is to make URLs that aren't too hard to remember instead
> of "topic_4348def3203ea339" or something equally nonsensical.
> An affectation, perhaps.  But I wanted to do it that way.
> The task of finding the common words wasn't really too difficult.
> First you read the whole file into Python (Python is *so* awesome)
> then you replace all the punctuation characters and stuff with
> whitespace, then you tokenize it, then you convert it all to
> lower case.  Then you build a map:
> # this only does one file -- but you could collect three files
> # as the source material.
> import re, string
> illegal_re = re.compile(r'[^a-zA-Z\s]+')
> # Match any set of one or more characters not a letter or whitespace
> words = [w for w in illegal_re.sub(' ', open('myfile',
> 'r').read()).lower().split() if len(w)>2] # Note the list comp is to ditch
> 1 and 2 character words which I don't care about # because I can safely
> toss ALL of those before culling most common words.
> word_freq = {}
> for word in words:
>     word_freq[word] = word_freq.get(word, 0) + 1
> word_freq = word_freq.items()
> word_freq.sort(lambda a,b: cmp(b[1],a[1]))
> for word, freq in word_freq[:500]:
>     print "%30s  %10d" % (word, freq)
> Now that wasn't terribly difficult, was it? ;-)
> This is the sort of thing that can easily be
> done as a non-mathematical programming problem.

Exactly my point. And this kind of thing needs to be presented to students 
early enough that they realize that they can use Python (or other 
programming) for their own interests. 

For those promoting  a math focus in teaching programming:

It *doesn't* have to be Math versus GUI and Games. It can be text processing, 
or date manipulation, or any number of other thing. While I understand the 
argument that "it's really just math in disguise", an exclusive (or primary) 
focus on math seems to me to forget to present these simple programs that 
show the applicability of programming to other areas of endeavor. 

Another example of non-math uses for programming:
My first Python program was calculating the number of actual days in training 
for a bunch of students who either trained weekdays *OR* trained weekends, 
but had to account for sick days and holidays. I had been shown how they did 
this in the office - they walked up to the calendar hanging on the wall and 
literally went "1, 2, 3..."  It was terribly error-prone: people miscounted, 
people forgot about holidays and sick days... Since this was used for 
determing when the students finished probation (90 *actual working days*, not 
simply 90 calendar days), it was pretty important to get it right. There was, 
I think, one (maybe two) lines of code actually dealing with mathematical 
calculations. The rest of the code was there to gather and manipulate all the 
right information in order for those calculations to be accurate (this was 
before date objects in Python). 

Was this a "math" program? Not in my mind, it wasn't. It was a date-handling 
program. Was there some math in it? Sure. But, I can pretty much use a 
calculator for the math parts of any program I've written. That wasn't the 
important part. The important part was handling all the conditions and 
prompting the user to do all the steps (check for sick days, check for 
holidays - which I later put into a pickled holidays dict). Being able to do 
the step by step procedural description of exactly what my conditions were 
and what to do about them, etc, is what I mean by algorithmic thinking. 

Now, you might say that this was entirely a mathematical problem. In some 
ways, yes, it would qualify as a "word problem" in standard parlance, I 
guess. So would my program to calculate Italian taxes. OTOH - the parts that 
are *useful* to me is having the program prompt me for some bits of 
information (e.g., is this a foreign or domestic client?) and have it use 
that to determine *which* calculations need to be done! The math calculations 
were the easy part - most of those I could do in my head. It's figuring out 
which ones to do for a particular invoice that was the long, involved 
(non-mathematical) process, that I don't have to do anymore, because I 
created my Python program.

[smile] I realize we're probably talking at cross-purposes. You say math, I 
think numerical calculations, algebraic equations, trigonometry, calculus. I 
have very little interest in numerical calculations, etc. - it's all the 
*other* really interesting things that I can do with programming (text 
processing, date manipulation, etc)  that got me back into it, and that I 
wish I had known about 20 years ago. Those are the things I'm advocating for 
being presented in introductory programming classes in addition to the math - 
so people know how they can apply programming in their lives.


More information about the Edu-sig mailing list