School Python

Avi Gross avigross at verizon.net
Tue Feb 16 23:42:39 EST 2021


I wonder if someone has come up with a sort of Python environment that lets kids play with more fundamental parts of the language that lets them get educated without the confusion. I mean a limited subset and with some additions/modifications.

Someone mentioned how something like range(1,10) is confusing as it now not only does not produce a list on 1 to 9 or 1 to 10 but produces an object that only can be viewed well by doing more advanced things like iterating it.

So why not have a module called something like EDUCATION which is loaded into the school version automagically and implements what you want. Make a function called SchoolTimeRANGE strange(here, there)  (or whatever) that returns something like list( range(here, there)) so the student never sees a range object or yet knows there are objects to object to. If you want it to include the last item, include "there". Want it to start at 0 or 1, do that.

As I see it, really limited languages make you work hard. Some of the LISP variants I used ages ago were so damn simple that you had programs largely consisting of combinations of CAR and CDR so dealing with some nested list data structure was painful enough that people had functions with name like CDDADAR to access some particular part. The same goes for various simple and limited languages that can do anything but won't keep a student in a room. Python is not limited and should not be but it should be taught progressively so basic computer concepts are learned before you learn arguably better ways. A beautiful thing about a list is it can be reused. Something with an iterator control can mysteriously be drained.

So what is wrong with much of basic python, especially slightly extended? Feel free to tell them to use, strange() above for now as it lets them see what is happening step by step and mention that LATER they can (or must) switch to other functions normally used that may be more efficient or general.

What I like about good parts of Python and that makes it good for teaching is that much can be written in almost normal English. Do you even need to use range(1,6) when you can ask the students to just type:

numbers = [ 1, 2, 3, 4, 5 ]
for index in numbers:
  ...

Yes, later, introduce ways to loop from 1 to N by using better methods. List comprehensions? Why introduce them at all as most other languages do not have them and they are just syntactic sugar.  

If the goal is to introduce children to simple algorithms, keep them simple. Forget elegance or efficiency or being pythonic. But past a certain point, when they are ready, sure, add more. At some point it is helpful to learn that instead of keeping multiple arrays or variables in parallel, you could capture them in one object and tell the object what to do with itself and so on. Maybe later, show some tricks with functional programming. But don't START with elegant recursion methods.

I see no major barrier to teaching using python for children who can handle indentation 😉 albeit they still have to learn to balance parentheses and quotes (sometimes) and brackets and braces ...

What I think is good is that they can practice in front of an interpreter and get immediate results, not like I did with index cards that were handed in and returned a day later, or having to wait a long time for a compile to complete, with errors.





More information about the Python-list mailing list