[Edu-sig] The fate of raw-input() in Python 3000

Hugh Stewart hughstewart at optushome.com.au
Mon Sep 11 07:13:06 CEST 2006


Hi All,
After 30 odd years of teaching 'programming' in many languages
and at many levels; (High School, College, University) I have 
come up with the 10:20:70 rule of thumb. 10% of students will 
have a natural flair, 20% will make competent programmers and 
the remainder struggle with many of the concepts (This does not
mean they don't gain from the experience, in many cases they do).
 
Hence the majority of the students in any group(class) will 
be the 70%ers and so any assistance from the language is to be 
valued and the raw_input() and to a lesser extent input() I/O
syntax have great value to the beginner.

The comments of Dan Crosta ring true for many students.

On retirement I toyed with the idea of turning the copious 
notes I had developed for students into a book/textbook.
At the time Python v1.5.2 had just been released and it 
looked interesting as the language for the book. I took 
the hundreds of exercises and assignments and reworked them 
in Python. It was enjoyable. It was also interesting in 
comparing the strengths and weaknesses displayed relative 
to earlier languages.

As an illustration: an exercise lifted from Oh! Pascal, 2nd. ed.
Norton p229-233.

  Write a program that produces palindromic numbers by the 
following algorithm:
  "Start by taking a number. If it isn't a palindrome, reverse 
  the number,sum the number and its reversal. If the new number 
  isn't palindromic reverse the new number, then add it to the 
  reversal. Eventually, the number will become a palindrome."

After a few iterations either a palindrome is found or an 
overflow is reported due to the limitations of the integer
representation in most languages. Then, I had neither the time 
nor interest to develop an extended solution.

Since Python 2.3 the extended solution is quite simple (almost trivial)
using long integers and extended slices. With this 
Python generated productivity I had time to play and enter a few
numbers at random via raw_input() and to my suprise the number 879 (978)
did not produce a palindrome after 100000 iterations.  I immediately
thought --- here is a conjecture: Not all numbers produce a
palindromic number.

Some time later a Google search produced the following site of interest:
http://mathworld.wolfram.com/PalindromicNumberConjecture.html.

To cut to the chase: raw_input() provides an extremely useful 
I/O function for simple exercise type problems which are so essential 
in building a beginners repertoire of programming techniques and
for 'John Zeller' type problems ( simple quick  dirty and effective 
solutions that get those housekeeping jobs done).

Python gives us a programming language of extraordinary productivity
at all levels of programming (especially for beginners).

Just for Kirby: Buckminster Fuller even says something about palindromic
numbers. See http://en.wikipedia.org/wiki/Palindromic_number

 Hugh 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/edu-sig/attachments/20060911/292441a5/attachment.htm 


More information about the Edu-sig mailing list