[Tutor] Girls, women and Programming (- and Python)

Allyn Weaks allyn.@tardigrade.net
Mon, 5 Aug 2002 02:54:57 -0700


On 4/8/02, Gregor Lingl wrote:

>> 2) How do I get them interested? Which kinds of material, approaches,
>> examples etc. are appealing to female students?

On 4/8/02, Eve Kotyk wrote:

>I'm determined to learn Phython but I find that my lack of general
>knowledge of programming makes it difficult to figure out what to write.
> Because I'm a painter, I'll use that as an analogy.  Many people who do
>not know how to use the materials and language of paint will often
>flounder when asked to paint a picture

Speaking of arts, try musical composition.  Western music fits
beautifully into list structures.  You can do it as a list of
attributes for each note (pitch, duration, loudness, ...).  But it's
much more useful and fun to split an entire tune into separate lists
for pitch and duration (as proper musical durations--breve, quarter,
eighth, etc), and for more subtlety if desired, loudness of each note,
percentage of time that the note sounds, etc.  Put the lists together
only at the last minute when playing the result.  Handling it this way
makes it really easy to play composition games such as:

What happens if you use the pitches from tune A, and the rhythm from
tune B?  What happens if you double the duration of every other note,
or every third note?  What does it sound like if you play the tune back
to front (retrograde), or upside down (inversion) or both?  What does
it sound like converted into a different scale, such as dorian instead
of major?  (How should one represent a 'scale'?)  How do you put in a
syncopation or a trill?  How can you stress the first beat of a
measure?  Does a tune sound the same in 4/4 and 6/8?  What can you do
to make the computer play less mechanically?

Have the computer help write a song for a set of lyrics--put the rhythm
and stresses of the words into lists, then try out different pitch
sequences--borrowed, original, or generated by algorithm--against that
rhythm, and adjust to taste.  Or try generating counterpoint with some
rules / algorithms about allowed intervals within a part and between
parts.  Add harmony with chords.  Find a way to print out the notation,
and/or convert your representation to and from midi format.  Play with
genetic algorithms and let tunes evolve.  Try some analysis and find
out what's the same / different between different styles--histogram of
pitches?  intervals?  rhythmic idioms?  Once you think you know what
makes up a given style, can you say that in rules to randomly generate
plausible tunes in that style?

There's an interesting book that's out of print, but still available
used:  Cybernetic Music, by Jaxitron; TAB Books, 1985, 0-8306-1856-2.
It uses APL to do this sort of representation and build tools for
composition.  It ought to be pretty easy to adapt the basics to python
for beginners, even beginners without a musical background, since so
many tunes are quite simple--plain major key, and straightforward
rhythms.  Another possible source of inspiration, though possibly
harder to find, is "The Game of Harmony" by Ross Lee Finney from the
40s.  It's an introduction to writing simple four part harmonies for
children.  It could be helpful for designing classes for chord
structures and algorithms for applying them.

You can do similar things with visual arts.  There should be good ways
to do a lot of textile stuff, such as weaving patterns.  A lot of
mathematical functions make beautiful quilt designs, and one could have
the computer generate piece patterns (don't forget those seam margins,
and optimizing the use of material can be a challenge.)  Both knitting
and macrame lead to knot theory and topology.  Ivars Peterson, of
Science News, has a book out that might be useful for ideas:
"Fragments of Infinity: A Kaleidoscope of Math and Art".  I think parts
of it have shown up as installments in Mathtrek at the Science News
site <http://www.sciencenews.org/sn_wekly/math_arc.asp>.

Then as an encore, how about choreographing the turtle? :-)
-- 
Allyn Weaks    allyn@tardigrade.net   Seattle, WA  Sunset zone 5
Pacific NW Native Wildlife Gardening: http://www.tardigrade.org/natives/
"The benefit of even limited monopolies is too doubtful, to be opposed
to that of their general suppression."  Thomas Jefferson