[Edu-sig] Would a simplified Python UI for MiddleSchool students be worth the effort?

Kirby Urner urnerk@qwest.net
Tue, 08 Jul 2003 00:21:55 -0700


At 12:23 PM 7/7/2003 -0700, you wrote:

>routines running! Sure, there are some kids that can abstract things and get
>all excited about rearranging letters and numbers, etc. But a lot of people
>in general like the visual pleasure of seeing things work. *sigh*

Some kids even like both! (and some neither :-( -- sigh again).

But the act of programming itself is a lot like rearranging letters
and numbers, is very text-oriented, visual programming notwithstanding
(you still usually end up writing code snippets behind the scenes).

So whereas I'm all for flashy visuals, a well-rounded diet should
include some regular expressions and such, IMO (but not exclusively
-- turtle graphics with Tkinter, yes! (including the demo). And
Kevin implemented some turtle stuff in PythonCard that's pretty
nifty as well).

And lets not forget the cellular automata (perhaps a bridge between
text and graphics, as simple CA may be displayed using a kind of
'ascii art' -- see below).

Kirby

  >>> def nextgen(g, rule):
         """
         Compute a next generation based on some rule
         """
          newline = ''
          for i in range(len(g)):
              cells = g[i%s] + g[(i+1)%s] + g[(i+2)%s]  # % for modulo
              newline = "%s%s" % (newline, rule[cells]) # %s for string
          return newline[-1]+newline[:-1]  # wrap last around to first

  >>> def run(g, n, rule):
         """
         compute n generations, starting with g, using a rule
         """
          print g
          for i in range(n):
             g = nextgen(g, rule)
             print g

  >>> # 3-cell pattern in top row below generates element in 2nd row
  >>> # (this implementation wraps right edge around to left)

  >>> rule110 = dict(zip(
               ['AAA','AA.','A.A','A..','.AA','.A.','..A','...'],
                [ '.',  'A',  'A',  '.',  'A',  'A',  'A',  '.']))

  >>> dots  = '.' * 30
  >>> start = dots + 'A' + dots
  >>> run(start, 40, rule110)
  ..............................A..............................
  .............................AA..............................
  ............................AAA..............................
  ...........................AA.A..............................
  ..........................AAAAA..............................
  .........................AA...A..............................
  ........................AAA..AA..............................
  .......................AA.A.AAA..............................
  ......................AAAAAAA.A..............................
  .....................AA.....AAA..............................
  ....................AAA....AA.A..............................
  ...................AA.A...AAAAA..............................
  ..................AAAAA..AA...A..............................
  .................AA...A.AAA..AA..............................
  ................AAA..AAAA.A.AAA..............................
  ...............AA.A.AA..AAAAA.A..............................
  ..............AAAAAAAA.AA...AAA..............................
  .............AA......AAAA..AA.A..............................
  ............AAA.....AA..A.AAAAA..............................
  ...........AA.A....AAA.AAAA...A..............................
  ..........AAAAA...AA.AAA..A..AA..............................
  .........AA...A..AAAAA.A.AA.AAA..............................
  ........AAA..AA.AA...AAAAAAAA.A..............................
  .......AA.A.AAAAAA..AA......AAA..............................
  ......AAAAAAA....A.AAA.....AA.A..............................
  .....AA.....A...AAAA.A....AAAAA..............................
  ....AAA....AA..AA..AAA...AA...A..............................
  ...AA.A...AAA.AAA.AA.A..AAA..AA..............................
  ..AAAAA..AA.AAA.AAAAAA.AA.A.AAA..............................
  .AA...A.AAAAA.AAA....AAAAAAAA.A..............................
  AAA..AAAA...AAA.A...AA......AAA..............................
  A.A.AA..A..AA.AAA..AAA.....AA.A.............................A
  AAAAAA.AA.AAAAA.A.AA.A....AAAAA............................AA
  .....AAAAAA...AAAAAAAA...AA...A...........................AA.
  ....AA....A..AA......A..AAA..AA..........................AAA.
  ...AAA...AA.AAA.....AA.AA.A.AAA.........................AA.A.
  ..AA.A..AAAAA.A....AAAAAAAAAA.A........................AAAAA.
  .AAAAA.AA...AAA...AA........AAA.......................AA...A.
  AA...AAAA..AA.A..AAA.......AA.A......................AAA..AA.
  AA..AA..A.AAAAA.AA.A......AAAAA.....................AA.A.AAAA
  .A.AAA.AAAA...AAAAAA.....AA...A....................AAAAAAA...

  >>>