From roberto03 at gmail.com Thu Apr 8 12:50:58 2010 From: roberto03 at gmail.com (roberto) Date: Thu, 8 Apr 2010 12:50:58 +0200 Subject: [Edu-sig] rewriting examples in python Message-ID: hello, i found this very famous book "Turtle Geometry: The Computer as a Medium for Exploring Mathematics (Artificial Intelligence)" by Harold Abelson and Andrea diSessa and i was wondering if anyone of the turtle experts has ever rewritten in python the logo examples in the book; i am more interested in the turtle spirit than in the logo language, so i'd like to use python directly along with the book itself thank you very much in advance -- roberto From kirby.urner at gmail.com Thu Apr 8 16:43:13 2010 From: kirby.urner at gmail.com (kirby urner) Date: Thu, 8 Apr 2010 07:43:13 -0700 Subject: [Edu-sig] using Python as a calculator Message-ID: I think Guido was wise to start his tutorial by showing how we might use Python as a calculator. We might assume many students in this day and age are quite familiar with this device, and even if they're not, the text might project one, show a picture on the screen, if what these things used to look like (still do). However, one thing calculators lack over the old wood pulp textbooks are trig tables with multiple rows showing a lot of data at the same time. Their small "chat window" does not permit much data to be seen at one time. Back in the day, a student could run her finger down the rows, as the number of angular degrees increase from 0 to 60 and onward to 90, perhaps all the way around to 360. Going across the row, one would have sine and cosine, perhaps tangent. Having all the data visible at once, or spread across a few pages, inspired some insights and understanding, as one could see the trends in the numbers, plus these "click stop" rows where the numbers would suddenly be super easy, like 1/2 and 1/2 for both sine and cosine. Calculators don't give us that kind of output, but earlier office computing machines did have paper i/o, called a tape, usually a scroll mounted on a spool and fed through a small printer. As one added numbers, one printed to tape, perhaps a running total. The tape itself was a valuable item (especially once it had the data on it). Large computers came with line printers that hit on continuous feed paper with holes along both sides, often with green and white stripes. I will not try to recapitulate the long history of printing devices, except to point out that computers inherited them while slide rules and calculators did not. The equivalent in Python is stdout and/or some file in storage, on the hard drive or memory stick. The program output shown below would be an example of this kind of i/o. Notice that unless a file name is given (optional), the data is to stdout. I'm going to do a full 90 degrees, just to remind myself of the patterns students got in the old days, before trig tables were replaced with calculators, much as dial watches were replaced with digital ones (not necessarily a smart move in all cases). >>> imp.reload(newprint) >>> newprint.trigtable(range(91), "trigtable.txt") The contents of trigtable.txt: 0 1.000000000 0.000000000 0.000000e+00 1 0.999847695 0.017452406 1.745506e-02 2 0.999390827 0.034899497 3.492077e-02 3 0.998629535 0.052335956 5.240778e-02 4 0.997564050 0.069756474 6.992681e-02 5 0.996194698 0.087155743 8.748866e-02 6 0.994521895 0.104528463 1.051042e-01 7 0.992546152 0.121869343 1.227846e-01 8 0.990268069 0.139173101 1.405408e-01 9 0.987688341 0.156434465 1.583844e-01 10 0.984807753 0.173648178 1.763270e-01 11 0.981627183 0.190808995 1.943803e-01 12 0.978147601 0.207911691 2.125566e-01 13 0.974370065 0.224951054 2.308682e-01 14 0.970295726 0.241921896 2.493280e-01 15 0.965925826 0.258819045 2.679492e-01 16 0.961261696 0.275637356 2.867454e-01 17 0.956304756 0.292371705 3.057307e-01 18 0.951056516 0.309016994 3.249197e-01 19 0.945518576 0.325568154 3.443276e-01 20 0.939692621 0.342020143 3.639702e-01 21 0.933580426 0.358367950 3.838640e-01 22 0.927183855 0.374606593 4.040262e-01 23 0.920504853 0.390731128 4.244748e-01 24 0.913545458 0.406736643 4.452287e-01 25 0.906307787 0.422618262 4.663077e-01 26 0.898794046 0.438371147 4.877326e-01 27 0.891006524 0.453990500 5.095254e-01 28 0.882947593 0.469471563 5.317094e-01 29 0.874619707 0.484809620 5.543091e-01 30 0.866025404 0.500000000 5.773503e-01 31 0.857167301 0.515038075 6.008606e-01 32 0.848048096 0.529919264 6.248694e-01 33 0.838670568 0.544639035 6.494076e-01 34 0.829037573 0.559192903 6.745085e-01 35 0.819152044 0.573576436 7.002075e-01 36 0.809016994 0.587785252 7.265425e-01 37 0.798635510 0.601815023 7.535541e-01 38 0.788010754 0.615661475 7.812856e-01 39 0.777145961 0.629320391 8.097840e-01 40 0.766044443 0.642787610 8.390996e-01 41 0.754709580 0.656059029 8.692867e-01 42 0.743144825 0.669130606 9.004040e-01 43 0.731353702 0.681998360 9.325151e-01 44 0.719339800 0.694658370 9.656888e-01 45 0.707106781 0.707106781 1.000000e+00 46 0.694658370 0.719339800 1.035530e+00 47 0.681998360 0.731353702 1.072369e+00 48 0.669130606 0.743144825 1.110613e+00 49 0.656059029 0.754709580 1.150368e+00 50 0.642787610 0.766044443 1.191754e+00 51 0.629320391 0.777145961 1.234897e+00 52 0.615661475 0.788010754 1.279942e+00 53 0.601815023 0.798635510 1.327045e+00 54 0.587785252 0.809016994 1.376382e+00 55 0.573576436 0.819152044 1.428148e+00 56 0.559192903 0.829037573 1.482561e+00 57 0.544639035 0.838670568 1.539865e+00 58 0.529919264 0.848048096 1.600335e+00 59 0.515038075 0.857167301 1.664279e+00 60 0.500000000 0.866025404 1.732051e+00 61 0.484809620 0.874619707 1.804048e+00 62 0.469471563 0.882947593 1.880726e+00 63 0.453990500 0.891006524 1.962611e+00 64 0.438371147 0.898794046 2.050304e+00 65 0.422618262 0.906307787 2.144507e+00 66 0.406736643 0.913545458 2.246037e+00 67 0.390731128 0.920504853 2.355852e+00 68 0.374606593 0.927183855 2.475087e+00 69 0.358367950 0.933580426 2.605089e+00 70 0.342020143 0.939692621 2.747477e+00 71 0.325568154 0.945518576 2.904211e+00 72 0.309016994 0.951056516 3.077684e+00 73 0.292371705 0.956304756 3.270853e+00 74 0.275637356 0.961261696 3.487414e+00 75 0.258819045 0.965925826 3.732051e+00 76 0.241921896 0.970295726 4.010781e+00 77 0.224951054 0.974370065 4.331476e+00 78 0.207911691 0.978147601 4.704630e+00 79 0.190808995 0.981627183 5.144554e+00 80 0.173648178 0.984807753 5.671282e+00 81 0.156434465 0.987688341 6.313752e+00 82 0.139173101 0.990268069 7.115370e+00 83 0.121869343 0.992546152 8.144346e+00 84 0.104528463 0.994521895 9.514364e+00 85 0.087155743 0.996194698 1.143005e+01 86 0.069756474 0.997564050 1.430067e+01 87 0.052335956 0.998629535 1.908114e+01 88 0.034899497 0.999390827 2.863625e+01 89 0.017452406 0.999847695 5.728996e+01 90 0.000000000 1.000000000 1.633124e+16 Here's the print function I used to generate the above. print("{0:>5g} {1:.9f} {2:.9f} {3:e}".format( row, cos(theta), sin(theta),tan(theta)), end="\n", file= thefile) My module starts with: from __future__ import printfunction which is why I get to use this in 2.6 So why use Python as a calculator again? Because it's more like an old office machine with a tape, and that restores some of what was lost when lookup tables went out of style. I should do log10 next, using range with a step or something.... Also, the trig tape should probably be 0-360 but I didn't want to waste paper. :) Kirby From echerlin at gmail.com Fri Apr 9 18:41:16 2010 From: echerlin at gmail.com (Edward Cherlin) Date: Fri, 9 Apr 2010 12:41:16 -0400 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: Message-ID: [sigh] Do math tables in a math array language. degrees =. i. 91 NB. 0..90 radians =. degrees * o. % 180 table =. |: degrees, 1 2 3 o./ radians where =. is assignment i. creates a list of consecutive numbers starting at 0. NB. is the comment marker o. x is pi times x % x is reciprocal of x, so o. % 180 is pi/180 |: is transpose , appends an array to another. It turns a list into a table in order to match dimensions. 1 2 3 o. x gives sine, cosine, tangent of x / creates a table with the given function (o.) applied to two list arguments The result is a 91 row, 4 column table of angles and trig function values. I can easily give you a short sequence of lessons leading to this level, introducing some other arithmetic, transcendental, and array-handling functions along the way, and a little more about operating on functions to define new functions. J is no-charge software from JSoftware.com. We are discussing the possibility of a GPLed version. When you do such function tables, it is extremely helpful to show the first differences. The differences of sine are approximately proportional to cosine, and of cosine are proportional to the negatives of sine. On Thu, Apr 8, 2010 at 10:43, kirby urner wrote: > I think Guido was wise to start his tutorial by showing how we > might use Python as a calculator. > > We might assume many students in this day and age are quite > familiar with this device, and even if they're not, the text might > project one, show a picture on the screen, if what these things > used to look like (still do). > > However, one thing calculators lack over the old wood pulp > textbooks are trig tables with multiple rows showing a lot of > data at the same time. ?Their small "chat window" does not > permit much data to be seen at one time. > > Back in the day, a student could run her finger down the > rows, as the number of angular degrees increase from > 0 to 60 and onward to 90, perhaps all the way around to > 360. > > Going across the row, one would have sine and cosine, > perhaps tangent. ?Having all the data visible at once, or spread > across a few pages, inspired some insights and understanding, > as one could see the trends in the numbers, plus these > "click stop" rows where the numbers would suddenly be > super easy, like 1/2 and 1/2 for both sine and cosine. > > Calculators don't give us that kind of output, but earlier office > computing machines did have paper i/o, called a tape, usually > a scroll mounted on a spool and fed through a small printer. > > As one added numbers, one printed to tape, perhaps a running > total. ?The tape itself was a valuable item (especially once it > had the data on it). > > Large computers came with line printers that hit on continuous > feed paper with holes along both sides, often with green and > white stripes. ?I will not try to recapitulate the long history > of printing devices, except to point out that computers > inherited them while slide rules and calculators did not. > > The equivalent in Python is stdout and/or some file in storage, > on the hard drive or memory stick. ?The program output > shown below would be an example of this kind of i/o. > > Notice that unless a file name is given (optional), the data > is to stdout. > > I'm going to do a full 90 degrees, just to remind myself of > the patterns students got in the old days, before trig tables > were replaced with calculators, much as dial watches were > replaced with digital ones (not necessarily a smart move > in all cases). > >>>> imp.reload(newprint) > >>>> newprint.trigtable(range(91), "trigtable.txt") > > The contents of trigtable.txt: > > ? ?0 ? ? ?1.000000000 ? ?0.000000000 ? ?0.000000e+00 > ? ?1 ? ? ?0.999847695 ? ?0.017452406 ? ?1.745506e-02 > ? ?2 ? ? ?0.999390827 ? ?0.034899497 ? ?3.492077e-02 > ? ?3 ? ? ?0.998629535 ? ?0.052335956 ? ?5.240778e-02 > ? ?4 ? ? ?0.997564050 ? ?0.069756474 ? ?6.992681e-02 > ? ?5 ? ? ?0.996194698 ? ?0.087155743 ? ?8.748866e-02 > ? ?6 ? ? ?0.994521895 ? ?0.104528463 ? ?1.051042e-01 > ? ?7 ? ? ?0.992546152 ? ?0.121869343 ? ?1.227846e-01 > ? ?8 ? ? ?0.990268069 ? ?0.139173101 ? ?1.405408e-01 > ? ?9 ? ? ?0.987688341 ? ?0.156434465 ? ?1.583844e-01 > ? 10 ? ? ?0.984807753 ? ?0.173648178 ? ?1.763270e-01 > ? 11 ? ? ?0.981627183 ? ?0.190808995 ? ?1.943803e-01 > ? 12 ? ? ?0.978147601 ? ?0.207911691 ? ?2.125566e-01 > ? 13 ? ? ?0.974370065 ? ?0.224951054 ? ?2.308682e-01 > ? 14 ? ? ?0.970295726 ? ?0.241921896 ? ?2.493280e-01 > ? 15 ? ? ?0.965925826 ? ?0.258819045 ? ?2.679492e-01 > ? 16 ? ? ?0.961261696 ? ?0.275637356 ? ?2.867454e-01 > ? 17 ? ? ?0.956304756 ? ?0.292371705 ? ?3.057307e-01 > ? 18 ? ? ?0.951056516 ? ?0.309016994 ? ?3.249197e-01 > ? 19 ? ? ?0.945518576 ? ?0.325568154 ? ?3.443276e-01 > ? 20 ? ? ?0.939692621 ? ?0.342020143 ? ?3.639702e-01 > ? 21 ? ? ?0.933580426 ? ?0.358367950 ? ?3.838640e-01 > ? 22 ? ? ?0.927183855 ? ?0.374606593 ? ?4.040262e-01 > ? 23 ? ? ?0.920504853 ? ?0.390731128 ? ?4.244748e-01 > ? 24 ? ? ?0.913545458 ? ?0.406736643 ? ?4.452287e-01 > ? 25 ? ? ?0.906307787 ? ?0.422618262 ? ?4.663077e-01 > ? 26 ? ? ?0.898794046 ? ?0.438371147 ? ?4.877326e-01 > ? 27 ? ? ?0.891006524 ? ?0.453990500 ? ?5.095254e-01 > ? 28 ? ? ?0.882947593 ? ?0.469471563 ? ?5.317094e-01 > ? 29 ? ? ?0.874619707 ? ?0.484809620 ? ?5.543091e-01 > ? 30 ? ? ?0.866025404 ? ?0.500000000 ? ?5.773503e-01 > ? 31 ? ? ?0.857167301 ? ?0.515038075 ? ?6.008606e-01 > ? 32 ? ? ?0.848048096 ? ?0.529919264 ? ?6.248694e-01 > ? 33 ? ? ?0.838670568 ? ?0.544639035 ? ?6.494076e-01 > ? 34 ? ? ?0.829037573 ? ?0.559192903 ? ?6.745085e-01 > ? 35 ? ? ?0.819152044 ? ?0.573576436 ? ?7.002075e-01 > ? 36 ? ? ?0.809016994 ? ?0.587785252 ? ?7.265425e-01 > ? 37 ? ? ?0.798635510 ? ?0.601815023 ? ?7.535541e-01 > ? 38 ? ? ?0.788010754 ? ?0.615661475 ? ?7.812856e-01 > ? 39 ? ? ?0.777145961 ? ?0.629320391 ? ?8.097840e-01 > ? 40 ? ? ?0.766044443 ? ?0.642787610 ? ?8.390996e-01 > ? 41 ? ? ?0.754709580 ? ?0.656059029 ? ?8.692867e-01 > ? 42 ? ? ?0.743144825 ? ?0.669130606 ? ?9.004040e-01 > ? 43 ? ? ?0.731353702 ? ?0.681998360 ? ?9.325151e-01 > ? 44 ? ? ?0.719339800 ? ?0.694658370 ? ?9.656888e-01 > ? 45 ? ? ?0.707106781 ? ?0.707106781 ? ?1.000000e+00 > ? 46 ? ? ?0.694658370 ? ?0.719339800 ? ?1.035530e+00 > ? 47 ? ? ?0.681998360 ? ?0.731353702 ? ?1.072369e+00 > ? 48 ? ? ?0.669130606 ? ?0.743144825 ? ?1.110613e+00 > ? 49 ? ? ?0.656059029 ? ?0.754709580 ? ?1.150368e+00 > ? 50 ? ? ?0.642787610 ? ?0.766044443 ? ?1.191754e+00 > ? 51 ? ? ?0.629320391 ? ?0.777145961 ? ?1.234897e+00 > ? 52 ? ? ?0.615661475 ? ?0.788010754 ? ?1.279942e+00 > ? 53 ? ? ?0.601815023 ? ?0.798635510 ? ?1.327045e+00 > ? 54 ? ? ?0.587785252 ? ?0.809016994 ? ?1.376382e+00 > ? 55 ? ? ?0.573576436 ? ?0.819152044 ? ?1.428148e+00 > ? 56 ? ? ?0.559192903 ? ?0.829037573 ? ?1.482561e+00 > ? 57 ? ? ?0.544639035 ? ?0.838670568 ? ?1.539865e+00 > ? 58 ? ? ?0.529919264 ? ?0.848048096 ? ?1.600335e+00 > ? 59 ? ? ?0.515038075 ? ?0.857167301 ? ?1.664279e+00 > ? 60 ? ? ?0.500000000 ? ?0.866025404 ? ?1.732051e+00 > ? 61 ? ? ?0.484809620 ? ?0.874619707 ? ?1.804048e+00 > ? 62 ? ? ?0.469471563 ? ?0.882947593 ? ?1.880726e+00 > ? 63 ? ? ?0.453990500 ? ?0.891006524 ? ?1.962611e+00 > ? 64 ? ? ?0.438371147 ? ?0.898794046 ? ?2.050304e+00 > ? 65 ? ? ?0.422618262 ? ?0.906307787 ? ?2.144507e+00 > ? 66 ? ? ?0.406736643 ? ?0.913545458 ? ?2.246037e+00 > ? 67 ? ? ?0.390731128 ? ?0.920504853 ? ?2.355852e+00 > ? 68 ? ? ?0.374606593 ? ?0.927183855 ? ?2.475087e+00 > ? 69 ? ? ?0.358367950 ? ?0.933580426 ? ?2.605089e+00 > ? 70 ? ? ?0.342020143 ? ?0.939692621 ? ?2.747477e+00 > ? 71 ? ? ?0.325568154 ? ?0.945518576 ? ?2.904211e+00 > ? 72 ? ? ?0.309016994 ? ?0.951056516 ? ?3.077684e+00 > ? 73 ? ? ?0.292371705 ? ?0.956304756 ? ?3.270853e+00 > ? 74 ? ? ?0.275637356 ? ?0.961261696 ? ?3.487414e+00 > ? 75 ? ? ?0.258819045 ? ?0.965925826 ? ?3.732051e+00 > ? 76 ? ? ?0.241921896 ? ?0.970295726 ? ?4.010781e+00 > ? 77 ? ? ?0.224951054 ? ?0.974370065 ? ?4.331476e+00 > ? 78 ? ? ?0.207911691 ? ?0.978147601 ? ?4.704630e+00 > ? 79 ? ? ?0.190808995 ? ?0.981627183 ? ?5.144554e+00 > ? 80 ? ? ?0.173648178 ? ?0.984807753 ? ?5.671282e+00 > ? 81 ? ? ?0.156434465 ? ?0.987688341 ? ?6.313752e+00 > ? 82 ? ? ?0.139173101 ? ?0.990268069 ? ?7.115370e+00 > ? 83 ? ? ?0.121869343 ? ?0.992546152 ? ?8.144346e+00 > ? 84 ? ? ?0.104528463 ? ?0.994521895 ? ?9.514364e+00 > ? 85 ? ? ?0.087155743 ? ?0.996194698 ? ?1.143005e+01 > ? 86 ? ? ?0.069756474 ? ?0.997564050 ? ?1.430067e+01 > ? 87 ? ? ?0.052335956 ? ?0.998629535 ? ?1.908114e+01 > ? 88 ? ? ?0.034899497 ? ?0.999390827 ? ?2.863625e+01 > ? 89 ? ? ?0.017452406 ? ?0.999847695 ? ?5.728996e+01 > ? 90 ? ? ?0.000000000 ? ?1.000000000 ? ?1.633124e+16 > > Here's the print function I used to generate the above. > > ? ? ? ? ? ? ? ?print("{0:>5g} ? ? ?{1:.9f} ? ?{2:.9f} ? ?{3:e}".format( > ? ? ? ? ? ? ? ? ? ? ? ? ? ?row, ? ? ? ?cos(theta), sin(theta),tan(theta)), > ? ? ? ? ? ? ? ? ? ? ?end="\n", file= thefile) > > My module starts with: > > from __future__ import printfunction > > which is why I get to use this in 2.6 > > So why use Python as a calculator again? ?Because it's more like > an old office machine with a tape, and that restores some of what > was lost when lookup tables went out of style. ?I should do log10 > next, using range with a step or something.... ?Also, the trig tape > should probably be 0-360 but I didn't want to waste paper. :) > > Kirby > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From christian.mascher at gmx.de Sat Apr 10 15:33:03 2010 From: christian.mascher at gmx.de (Christian Mascher) Date: Sat, 10 Apr 2010 15:33:03 +0200 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: Message-ID: <4BC07E0F.0@gmx.de> Edward Cherlin wrote: > [sigh] > > Do math tables in a math array language. > > degrees =. i. 91 NB. 0..90 > > radians =. degrees * o. % 180 > > table =. |: degrees, 1 2 3 o./ radians Sorry, I don't know J (Kirby does), but this is exactly the reason I prefer Python. Readability counts (for me). For creating a table, most people would probably use a spreadsheet anyway, but as I happen to know Python, I use it for such tasks from time to time. I can even remember the syntax without having used Python for months. Don't think that would be the case with J. Not very inclined to learn that. > > where > > =. is assignment > i. creates a list of consecutive numbers starting at 0. Who on earth would think of that without a manual? > NB. is the comment marker > o. x is pi times x Why not pi? > % x is reciprocal of x, so o. % 180 is pi/180 Don't think that is very useful. > |: is transpose Another very special symbol. > , appends an array to another. It turns a list into a table in order > to match dimensions. Lost you there... > 1 2 3 o. x gives sine, cosine, tangent of x Why don't they use sin(), cos(), tan() like the rest of the mathematical world? > / creates a table with the given function (o.) applied to two list arguments > > The result is a 91 row, 4 column table of angles and trig function values. > Impressive ;-)) > I can easily give you a short sequence of lessons leading to this > level, introducing some other arithmetic, transcendental, and > array-handling functions along the way, and a little more about > operating on functions to define new functions. Python is much nearer to standard Math-notation, that is a good thing. I like to learn new languages - up to a point. I don't see the added value of J in this case. Just my 2c Christian From mpaul213 at gmail.com Sat Apr 10 18:12:04 2010 From: mpaul213 at gmail.com (michel paul) Date: Sat, 10 Apr 2010 09:12:04 -0700 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: Message-ID: The timing of this post was kind of one of those amazing cosmic coincidences, for all kinds of reasons. Thanks, Kirby. I got kicked in the teeth again by an administrator putting the brakes on starting a computational analysis course, the pseudo-arguments having to do with budget constraints. But the dream isn't dead ... I now have some support at the site level from some administrators and from parents who see that this really would be a good thing to do. Letters are being written to the board, lots of discussion fomenting. Way better than when I was completely alone. But an amazing amount of time has been sucked into having to constantly return to square one, or zero, in presenting the value of having a designated computational Math Analysis course. So .. in our regular Analysis class we were doing graphs of polar equations. The kids were a little confused about why certain graphs turned out as they did. Like - in r = sin(x), why is the circle 'all positive'? What happened to the negative sine values? They understood the basic meaning of (r, x), but the behavior of the graphs was bewildering. So I told them to think of a laser gun at the pole whose orientation was x and that fired a beam whose length was r(x). Then visualize the gun rotating through x = [0 .. 2*pi] firing beams of length r(x). (You also have to allow the gun to fire either forwards or backwards.) Then it hit me ... TURTLE! Forward, backward, right, left, ... polar coordinates! I wrote a little turtle module that drew segments from (0,0) to (r(x), x) plotting a little circle at (r(x), x). Very simple. Just a loop setting the turtle heading, calculating the distance, and then going forward (or backward). It beautifully illustrates the laser gun model, because you can actually see it happening. You don't just get a finished graph all at once. Rather, you can actually observe the process of little beams sequentially emanating from the center. I enhanced it by making each beam receive a randomly chosen color. The resulting graphs are really pretty - imagine a polar graph generated by a dense cluster of multi-colored rays from the pole - and the kids totally loved it. There were all kinds of OOOH and AHHHH around the lab the first time I said, "Ready? OK ... run it!" and they got a psychedelic Archimedean spiral. They were then to experiment with different functions for r(x) to create spirals, circles, rose curves, limacons and whatever ... I wanted them to see how they could duplicate the stuff in the text but also explore completely bizarre things on their own. Same loop, but different results depending on r(x). The cool thing was ... this was totally easy. I basically wrote the module - all the kids had to do was experiment with different functions of r(x). But since they had the source code sitting in front of them, they were free to experiment with it, and I encouraged them to do so. So one kid changed the radius of the little circles that were plotting the points. He made it REALLY BIG, and the resulting graphs were fantastic! So all the other kids wanted to do that too. The reason Kirby's post was such a cosmic coincidence is that it appeared on the VERY DAY that I decided to do this with my Analysis kids. Not that I was dealing with tables per se, but we were dealing with trig and with using the Python shell *as a trig calculator*. The timing of all of this was perfect, as the kids really did think this was cool, and one of the kids happens to have a board member as a parent : ) . I was able to say to the kids, you see, I wrote this module for you, but if this was a class where you learned to program from the beginning, you could create this kind of module yourself! So, I really enjoy the way the universe unfolds. - Michel -------------- next part -------------- An HTML attachment was scrubbed... URL: From lognaturel at gmail.com Sat Apr 10 18:23:21 2010 From: lognaturel at gmail.com (Helene Martin) Date: Sat, 10 Apr 2010 09:23:21 -0700 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: Message-ID: I humbly disagree that this is the right place to start. I teach students with diverse backgrounds -- some extremely bright and others really behind in school and using Python as a calculator is one thing they would all agree is terrifically boring and not so compelling. How many students have ever said "man, I really wish I had a trig table right now?" I agree that one way to sell programming is to incorporate it into math courses and maybe that kind of start is more appropriate there. It's not like I start with fireworks and fanfare but I'm thrilled to see Turtle be fun and compelling for students of all levels. Most of them discover Python can do math when they try to see whether they could pass in a scaling parameter and guess that multiplication is probably an asterisk. I mention order of operation and integer division and we move on. I enjoy reading this list and learn many interesting tidbits from it but, as I think I've mentioned before, I often find myself chuckling a bit. A lot of what is said on here is so incredibly esoteric and far from my students' realities! On Thu, Apr 8, 2010 at 7:43 AM, kirby urner wrote: > I think Guido was wise to start his tutorial by showing how we > might use Python as a calculator. > > We might assume many students in this day and age are quite > familiar with this device, and even if they're not, the text might > project one, show a picture on the screen, if what these things > used to look like (still do). > > However, one thing calculators lack over the old wood pulp > textbooks are trig tables with multiple rows showing a lot of > data at the same time. ?Their small "chat window" does not > permit much data to be seen at one time. > > Back in the day, a student could run her finger down the > rows, as the number of angular degrees increase from > 0 to 60 and onward to 90, perhaps all the way around to > 360. > > Going across the row, one would have sine and cosine, > perhaps tangent. ?Having all the data visible at once, or spread > across a few pages, inspired some insights and understanding, > as one could see the trends in the numbers, plus these > "click stop" rows where the numbers would suddenly be > super easy, like 1/2 and 1/2 for both sine and cosine. > > Calculators don't give us that kind of output, but earlier office > computing machines did have paper i/o, called a tape, usually > a scroll mounted on a spool and fed through a small printer. > > As one added numbers, one printed to tape, perhaps a running > total. ?The tape itself was a valuable item (especially once it > had the data on it). > > Large computers came with line printers that hit on continuous > feed paper with holes along both sides, often with green and > white stripes. ?I will not try to recapitulate the long history > of printing devices, except to point out that computers > inherited them while slide rules and calculators did not. > > The equivalent in Python is stdout and/or some file in storage, > on the hard drive or memory stick. ?The program output > shown below would be an example of this kind of i/o. > > Notice that unless a file name is given (optional), the data > is to stdout. > > I'm going to do a full 90 degrees, just to remind myself of > the patterns students got in the old days, before trig tables > were replaced with calculators, much as dial watches were > replaced with digital ones (not necessarily a smart move > in all cases). > >>>> imp.reload(newprint) > >>>> newprint.trigtable(range(91), "trigtable.txt") > > The contents of trigtable.txt: > > ? ?0 ? ? ?1.000000000 ? ?0.000000000 ? ?0.000000e+00 > ? ?1 ? ? ?0.999847695 ? ?0.017452406 ? ?1.745506e-02 > ? ?2 ? ? ?0.999390827 ? ?0.034899497 ? ?3.492077e-02 > ? ?3 ? ? ?0.998629535 ? ?0.052335956 ? ?5.240778e-02 > ? ?4 ? ? ?0.997564050 ? ?0.069756474 ? ?6.992681e-02 > ? ?5 ? ? ?0.996194698 ? ?0.087155743 ? ?8.748866e-02 > ? ?6 ? ? ?0.994521895 ? ?0.104528463 ? ?1.051042e-01 > ? ?7 ? ? ?0.992546152 ? ?0.121869343 ? ?1.227846e-01 > ? ?8 ? ? ?0.990268069 ? ?0.139173101 ? ?1.405408e-01 > ? ?9 ? ? ?0.987688341 ? ?0.156434465 ? ?1.583844e-01 > ? 10 ? ? ?0.984807753 ? ?0.173648178 ? ?1.763270e-01 > ? 11 ? ? ?0.981627183 ? ?0.190808995 ? ?1.943803e-01 > ? 12 ? ? ?0.978147601 ? ?0.207911691 ? ?2.125566e-01 > ? 13 ? ? ?0.974370065 ? ?0.224951054 ? ?2.308682e-01 > ? 14 ? ? ?0.970295726 ? ?0.241921896 ? ?2.493280e-01 > ? 15 ? ? ?0.965925826 ? ?0.258819045 ? ?2.679492e-01 > ? 16 ? ? ?0.961261696 ? ?0.275637356 ? ?2.867454e-01 > ? 17 ? ? ?0.956304756 ? ?0.292371705 ? ?3.057307e-01 > ? 18 ? ? ?0.951056516 ? ?0.309016994 ? ?3.249197e-01 > ? 19 ? ? ?0.945518576 ? ?0.325568154 ? ?3.443276e-01 > ? 20 ? ? ?0.939692621 ? ?0.342020143 ? ?3.639702e-01 > ? 21 ? ? ?0.933580426 ? ?0.358367950 ? ?3.838640e-01 > ? 22 ? ? ?0.927183855 ? ?0.374606593 ? ?4.040262e-01 > ? 23 ? ? ?0.920504853 ? ?0.390731128 ? ?4.244748e-01 > ? 24 ? ? ?0.913545458 ? ?0.406736643 ? ?4.452287e-01 > ? 25 ? ? ?0.906307787 ? ?0.422618262 ? ?4.663077e-01 > ? 26 ? ? ?0.898794046 ? ?0.438371147 ? ?4.877326e-01 > ? 27 ? ? ?0.891006524 ? ?0.453990500 ? ?5.095254e-01 > ? 28 ? ? ?0.882947593 ? ?0.469471563 ? ?5.317094e-01 > ? 29 ? ? ?0.874619707 ? ?0.484809620 ? ?5.543091e-01 > ? 30 ? ? ?0.866025404 ? ?0.500000000 ? ?5.773503e-01 > ? 31 ? ? ?0.857167301 ? ?0.515038075 ? ?6.008606e-01 > ? 32 ? ? ?0.848048096 ? ?0.529919264 ? ?6.248694e-01 > ? 33 ? ? ?0.838670568 ? ?0.544639035 ? ?6.494076e-01 > ? 34 ? ? ?0.829037573 ? ?0.559192903 ? ?6.745085e-01 > ? 35 ? ? ?0.819152044 ? ?0.573576436 ? ?7.002075e-01 > ? 36 ? ? ?0.809016994 ? ?0.587785252 ? ?7.265425e-01 > ? 37 ? ? ?0.798635510 ? ?0.601815023 ? ?7.535541e-01 > ? 38 ? ? ?0.788010754 ? ?0.615661475 ? ?7.812856e-01 > ? 39 ? ? ?0.777145961 ? ?0.629320391 ? ?8.097840e-01 > ? 40 ? ? ?0.766044443 ? ?0.642787610 ? ?8.390996e-01 > ? 41 ? ? ?0.754709580 ? ?0.656059029 ? ?8.692867e-01 > ? 42 ? ? ?0.743144825 ? ?0.669130606 ? ?9.004040e-01 > ? 43 ? ? ?0.731353702 ? ?0.681998360 ? ?9.325151e-01 > ? 44 ? ? ?0.719339800 ? ?0.694658370 ? ?9.656888e-01 > ? 45 ? ? ?0.707106781 ? ?0.707106781 ? ?1.000000e+00 > ? 46 ? ? ?0.694658370 ? ?0.719339800 ? ?1.035530e+00 > ? 47 ? ? ?0.681998360 ? ?0.731353702 ? ?1.072369e+00 > ? 48 ? ? ?0.669130606 ? ?0.743144825 ? ?1.110613e+00 > ? 49 ? ? ?0.656059029 ? ?0.754709580 ? ?1.150368e+00 > ? 50 ? ? ?0.642787610 ? ?0.766044443 ? ?1.191754e+00 > ? 51 ? ? ?0.629320391 ? ?0.777145961 ? ?1.234897e+00 > ? 52 ? ? ?0.615661475 ? ?0.788010754 ? ?1.279942e+00 > ? 53 ? ? ?0.601815023 ? ?0.798635510 ? ?1.327045e+00 > ? 54 ? ? ?0.587785252 ? ?0.809016994 ? ?1.376382e+00 > ? 55 ? ? ?0.573576436 ? ?0.819152044 ? ?1.428148e+00 > ? 56 ? ? ?0.559192903 ? ?0.829037573 ? ?1.482561e+00 > ? 57 ? ? ?0.544639035 ? ?0.838670568 ? ?1.539865e+00 > ? 58 ? ? ?0.529919264 ? ?0.848048096 ? ?1.600335e+00 > ? 59 ? ? ?0.515038075 ? ?0.857167301 ? ?1.664279e+00 > ? 60 ? ? ?0.500000000 ? ?0.866025404 ? ?1.732051e+00 > ? 61 ? ? ?0.484809620 ? ?0.874619707 ? ?1.804048e+00 > ? 62 ? ? ?0.469471563 ? ?0.882947593 ? ?1.880726e+00 > ? 63 ? ? ?0.453990500 ? ?0.891006524 ? ?1.962611e+00 > ? 64 ? ? ?0.438371147 ? ?0.898794046 ? ?2.050304e+00 > ? 65 ? ? ?0.422618262 ? ?0.906307787 ? ?2.144507e+00 > ? 66 ? ? ?0.406736643 ? ?0.913545458 ? ?2.246037e+00 > ? 67 ? ? ?0.390731128 ? ?0.920504853 ? ?2.355852e+00 > ? 68 ? ? ?0.374606593 ? ?0.927183855 ? ?2.475087e+00 > ? 69 ? ? ?0.358367950 ? ?0.933580426 ? ?2.605089e+00 > ? 70 ? ? ?0.342020143 ? ?0.939692621 ? ?2.747477e+00 > ? 71 ? ? ?0.325568154 ? ?0.945518576 ? ?2.904211e+00 > ? 72 ? ? ?0.309016994 ? ?0.951056516 ? ?3.077684e+00 > ? 73 ? ? ?0.292371705 ? ?0.956304756 ? ?3.270853e+00 > ? 74 ? ? ?0.275637356 ? ?0.961261696 ? ?3.487414e+00 > ? 75 ? ? ?0.258819045 ? ?0.965925826 ? ?3.732051e+00 > ? 76 ? ? ?0.241921896 ? ?0.970295726 ? ?4.010781e+00 > ? 77 ? ? ?0.224951054 ? ?0.974370065 ? ?4.331476e+00 > ? 78 ? ? ?0.207911691 ? ?0.978147601 ? ?4.704630e+00 > ? 79 ? ? ?0.190808995 ? ?0.981627183 ? ?5.144554e+00 > ? 80 ? ? ?0.173648178 ? ?0.984807753 ? ?5.671282e+00 > ? 81 ? ? ?0.156434465 ? ?0.987688341 ? ?6.313752e+00 > ? 82 ? ? ?0.139173101 ? ?0.990268069 ? ?7.115370e+00 > ? 83 ? ? ?0.121869343 ? ?0.992546152 ? ?8.144346e+00 > ? 84 ? ? ?0.104528463 ? ?0.994521895 ? ?9.514364e+00 > ? 85 ? ? ?0.087155743 ? ?0.996194698 ? ?1.143005e+01 > ? 86 ? ? ?0.069756474 ? ?0.997564050 ? ?1.430067e+01 > ? 87 ? ? ?0.052335956 ? ?0.998629535 ? ?1.908114e+01 > ? 88 ? ? ?0.034899497 ? ?0.999390827 ? ?2.863625e+01 > ? 89 ? ? ?0.017452406 ? ?0.999847695 ? ?5.728996e+01 > ? 90 ? ? ?0.000000000 ? ?1.000000000 ? ?1.633124e+16 > > Here's the print function I used to generate the above. > > ? ? ? ? ? ? ? ?print("{0:>5g} ? ? ?{1:.9f} ? ?{2:.9f} ? ?{3:e}".format( > ? ? ? ? ? ? ? ? ? ? ? ? ? ?row, ? ? ? ?cos(theta), sin(theta),tan(theta)), > ? ? ? ? ? ? ? ? ? ? ?end="\n", file= thefile) > > My module starts with: > > from __future__ import printfunction > > which is why I get to use this in 2.6 > > So why use Python as a calculator again? ?Because it's more like > an old office machine with a tape, and that restores some of what > was lost when lookup tables went out of style. ?I should do log10 > next, using range with a step or something.... ?Also, the trig tape > should probably be 0-360 but I didn't want to waste paper. :) > > Kirby > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > From calcpage at aol.com Sat Apr 10 20:07:28 2010 From: calcpage at aol.com (calcpage at aol.com) Date: Sat, 10 Apr 2010 14:07:28 -0400 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: Message-ID: <8CCA6EFD0FAA325-1A4C-1C9F1@webmail-d086.sysops.aol.com> This thread is very interesting. As a mater of fact, I've been trying to get 2 new course approvals at my High School for several years now and suddenly I have the go ahead for both! For more info on all the python related projects I'm involved with as summarized below, please see my blog: http://calcpage.tripod.com/shadowfax 1) Computer Math: I have run this pre AP Computer Science class for nearly 30 years. Its an introduction to programming via BASIC incorporating concepts from Discrete Mathematics. I've used every form of BASIC that ever existed (console, gui, windows, linux, etc). It was time for a change. Next year I'm using a new text by Gary & Maria Litvin called "Mathematics for the Digital Age.". This book covers all the same topics my own home-grown text does but uses python! Also, I'll be using SAGE (http://www.sagenb.org) to write the programs. 2) Calculus Research Lab: This is a course in Scientific Computing. I will take students already taking Calculus and meet with them an additional period every other day like a Science lab. We will be using online Calculus texts in pdf format on the SAGE website (http://www.sagemath.org) to reinforce concepts they learn in AP Calculus AB and AP Calculus BC class. Needless to say, I'll be using SAGE here too, but we will be more focused on Computer Algebra Systems. This course was approved last year, but the guidance counselors messed up scheduling several new courses so it didn't run this year, but we have enrollment for next year! HTH, A. Jorge Garcia http://calcpage.tripod.com Teacher & Professor Applied Mathematics, Physics?& Computer Science Baldwin Senior High School & Nassau Community College From da.ajoy at gmail.com Sat Apr 10 22:37:29 2010 From: da.ajoy at gmail.com (Daniel Ajoy) Date: Sat, 10 Apr 2010 15:37:29 -0500 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: Message-ID: On Sat, 10 Apr 2010 11:23:23 -0500, wrote: > I humbly disagree that this is the right place to start. I teach > students with diverse backgrounds -- some extremely bright and others > really behind in school and using Python as a calculator is one thing > they would all agree is terrifically boring and not so compelling. > How many students have ever said "man, I really wish I had a trig > table right now?" What kind of things do you think kids would find exciting about programming? I've identified these things: Turtle Graphics Sprite Animations Virtual Robot programming Number crunching Make the computer do your homework In "number crunching" I try to collect all the things that excite students about making the computer show its awesome powers of calculation. I think there is an element of excitement in making a program that makes the computer work a lot to produce results. Maybe, that table falls into this category. I have the impression that using a programming language as a calculator is boring, too. But if we use it to help us solve homework I think it becomes interesting. Thinks like, solve: (x + 2) / 10 = 100 to solve do.while [ make "x random 1000 ] [not (:x + 2) / 10 = 100] print :x end solve 998 Daniel From macquigg at ece.arizona.edu Sat Apr 10 22:41:11 2010 From: macquigg at ece.arizona.edu (David MacQuigg) Date: Sat, 10 Apr 2010 13:41:11 -0700 Subject: [Edu-sig] using Python as a calculator In-Reply-To: <4BC07E0F.0@gmx.de> References: <4BC07E0F.0@gmx.de> Message-ID: <4BC0E267.1020003@ece.arizona.edu> Christian Mascher wrote: > Edward Cherlin wrote: >> [sigh] >> >> Do math tables in a math array language. >> >> degrees =. i. 91 NB. 0..90 >> >> radians =. degrees * o. % 180 >> >> table =. |: degrees, 1 2 3 o./ radians > > Sorry, I don't know J (Kirby does), but this is exactly the reason I > prefer Python. Readability counts (for me). For creating a table, most > people would probably use a spreadsheet anyway, but as I happen to > know Python, I use it for such tasks from time to time. I can even > remember the syntax without having used Python for months. Don't think > that would be the case with J. Not very inclined to learn that. I agree. Clarity is important, especially with young students (and us old guys who have trouble remembering Java classes :>). from math import sin, cos, tan, pi rad_per_degree = pi/180 pattern = "{0:>5g} {1:.9f} {2:.9f} {3:e}" def print_trig_table(start, stop, step): . for degrees in range(start, stop, step): . theta = degrees * rad_per_degree . data = ( degrees, cos(theta), sin(theta), tan(theta) ) . print( pattern.format(*data) ) The only thing a little non-intuitive about this is the construct pattern.format(*data). It's the same problem as with "".join(list). It feels backwards until you really grasp the concept of these methods being associated with string objects, not with the data, which can be any of various object types. Back to the subject of Python as a calculator, I have offered to mentor a proposal in Google Summer of Code seeking to improve IDLE. A key item is adding the ability to display graphics. This should be as easy as just pressing the GRAPH button, but also not limit students who want the full sophistication of a package like matplotlib. Suggestions are welcome. From kirby.urner at gmail.com Sun Apr 11 00:08:18 2010 From: kirby.urner at gmail.com (kirby urner) Date: Sat, 10 Apr 2010 15:08:18 -0700 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: Message-ID: On Fri, Apr 9, 2010 at 9:41 AM, Edward Cherlin wrote: > [sigh] > > Do math tables in a math array language. > > degrees =. i. 91 NB. 0..90 > > radians =. degrees * o. % 180 > > table =. |: degrees, 1 2 3 o./ radians > > where > > =. is assignment > i. creates a list of consecutive numbers starting at 0. > NB. is the comment marker > o. x is pi times x > % x is reciprocal of x, so o. % 180 is pi/180 > |: is transpose > , appends an array to another. It turns a list into a table in order > to match dimensions. > 1 2 3 o. x gives sine, cosine, tangent of x > / creates a table with the given function (o.) applied to two list > arguments > > Thanks Ed. Nostalgia trip. Yeah, my first reaction was similar to Christians: if we need to learn a whole new language to do a trig table, that's hardly productive-seeming. How to use the tools we already know? And yet I've suggested a minimum of two languages, even if foreground emphasis is given to just one. The other might be purposely off-beat, like COBOL or something. REBOL anyone? Or it might be a closer relative to Python, such as JavaScript (for which Alan Kay has a lot of respect). NB. for nota bene as I recall. I always treasure the Italian influence. APL was (is) like Greek. Below is the source for the trig table generator, a snap shot. The inner circle on this one, which includes Chairman Steve, is debating whether TypeError should really be caught. On the "aff side" (as debaters say, when arguing in the affirmative), a capricious, not necessarily malicious user might feed in a filename of like 3, or type([ ]). That's not a filename at all, so catch it with TypeError. On the "neg side", there's a school of thought which says exceptions are about catching "honest mistakes" i.e. the exception suite is showing what one might legitimately expect as an error: in this case an IOError because the file cannot be created (e.g. is write-protected, is specified in a non-existent directory or something of that nature). I forget how J handles exceptions of this nature (wrong path, write-protected file) -- I seem to recall a bunch of system call features, but it has been some years... Kirby === def trigtable(therange, fileout = None): """ Print a trig table, to stdout or to a file http://mail.python.org/pipermail/edu-sig/2010-April/009890.html Rewrite with "with statement"? """ if fileout: try: thefile = open(fileout, 'w') #lets hope for a legal filename (optional path part) except (TypeError, IOError) as exc: print("Unable to open file: {0}".format(fileout)) raise else: thefile = sys.stdout for row in therange: theta = radians(row) print("{0:>5g} {1:.9f} {2:.9f} {3:e}".format( row,cos(theta),sin(theta),tan(theta)),file= thefile) if fileout: thefile.close() > The result is a 91 row, 4 column table of angles and trig function values. > > -- > Edward Mokurai (??/???????????????/????????????? ?) Cherlin > Silent Thunder is my name, and Children are my nation. > The Cosmos is my dwelling place, the Truth my destination. > http://www.earthtreasury.org/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kirby.urner at gmail.com Sun Apr 11 01:06:30 2010 From: kirby.urner at gmail.com (kirby urner) Date: Sat, 10 Apr 2010 16:06:30 -0700 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: Message-ID: On Sat, Apr 10, 2010 at 9:23 AM, Helene Martin wrote: > I humbly disagree that this is the right place to start. I teach > students with diverse backgrounds -- some extremely bright and others > really behind in school and using Python as a calculator is one thing > they would all agree is terrifically boring and not so compelling. > How many students have ever said "man, I really wish I had a trig > table right now?" > > Yes Helen, I really do understand this concern. It's a concern that somewhat worries me though. Maybe the problem is students aren't being paid to be there. Should we offer frequent flyer miles for assignments turned in? On Delta? > I agree that one way to sell programming is to incorporate it into > math courses and maybe that kind of start is more appropriate there. > > Ah, now I see the problem. There's this notion of trying to "sell programming" whereas world class schools already mix computer programming with math. Speaking of which, check out this cool steampunk monitor: http://steampunkworkshop.com/lcd.shtml > It's not like I start with fireworks and fanfare but I'm thrilled to > see Turtle be fun and compelling for students of all levels. Most of > them discover Python can do math when they try to see whether they > could pass in a scaling parameter and guess that multiplication is > probably an asterisk. I mention order of operation and integer > division and we move on. > > My students know they likely won't be taken seriously if they boast of math skills and yet evidence no ability to think like computer scientists. Knowing how to program is just one of those "goes with the territory" kinds of skills associated with STEM. My bias derives from literature funded in some measure by DARPA-with-a-backwards-R -- for "radical" (a CP4E commercial). Why is OLPC / G1G1 is so important: to help kids elsewhere from suffering the same fate. > I enjoy reading this list and learn many interesting tidbits from it > but, as I think I've mentioned before, I often find myself chuckling a > bit. A lot of what is said on here is so incredibly esoteric and far > from my students' realities! > I teach Pythonic Math off and on through a nonprofit backed by Silicon Forest interests. The view of many Silicon Foresters is that the traditional math education being provided in high schools is simply a forced march in the wrong direction. My students have been highly diverse, including a Goth girl who hated school (wicked smart though), many with English as a 2nd language, many home schoolers. Lots of disaffected, refugees. Those doing well on the calculator / calculus track may see no reason to leave The Matrix. Kirby -------------- next part -------------- An HTML attachment was scrubbed... URL: From droujkova at gmail.com Sun Apr 11 01:18:30 2010 From: droujkova at gmail.com (Maria Droujkova) Date: Sat, 10 Apr 2010 19:18:30 -0400 Subject: [Edu-sig] Confused how teach geometry and importance of teaching geometry in 21st century. In-Reply-To: <20100326024032.GA22309@seberino.org> References: <20100326024032.GA22309@seberino.org> Message-ID: Check out GeoGebra OER community. There will be a US conference this year, and the online resources and groups are good, too. A lot of my students appreciate geometry through the following lenses: - Origami - Computer graphics, especially programming cool visuals for games - Escher, Dali, and other "surreal" space transformations - we are doing a lot of it in our "Alice in Wonderland" class, hehe. We watch videos a lot, too. Mobius transformation: http://www.youtube.com/watch?v=JX3VmDgiFnY Bach on Mobius strip: http://www.youtube.com/watch?v=xUHQ2ybTejU Cheers, Maria Droujkova http://www.naturalmath.com Make math your own, to make your own math. On Thu, Mar 25, 2010 at 10:40 PM, wrote: > I'm teaching high school math to homeschoolers and I'm looking for how to > make > geometry year meaningful. > > I'm having a "crisis of confidence" because from my viewpoint, algebra was > 10x > more useful for future math and science work. > > The only thing I can remember that was useful from geometry was a few > volume > and area formulas. That can justify maybe a month but not a whole YEAR of > geometry!?!? > > cs > > P.S. Yes yes I know that geometry is meant to teach logical reasoning. > Maybe > one can get that from chess, debate club and other activities as well if > not better? People also say geometry is where you learn proofs. Couldn't > proofs be just as easily emphasized in all the other math classes? > > -- > _______________________________________ > > Christian Seberino, Ph.D. > Email: chris at seberino.org > _______________________________________ > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kirby.urner at gmail.com Sun Apr 11 01:41:36 2010 From: kirby.urner at gmail.com (kirby urner) Date: Sat, 10 Apr 2010 16:41:36 -0700 Subject: [Edu-sig] Radical Math: debugging help? Message-ID: Below is current source for ch.py, a module for exploring volume relationships starting with a "ground state" (a default) known as the concentric hierarchy of polyhedra. The user begets various polyhedra from their class definitions, then resizes them at will, perhaps using the * operator in place of the scale method: >>> import ch >>> rt = ch.R_Triac() >>> rt.volume 7.5 >>> rt = rt * pow(2/3., 1/3.) DEBUG: a star is born: a new R_Triac >>> rt.volume 5.0000000000000009 >>> rt.edge 0.61771467052713269 >>> rt = ch.R_Triac() >>> rt.edge 0.70710678118654757 >>> rt.edge_name 'long face diagonal' The concentric hierarchy is formed from the five Platonics, a primitive set that is closed under the operation of "make my dual". When the duals combine, e.g. the tetrahedron with itself, you have the option to intersect the edges so as to form yet another polyhedron (not necessarily Platonic). Here's what you can do with the five Platonics in that regard (i.e. o + o.dual == something). tetrahedron + tetrahedron == cube octahedron + cube == rhombic dodecahedron icosahedron + pentagonal dodecahedron == rhombic triacontahedron There's some question as to how to scale these relative to one another, when defining a ground state. The tetrahedron, cube, octahedron and rhombic dodecahedron all have obvious volume relationships if you start in this way. Anyway, here's my puzzle: I'm using Python 2.6, but my call to Poly.__init__ within its subclasses would surely be more stylish where super() used instead. However, all my trials with super(), have so far resulted in errors. If you fix this and even provide a clear explanation as to how this fix works, you might become part of a famous inner circle. The concentric hierarchy is poised to take the world by storm, at least in NCTM circles. Here's a lesson plan I've been touting. http://www.bfi.org/our_programs/bfi_community/synergetics (follow link to NCTM web site) Kirby PS: all the dual combos are rhombohedra i.e. have rhombic faces. You may criss-cross these diamond faces to get tri-rectangular tetrahedral wedge shapes that include the center point. In the case of the cube and rhombic dodecahedron, one gets the same shape, called a Mite in this namespace (for "minimum tetrahedron" -- it's a space-filler). In the case of the rhombic triacontahedron, one gets the T-module (T for triacontahedron). Provided our scaling is done right, 3 * T = Mite (volumetrically speaking). I will be adding these in a next edition. My thanks to David Koski for technical assistance on this project. *====== ch.py ====== from math import sqrt as radical phi = (1 + radical(5))/2 class Poly: def __init__(self, edge = 1, edge_name = "edge", volume = 1, greekname = "Tetrahedron"): self.edge = edge self.edge_name = edge_name self.volume = volume self.greekname = greekname def scale(self, scalefactor): edge = self.edge * scalefactor # edge unbound to self volume = self.volume * pow(scalefactor, 3) # likewise volume print("DEBUG: a star is born: a new %s" % self.__class__.__name__) return self.__class__(edge = edge, edge_name = self.edge_name, volume = volume, greekname = self.greekname) __mul__ = __rmul__ = scale # e.g. tetra = tetra * 3 def __repr__(self): return "Polyhedron of type %s (vol: %s)" % (self.greekname, self.volume) class Tetra( Poly ): pass class Cube( Poly ): def __init__(self, edge = 1, edge_name = "face diagonal", volume = 3, greekname = "Hexahedron"): Poly.__init__(self, *(edge, edge_name, volume, greekname)) class Octa( Poly ): def __init__(self, edge = 1, edge_name = "edge", volume = 4, greekname = "Octahedron"): Poly.__init__(self, *(edge, edge_name, volume, greekname)) class R_Dodeca( Poly ): def __init__(self, edge = 1, edge_name = "long face diagonal", volume = 6, greekname = "Rhombic dodecahedron"): Poly.__init__(self, *(edge, edge_name, volume, greekname)) class R_Triac( Poly ): def __init__(self, edge = radical(2)/2, edge_name = "long face diagonal", volume = 7.5, greekname = "Rhombic Triacontahedron"): Poly.__init__(self, *(edge, edge_name, volume, greekname)) class Icosa ( Poly ): def __init__(self, edge = 1, edge_name = "edge", volume = 5 * phi**2 * radical(2), greekname = "Icosahedron"): Poly.__init__(self, *(edge, edge_name, volume, greekname)) class Cubocta ( Poly ): def __init__(self, edge = 1, edge_name = "edge", volume = 20, greekname = "Cuboctahedron"): Poly.__init__(self, *(edge, edge_name, volume, greekname)) -------------- next part -------------- An HTML attachment was scrubbed... URL: From lognaturel at gmail.com Sun Apr 11 06:25:34 2010 From: lognaturel at gmail.com (Helene Martin) Date: Sat, 10 Apr 2010 21:25:34 -0700 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: Message-ID: (Speaking as a high school teacher with ~120 students in 3 different levels of computer science courses in a public school in Seattle) I guess my point is that computer science in general and programming specifically have so much opportunity to be exciting for both the majority of students who are burned out on "traditional classes" as well as the minority of students who "know they likely won't be taken seriously if they boast of math skills and yet evidence no ability to think like computer scientists" (come on, that requires a high level of intellectual sophistication and is REALLY rare). I think we need to exploit that opportunity to its full potential. I steer away from purely math-oriented examples because they alienate the majority of my students. It's a tricky balancing act and I certainly can't claim to have figured it out. Selfishly, I'd like to see the brilliant minds in this group sharing examples or ideas that the average 13-18 year old would find exciting and worthy of further exploration. For example, a while back, Gregor Lingl shared a Turtle Graphics example in which a turtle performs a random walk collecting "coins" as it goes. There are lots of interesting mathematical concepts to discuss in there and it requires students to use a lot of programming tools and ideas but it also has a "cool" factor. Furthermore, the basic idea is reasonably simple to understand and to see a use for (we can simulate other kinds of real-world situations, etc). I agree that we as educators are not entertainers and that learning is important for the sake of learning but at the same time, we need to be careful not to on one hand deplore the fact that students aren't taking computing courses while on the other creating courses which are dry and esoteric. Again, I don't claim to have figured it out. I say all this but at the same time, I'm wary of courses which expose students to computing applications without giving them many skills (programming/critical thinking/math/algorithmics) or which rely entirely on one application space (animation, games, personal robots, whatever) to be "sexy" and capture students' attention. I suppose it's all about goals. One potential goal for using Python in teaching is to reinforce and develop mathematical reasoning skills and it seems like that's the focus of a lot of the people on this list. I believe that's a worthy goal and I try to accomplish some of that in my courses as well, but it's not my primary goal. I guess my primary goal is to encourage students to see software as something they can be a part of rather than simply as something they consume or are forced to live with. I don't have a ton of concrete ideas on how to do that -- I think I've somehow crafted successful courses on intuition more than anything else and can't really formally express what I'm doing yet -- but I really do see it as a very different goal that leads to very different types of courses. And maybe I'm the only one who sees the majority of examples and ideas on this list as esoteric! It's something I often find myself thinking so I thought I'd try to describe and explain a bit of my discomfort. Not sure I really expressed myself very well -- sorry! H?l?ne. On Sat, Apr 10, 2010 at 4:06 PM, kirby urner wrote: > On Sat, Apr 10, 2010 at 9:23 AM, Helene Martin wrote: >> >> I humbly disagree that this is the right place to start. ?I teach >> students with diverse backgrounds -- some extremely bright and others >> really behind in school and using Python as a calculator is one thing >> they would all agree is terrifically boring and not so compelling. >> How many students have ever said "man, I really wish I had a trig >> table right now?" >> > > Yes Helen, I really do understand this concern. > It's a concern that somewhat worries me though. > Maybe the problem is students aren't being paid to be there. > Should we offer frequent flyer miles for assignments turned in? ?On Delta? > >> >> I agree that one way to sell programming is to incorporate it into >> math courses and maybe that kind of start is more appropriate there. >> > > Ah, now I see the problem. > There's this notion of trying to "sell programming" whereas world class > schools already mix computer programming with math. > Speaking of which, check out this cool steampunk monitor: > http://steampunkworkshop.com/lcd.shtml > >> >> It's not like I start with fireworks and fanfare but I'm thrilled to >> see Turtle be fun and compelling for students of all levels. ?Most of >> them discover Python can do math when they try to see whether they >> could pass in a scaling parameter and guess that multiplication is >> probably an asterisk. ?I mention order of operation and integer >> division and we move on. >> > > My students know they likely won't be taken seriously if they boast of math > skills and yet evidence no ability to think like computer scientists. > Knowing how to program is just one of those "goes with the territory" kinds > of skills associated with STEM. > My bias derives from literature funded in some measure by > DARPA-with-a-backwards-R -- for "radical" ?(a CP4E commercial). > Why is OLPC / G1G1 is so important: ?to help kids elsewhere from suffering > the same fate. > >> >> I enjoy reading this list and learn many interesting tidbits from it >> but, as I think I've mentioned before, I often find myself chuckling a >> bit. ?A lot of what is said on here is so incredibly esoteric and far >> from my students' realities! > > I teach Pythonic Math off and on through a nonprofit backed by Silicon > Forest interests. > The view of many Silicon Foresters is that the traditional math education > being provided in high schools is simply a forced march in the wrong > direction. > My students have been highly diverse, including a Goth girl who hated school > (wicked smart though), many with English as a 2nd language, many home > schoolers. ?Lots of disaffected, refugees. > Those doing well on the calculator / calculus track may see no reason to > leave The Matrix. > Kirby > From svenforum at gmail.com Sun Apr 11 07:20:12 2010 From: svenforum at gmail.com (Sven De Mol) Date: Sun, 11 Apr 2010 07:20:12 +0200 Subject: [Edu-sig] ~~Hi~~ Message-ID: http://www.srednovekoven-ohrid.com.mk/SX7yJVqiJB.htm From kirby.urner at gmail.com Sun Apr 11 11:32:26 2010 From: kirby.urner at gmail.com (kirby urner) Date: Sun, 11 Apr 2010 02:32:26 -0700 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: Message-ID: On Sat, Apr 10, 2010 at 9:25 PM, Helene Martin wrote: > > (Speaking as a high school teacher with ~120 students in 3 different > levels of computer science courses in a public school in Seattle) > That's hard work and you have my respect for it. I started out as a full time high school teacher, mostly math, but only stayed with St. Dominic Academy (Jersey City) for two years. Later I wound up at McGraw-Hill and looked from the text book publisher angle (I was on the 28th floor of a skyscraper in Rockefeller Center, commuting from my friend Ray Simon's apartment in Brooklyn. > I guess my point is that computer science in general and programming > specifically have so much opportunity to be exciting for both the > majority of students who are burned out on "traditional classes" as > well as the minority of students who "know they likely won't be taken > seriously if they boast of math skills and yet evidence no ability to > think like computer scientists" (come on, that requires a high level > of intellectual sophistication and is REALLY rare). ?I think we need > to exploit that opportunity to its full potential. > > I steer away from purely math-oriented examples because they alienate > the majority of my students. ?It's a tricky balancing act and I > certainly can't claim to have figured it out. ?Selfishly, I'd like to > see the brilliant minds in this group sharing examples or ideas that > the average 13-18 year old would find exciting and worthy of further > exploration. ?For example, a while back, Gregor Lingl shared a Turtle > Graphics example in which a turtle performs a random walk collecting > "coins" as it goes. ?There are lots of interesting mathematical > concepts to discuss in there and it requires students to use a lot of > programming tools and ideas but it also has a "cool" factor. > Furthermore, the basic idea is reasonably simple to understand and to > see a use for (we can simulate other kinds of real-world situations, > etc). > Yes, and I would not want to get in your way. What I like to do in some of my classes (I still get teaching gigs through the private sector) is show up with an XO or two, those One Laptop per Child gizmos that Ed does Turtle Art for. Our XO HQS in Portland, Oregon is one Duke's Landing on SE Belmont, where Michael D. is tending mine among others, got me a developer's key and everything, upgraded me to the latest Sugar. http://www.flickr.com/search/?q=XO&w=17157315 at N00 (tagged with XO in my Photostream) http://www.flickr.com/photos/17157315 at N00/4104822975/ http://www.flickr.com/photos/17157315 at N00/4105591168/ (at Duke's specifically) The Python application that puts Python most in one's scope is called Pippy. The fact that Sugar itself is a Python program will escape notice unless they somehow get access to this lore, through a teacher or other peer, perhaps via the Web. The last gig I did was for a Free School event near Duke's, a place called Flipside around the corner from Muddy Water's. http://worldgame.blogspot.com/2010/03/radical-math.html Anyway, that's a lot of Portland geography most people here won't know (check Google Earth if curious, or Google Street Views -- here's Duke's http://preview.tinyurl.com/ydeyzjl ). Also, in the public sector, I took the whole of Winterhaven's 8th grade for a spin. Winterhaven is a one of Portland public's and a kind of geek Hogwarts for some families. It only goes up through middle school though (8th grade). What I taught there was a mixture of Python and GIS/GPS subjects, per recommendations from other faculty. The thinking has evolved since then to where we might adapt this for high schools by having kids actually venture forth from their buildings in teams, riding the buses and such, following various clues -- a kind of geocaching as an organized sport, but also an academic exercise. I could send links, but this is already pretty long. Here's a peak at some of the work that we accomplished at Winterhaven. http://www.4dsolutions.net/ocn/winterhaven/ > I agree that we as educators are not entertainers and that learning is > important for the sake of learning but at the same time, we need to be > careful not to on one hand deplore the fact that students aren't > taking computing courses while on the other creating courses which are > dry and esoteric. > What we're trying to get off the ground in Oregon are pilot classes that go towards the 3 year math requirement (mandatory for a h.s. diploma) yet include computer programming as a part of the content, maybe (I personally would hope) more of this GIS/GPS stuff. It's a math course in other words, and yet Python might be used for a language, like if teachers go with the Litvins' text, which I highly recommend, among others. In a hands-on music class, students pick an instrument. In hands-on math, you pick a computer language (at least one, but one leads to another if a student gets curious). I just got a mailing from Saturday Academy today in fact, listing some of my students for such a class at Reed College (just a short pilot). I call my portion Martian Math and have pages on Wikieducator about it. These will be younger students than I'm used to. My associate Glenn Stockton is doing Neolithic Math and Tai Chi with the same group. Neolithic Math, like Martian Math, is just branding we're using, hoping to keep things interesting. In terms of content, you'd want to look at the write-up, but it includes Euclidean basics such as the Vesica Pices and generating edge lengths with string and stick (compass and ruler), using these edges in constructions (such as polyhedra). You may have seen the polyhedra go by in a short script here recently. Obviously some of this material is further down the timeline than either the Paleolithic, Neolithic or Mesolithic eras. Some of it is downright futuristic, which is where my Martian Math stuff kicks in. We try to provide some continuity in our students' experience, picking up on some cues from Ralph Abraham at the Oregon Math Summit in 1997, Sir Roger Penrose a keynote. He suggested a more time-line based approach, more direct linking to history. > Again, I don't claim to have figured it out. ?I say all this but at > the same time, I'm wary of courses which expose students to computing > applications without giving them many skills (programming/critical > thinking/math/algorithmics) or which rely entirely on one application > space (animation, games, personal robots, whatever) to be "sexy" and > capture students' attention. > I'm wary of math classes that use boring calculators. When I say lets use Python as a calculator instead of using a calculator, I'm talking about stopping using calculators in math class and using Python instead. Picture the NCTM conference with a Ruby booth, a Scheme booth, a J booth and so on. This is the National Council of Teachers of Mathematics and yet industrial strength computer languages are treated on a par with the calculators. What a concept! Hooray for less bigotry against thinking like computer scientists. 'Concrete Mathematics' broke some ice maybe. > I suppose it's all about goals. ?One potential goal for using Python > in teaching is to reinforce and develop mathematical reasoning skills > and it seems like that's the focus of a lot of the people on this > list. ?I believe that's a worthy goal and I try to accomplish some of > that in my courses as well, but it's not my primary goal. ?I guess my > primary goal is to encourage students to see software as something > they can be a part of rather than simply as something they consume or > are forced to live with. ?I don't have a ton of concrete ideas on how > to do that -- I think I've somehow crafted successful courses on > intuition more than anything else and can't really formally express > what I'm doing yet -- but I really do see it as a very different goal > that leads to very different types of courses. > I appreciate your commitment to keeping interest levels high. You rightly point out how I risk coming across as some kind of killjoy by wanting to take a colorful bright computer and make it seem like a boring old calculator. Of all the fun and interesting things one might do... But I'm not talking about using it *exclusively* in that way. > And maybe I'm the only one who sees the majority of examples and ideas > on this list as esoteric! ?It's something I often find myself thinking > so I thought I'd try to describe and explain a bit of my discomfort. > Not sure I really expressed myself very well -- sorry! > > H?l?ne. > I think "esoteric" and/or "avant-garde" are fair characterizations. I'm glad you've joined us here, as a fully participating individual and professional, Seattle-based -- just 3.5 hours from here by car on I-5, for those of you unfamiliar with this bio-region. I'm wondering if you've gone through Allen Downey's work, and/or Jeff Elkner's: http://www.greenteapress.com/thinkpython/thinkpython.html This book is free to public schools (is free period). If a school is spending big bucks on a textbook about programming, this could be a savings, especially with Python itself being both free and open source. Here's a rave review by Hong Feng of Allen's book in the series about Java. http://www.free-soft.org/FSM/english/issue01/bookreview.html Whereas I'm a huge fan of Python, I wouldn't discourage using some Java or JavaScript in a math class as well. I'm all about leaving it to local faculties to create their own courseware. As long as teachers retain their professional freedom to innovate, I think we'll gradually see more of these math and computer science hybrids that include more geography (Google Earth etc.). Kirby From echerlin at gmail.com Sun Apr 11 21:00:04 2010 From: echerlin at gmail.com (Edward Cherlin) Date: Sun, 11 Apr 2010 15:00:04 -0400 Subject: [Edu-sig] using Python as a calculator In-Reply-To: <4BC07E0F.0@gmx.de> References: <4BC07E0F.0@gmx.de> Message-ID: On Sat, Apr 10, 2010 at 09:33, Christian Mascher wrote: > Edward Cherlin wrote: >> >> [sigh] >> >> Do math tables in a math array language. >> >> degrees =. i. 91 ?NB. 0..90 >> >> radians =. degrees * o. % 180 >> >> table =. |: degrees, 1 2 3 o./ radians > > Sorry, I don't know J (Kirby does), but this is exactly the reason I prefer > Python. Readability counts (for me). That's what they said to Fibonacci when he tried to explain why Arabic numerals were better for math than Roman numerals. But Roman numerals are better in readability and algorithmic complexity if you rarely do anything but add and subtract, as merchants did before interest payments became critical. Roman numerals are precisely equivalent to abacus notation. It is odd that the distinction between math/science programming and business programming is nearly a thousand years old, but there it is. In fact, APL is the only computer language that uses the same symbols, + - ? ?, as first grade arithmetic texts. (Presumably, with the acceptance of Unicode, this will change someday.) Back in the 1960s, Ken Iverson successfully taught teachers how to teach children arithmetic on IBM Selectric terminals connected to a loaned 360 mainframe. An addition table up to 10 is simply numbers =. i. 11 NB. 0..10 numbers +/ numbers or, with a bit more complexity or a bit more simplicity, depending on your viewpoint, +/~ i. 11 where f~ x is x f x . > For creating a table, most people would > probably use a spreadsheet anyway, but as I happen to know Python, I use it > for such tasks from time to time. I can even remember the syntax without > having used Python for months. Don't think that would be the case with J. This turns out not to be the case. The complete syntax table for J consists of 12 lines. You are talking glibly about a topic on which you have no information. > Not very inclined to learn that. Obviously. >> where >> >> =. is assignment >> i. creates a list of consecutive numbers starting at 0. > > Who on earth would think of that without a manual? And without a lesson? Do you believe that Python syntax is intuitive, and can be guessed without a manual or lessons? In i., the i stands for index. It is easy to learn, and reasonably mnemonic. >> NB. is the comment marker o. x is pi times x > > Why not pi? Why? >> % x is reciprocal of x, so o. % 180 is pi/180 > > Don't think that is very useful. These objections are trivial and uninformed. You aren't a mathematician, you don't like math and math notation, so there is nothing more to say, except please stand out of the way of people who can benefit from it and want it. >> |: is transpose > > Another very special symbol. >> >> , appends an array to another. It turns a list into a table in order >> to match dimensions. > > Lost you there... You can append a table to a table if they have a dimension in common. You can't append a table to a list unless the list is turned into a one-row table. >> 1 2 3 o. x gives sine, cosine, tangent of x > > Why don't they use sin(), cos(), tan() like the rest of the mathematical > world? >> >> / creates a table with the given function (o.) applied to two list >> arguments >> >> The result is a 91 row, 4 column table of angles and trig function values. >> > Impressive ;-)) >> >> I can easily give you a short sequence of lessons leading to this >> level, introducing some other arithmetic, transcendental, and >> array-handling functions along the way, and a little more about >> operating on functions to define new functions. > > Python is much nearer to standard Math-notation, that is a good thing. LOL. Math notation is what mathematicians use, not schoolchildren. They are constantly inventing more of it. What you call math notation is known to mathematicians as "arithmetic". There is no standard math notation. Polish: + 1 2 Infix: 1 + 2 Reverse Polish: 1 2 + Reverse Polish is one of the two standard calculator input systems, the one used by engineers, from HP. Polish is standard in LISP and combinatory logic. Neither requires parentheses. Infix notation, as on TI and related calculators, requires parentheses, and is much more difficult for complex expressions. > I > like to learn new languages - up to a point. I don't see the added value of > J in this case. I like to learn languages a lot more than you, then. I don't consider anybody educated in computing without knowing something of languages from the LISP, APL, FORTH, OOP, and scalar language families. > Just my 2c > > Christian > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From lognaturel at gmail.com Sun Apr 11 22:54:16 2010 From: lognaturel at gmail.com (Helene Martin) Date: Sun, 11 Apr 2010 13:54:16 -0700 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: <4BC07E0F.0@gmx.de> Message-ID: Since I've been vocal over the past few days, I'd like to point out that this is a very negative post. Here's what I got out of it: "You don't know math, you don't know this list of programming languages so you're not a True Member of the Computation World and if you knew anything about this, you clearly wouldn't say such foolish things." I know that's not exactly what you said, but read over your post to see how it may be the case that that's how it comes across, starting with the sigh of exasperation in your original post. Christian makes frequent interesting and intelligent posts so why not assume that his opinion is grounded in valid experience? I found his remarks very important because they're trying to mitigate some of the esoteric nature of the conversation. I take particular offense to your closing statement -- "I don't consider anybody educated in computing without knowing something of languages from the LISP, APL, FORTH, OOP, and scalar language families." First of all, you've just called many of us uneducated which I'd argue somewhat lacks in tact. You're also reinforcing the idea that computing is this select club that only people with specific experiences and interests have access to. Do the majority of computer scientists care much about APL/MATLAB/J/etc? I know several who use it all the time and several others, myself included, who really haven't had much of a need for those. I take it we are out of the club? Keep in mind you're excluding lots of folks with PhDs and interesting projects under their belt. As an educator, I find this attitude troubling, though I know that's less relevant to you since you're not currently in the classroom. Think about the effect this kind of attitude can have on folks who are just starting to develop an interest in computing, especially those who have reasons to think they don't belong right off the bat (women, minorities). Something to consider. On Sun, Apr 11, 2010 at 12:00 PM, Edward Cherlin wrote: > On Sat, Apr 10, 2010 at 09:33, Christian Mascher > wrote: >> Edward Cherlin wrote: >>> >>> [sigh] >>> >>> Do math tables in a math array language. >>> >>> degrees =. i. 91 ?NB. 0..90 >>> >>> radians =. degrees * o. % 180 >>> >>> table =. |: degrees, 1 2 3 o./ radians >> >> Sorry, I don't know J (Kirby does), but this is exactly the reason I prefer >> Python. Readability counts (for me). > > That's what they said to Fibonacci when he tried to explain why Arabic > numerals were better for math than Roman numerals. But Roman numerals > are better in readability and algorithmic complexity if you rarely do > anything but add and subtract, as merchants did before interest > payments became critical. Roman numerals are precisely equivalent to > abacus notation. It is odd that the distinction between math/science > programming and business programming is nearly a thousand years old, > but there it is. > > In fact, APL is the only computer language that uses the same symbols, > + - ? ?, as first grade arithmetic texts. (Presumably, with the > acceptance of Unicode, this will change someday.) Back in the 1960s, > Ken Iverson successfully taught teachers how to teach children > arithmetic on IBM Selectric terminals connected to a loaned 360 > mainframe. An addition table up to 10 is simply > > numbers =. i. 11 ?NB. 0..10 > > numbers +/ numbers > > or, with a bit more complexity or a bit more simplicity, depending on > your viewpoint, > > +/~ i. 11 > > where f~ x is x f x . > >> For creating a table, most people would >> probably use a spreadsheet anyway, but as I happen to know Python, I use it >> for such tasks from time to time. I can even remember the syntax without >> having used Python for months. Don't think that would be the case with J. > > This turns out not to be the case. The complete syntax table for J > consists of 12 lines. You are talking glibly about a topic on which > you have no information. > >> Not very inclined to learn that. > > Obviously. > >>> where >>> >>> =. is assignment >>> i. creates a list of consecutive numbers starting at 0. >> >> Who on earth would think of that without a manual? > > And without a lesson? Do you believe that Python syntax is intuitive, > and can be guessed without a manual or lessons? In i., the i stands > for index. It is easy to learn, and reasonably mnemonic. > >>> NB. is the comment marker o. x is pi times x >> >> Why not pi? > > Why? > >>> % x is reciprocal of x, so o. % 180 is pi/180 >> >> Don't think that is very useful. > > These objections are trivial and uninformed. You aren't a > mathematician, you don't like math and math notation, so there is > nothing more to say, except please stand out of the way of people who > can benefit from it and want it. > >>> |: is transpose >> >> Another very special symbol. >>> >>> , appends an array to another. It turns a list into a table in order >>> to match dimensions. >> >> Lost you there... > > You can append a table to a table if they have a dimension in common. > You can't append a table to a list unless the list is turned into a > one-row table. > >>> 1 2 3 o. x gives sine, cosine, tangent of x >> >> Why don't they use sin(), cos(), tan() like the rest of the mathematical >> world? >>> >>> / creates a table with the given function (o.) applied to two list >>> arguments >>> >>> The result is a 91 row, 4 column table of angles and trig function values. >>> >> Impressive ;-)) >>> >>> I can easily give you a short sequence of lessons leading to this >>> level, introducing some other arithmetic, transcendental, and >>> array-handling functions along the way, and a little more about >>> operating on functions to define new functions. >> >> Python is much nearer to standard Math-notation, that is a good thing. > > LOL. Math notation is what mathematicians use, not schoolchildren. > They are constantly inventing more of it. What you call math notation > is known to mathematicians as "arithmetic". > > There is no standard math notation. > > Polish: + 1 2 > Infix: 1 + 2 > Reverse Polish: 1 2 + > > Reverse Polish is one of the two standard calculator input systems, > the one used by engineers, from HP. Polish is standard in LISP and > combinatory logic. Neither requires parentheses. Infix notation, as on > TI and related calculators, requires parentheses, and is much more > difficult for complex expressions. > >> I >> like to learn new languages - up to a point. I don't see the added value of >> J in this case. > > I like to learn languages a lot more than you, then. I don't consider > anybody educated in computing without knowing something of languages > from the LISP, APL, FORTH, OOP, and scalar language families. > >> Just my 2c >> >> Christian >> >> _______________________________________________ >> Edu-sig mailing list >> Edu-sig at python.org >> http://mail.python.org/mailman/listinfo/edu-sig >> > > > > -- > Edward Mokurai (??/???????????????/????????????? ?) Cherlin > Silent Thunder is my name, and Children are my nation. > The Cosmos is my dwelling place, the Truth my destination. > http://www.earthtreasury.org/ > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > From kirby.urner at gmail.com Sun Apr 11 23:51:35 2010 From: kirby.urner at gmail.com (kirby urner) Date: Sun, 11 Apr 2010 14:51:35 -0700 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: <4BC07E0F.0@gmx.de> Message-ID: >> Sorry, I don't know J (Kirby does), but this is exactly the reason I prefer >> Python. Readability counts (for me). > > That's what they said to Fibonacci when he tried to explain why Arabic > numerals were better for math than Roman numerals. But Roman numerals > are better in readability and algorithmic complexity if you rarely do > anything but add and subtract, as merchants did before interest > payments became critical. Roman numerals are precisely equivalent to > abacus notation. It is odd that the distinction between math/science > programming and business programming is nearly a thousand years old, > but there it is. > Fibonacci's Liber Abaci introduced the Indian/Arabic number system, based on the abacus. The place value system corresponds to the rods of the abacus, with the zero corresponding to a rod with no beads (a place holder). Roman numerals, in contrast, have nothing to do with abacus notation and have no place value e.g XIV for 14 or MMMCCC for 3300. http://www.novaroma.org/via_romana/numbers.html Roman numbers suck for arithmetic operations of any kind IMO. > numbers =. i. 11 ?NB. 0..10 > ...similar to Python's range built-in. > These objections are trivial and uninformed. You aren't a > mathematician, you don't like math and math notation, so there is > nothing more to say, except please stand out of the way of people who > can benefit from it and want it. > One could argue any computer language comprises a math notation. Also, one could argue that all creatures are mathematicians in some innate way (Keith Devlin's point). Carving out a special caste of humans and calling them "mathematicians" is a practice within various institutions. I've noticed many of these institutions promote a kind of snobbery, but then such is the human ego. > You can append a table to a table if they have a dimension in common. > You can't append a table to a list unless the list is turned into a > one-row table. > Note that numpy shares some of APL's and J's ability to shape data into multi-dimensional objects with rank. >>> import numpy >>> a = numpy.array(range(10)) >>> a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> a.reshape((2,5)) array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]) >>> a array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> a = a.reshape((2,5)) >>> a array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]) >>> numpy.concatenate((a,a)) array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]) >>> numpy.concatenate((a,a), axis=1) array([[0, 1, 2, 3, 4, 0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 5, 6, 7, 8, 9]]) >>> I can easily give you a short sequence of lessons leading to this >>> level, introducing some other arithmetic, transcendental, and >>> array-handling functions along the way, and a little more about >>> operating on functions to define new functions. >> >> Python is much nearer to standard Math-notation, that is a good thing. > > LOL. Math notation is what mathematicians use, not schoolchildren. Math notations, like music notations, are the common heritage of humankind, not the special property of an elite caste of human. That being said, many math notations, including computer languages, are quite opaque until deciphered. Those already "in the know" may exult in their exclusive knowledge, that's been true since time immemorial. Those cryptic expressions on a T-shirt from the MIT gift shop serve as mnemonics, are reminders of long hours spent unpacking the meanings. To a non-initiate, it all looks like so much unreadable APL. :) Of course non-math notations share in these encrypting / compacting capabilities. You needn't use math notations to create operational systems (institutions) with their respective insiders and outsiders, with insiders often ranked according to their "degree" of inner-ness. We've not really defined "mathematics", "mathematician" or "math notation" for the purposes of this thread, so maybe one could argue that all notations are inherently mathematical in that they're aids to thought processes, which processes by their very nature are computational in some degree. Is Chinese a math notation? Write a 500 word essay on why it is. Write another 500 word essay on why it isn't. > They are constantly inventing more of it. What you call math notation > is known to mathematicians as "arithmetic". > Iverson called APL an executable math notation (MN). MNs were divided into machine-executable and not. Leibniz dreamed of machine-executable logical languages. We have them now, call them "computer languages". > There is no standard math notation. > Nor is there a strongly fixed meaning to the concept of "math notation". Is Python a math notation? One could argue that it is. Or call it a machine-executable logic. > Polish: + 1 2 > Infix: 1 + 2 > Reverse Polish: 1 2 + > > Reverse Polish is one of the two standard calculator input systems, > the one used by engineers, from HP. Polish is standard in LISP and > combinatory logic. Neither requires parentheses. Infix notation, as on > TI and related calculators, requires parentheses, and is much more > difficult for complex expressions. > >> I like to learn new languages - up to a point. I don't see the added value of >> J in this case. > > I like to learn languages a lot more than you, then. I don't consider > anybody educated in computing without knowing something of languages > from the LISP, APL, FORTH, OOP, and scalar language families. > "Like" may not be the operative word in all cases. Some people just don't have the privilege to study that much. I wish that they did. Socrates worked with that slave boy to show how intelligence was innate, but he didn't manage to abolish slavery. This is clearly a Python list, so I'm never going to apologize for showing a Pythonic solution or implementation that could just as well be done in another language in far fewer steps. I'm happy to have APL and J mentioned for comparing and contrasting (I mention them myself), but if one judges one needs to stick with Python for a given task (because it's what they know, and because the task is looming), then it's hardly my place to judge them mentally and/or morally deficient in some way. >> Just my 2c >> >> Christian >> Thanks for your remarks Christian. Don't let this Ed character bully or intimidate you. He likes to show off, which is fine, but he lacks diplomatic skills IMO. But then some say the same about me. Kirby >> _______________________________________________ >> Edu-sig mailing list >> Edu-sig at python.org >> http://mail.python.org/mailman/listinfo/edu-sig >> > > > > -- > Edward Mokurai (??/???????????????/????????????? ?) Cherlin > Silent Thunder is my name, and Children are my nation. > The Cosmos is my dwelling place, the Truth my destination. > http://www.earthtreasury.org/ > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > From missive at hotmail.com Mon Apr 12 00:01:01 2010 From: missive at hotmail.com (Lee Harr) Date: Mon, 12 Apr 2010 02:31:01 +0430 Subject: [Edu-sig] [ANNC] pynguin-0.7 (python turtle graphics application) Message-ID: Pynguin is a python-based turtle graphics application. ??? It combines an editor, interactive interpreter, and ??? graphics display area. It is meant to be an easy environment for introducing ??? some programming concepts to beginning programmers. http://pynguin.googlecode.com/ This release changes the method of starting and stopping ??? the separate code-running threads. It should be much ??? less susceptible to lock-ups and crashes, though I ??? am still experiencing occasional problems. Pynguin is tested with Python 2.6.4 and uses PyQt (4.6) ??? for its GUI elements. Pynguin is released under GPLv3. Changes in pynguin-0.7: ??? - fixed deadlock when running with many pynguins at instant speed ??? - new threading model greatly reduces problems with lock-ups ??? - added more multi-pynguin examples ??? - added commands turnto('random') and lineto('random') ??? - added more random color possibilities ('rlight', 'rmedium', 'rdark') ??? - allow named colors and html-style colors ??? - added command clear() ??? - added equation plotting examples - cartesian and polar ??? - re-center on (0, 0) when moving view splitter ??? - added svg/pdf worksheets Changes in pynguin-0.6: ??? - fixed crash when using new_pynguin() ??? - fixed possible crash during startup (due to race condition) ??? - added goto('random') and xy() to easily get coordinates ??? - added keyword args for fill -- fill(color=..., rule=...) ??? - added easier access for fillcolor 'random' ??? - added examples using multiple pynguins ??? - remove any added pynguins when using reset() ??? - set window title when using Save As... ??? - better error messages when loading file with errors ??? - whitespace cleanup when saving files ??? - render About image and title at runtime ??? - more examples Changes in pynguin-0.5: ??? - catch errors when processing graphic move queue ??? - capture and hold stdout and stderr ??? - call str() on argument to write ??? - guard against sending non-int to color _________________________________________________________________ Hotmail: Trusted email with Microsoft?s powerful SPAM protection. https://signup.live.com/signup.aspx?id=60969 From macquigg at ece.arizona.edu Mon Apr 12 01:50:34 2010 From: macquigg at ece.arizona.edu (David MacQuigg) Date: Sun, 11 Apr 2010 16:50:34 -0700 Subject: [Edu-sig] Why Python? In-Reply-To: References: <4BC07E0F.0@gmx.de> Message-ID: <4BC2604A.6000706@ece.arizona.edu> Edward Cherlin wrote: > On Sat, Apr 10, 2010 at 09:33, Christian Mascher > wrote: > >> Edward Cherlin wrote: >> >>> [sigh] >>> >>> Do math tables in a math array language. >>> >>> degrees =. i. 91 NB. 0..90 >>> >>> radians =. degrees * o. % 180 >>> >>> table =. |: degrees, 1 2 3 o./ radians >>> >> Python is much nearer to standard Math-notation, that is a good thing. >> > > LOL. Math notation is what mathematicians use, not schoolchildren. > They are constantly inventing more of it. What you call math notation > is known to mathematicians as "arithmetic". > > There is no standard math notation. > I think what Christian means to say is that Python is much nearer to a notation (pseudocode) that might be used by scientists and engineers who are trying to express an idea involving computation, without relying on a specific language. Of course, there is no "standard" pseudocode, but if you look at textbooks that are most successful at expressing algorithms this way (my examples would be from engineering - Hachtel & Somenzi on Logic Synthesis, Stinson on Cryptography) what you see is a notation very close to Python. Pseudocode has to be self-explanatory. There is no introductory chapter on how to read it. Likewise, an introductory computer language should be close to self-explanatory. It will be difficult to get math and science teachers to accept it, if they have to make extra efforts explaining the notation. Getting math and science teachers to accept computation as a vital part of their curricula is my current focus, so I wouldn't try to push something like your example above. Python is just a means to an end, the closest thing we have to pseudocode. When someone who favors another language (typically Java) asks me why Python, I find the comparison to pseudocode to be the best answer. Specific examples, like the absence of type declarations, tends to invite unthinking reactions. (Students will make too many errors.) Even something as simple as requiring correct indentation is not obvious to someone who hasn't used Python. (Although that one does have some appeal to teachers who have had to read sloppy student code.) Ultimately, it is word-of-mouth, one teacher telling another, that I think will decide which language gets used. -- Dave ************************************************************ * * David MacQuigg, PhD email: macquigg at ece.arizona.edu * * * Research Associate phone: USA 520-721-4583 * * * * ECE Department, University of Arizona * * * * 9320 East Mikelyn Lane * * * * http://purl.net/macquigg Tucson, Arizona 85710 * ************************************************************ * From aharrin at luc.edu Mon Apr 12 03:03:03 2010 From: aharrin at luc.edu (Andrew Harrington) Date: Sun, 11 Apr 2010 20:03:03 -0500 Subject: [Edu-sig] Why Python? In-Reply-To: <4BC2604A.6000706@ece.arizona.edu> References: <4BC07E0F.0@gmx.de> <4BC2604A.6000706@ece.arizona.edu> Message-ID: Well put David. My choices are always about me and a particular situation. I would not teach J to beginners or to people not crunching a lot of mathematical stuff regularly, but for the professional statisticians and electronic traders I know, J is a fabulous language, and very worth the modest learning curve. J is an interesting case. Iverson did not totally open up the source. JSoftware still sells that to big users who want extra insurance for the future of their codebase, but the very powerful language is freely available. The statisticians in my university are talking about dumping traditional massively expensive statistical environments, not for a switch to some Python tool, but to J and its freely available libraries. I fear I sometimes push Python in ways that can easily be interpreted as meaning for essentially all people and all situations. I know that inside my head I am not thinking about so general a situation, but I think I could often communicate it better. Andy On Sun, Apr 11, 2010 at 6:50 PM, David MacQuigg wrote: > Edward Cherlin wrote: > >> On Sat, Apr 10, 2010 at 09:33, Christian Mascher >> wrote: >> >> >>> Edward Cherlin wrote: >>> >>> >>>> [sigh] >>>> >>>> Do math tables in a math array language. >>>> >>>> degrees =. i. 91 NB. 0..90 >>>> >>>> radians =. degrees * o. % 180 >>>> >>>> table =. |: degrees, 1 2 3 o./ radians >>>> >>>> >>> > > > Python is much nearer to standard Math-notation, that is a good thing. >>> >>> >> >> LOL. Math notation is what mathematicians use, not schoolchildren. >> They are constantly inventing more of it. What you call math notation >> is known to mathematicians as "arithmetic". >> >> There is no standard math notation. >> >> > > I think what Christian means to say is that Python is much nearer to a > notation (pseudocode) that might be used by scientists and engineers who are > trying to express an idea involving computation, without relying on a > specific language. Of course, there is no "standard" pseudocode, but if you > look at textbooks that are most successful at expressing algorithms this way > (my examples would be from engineering - Hachtel & Somenzi on Logic > Synthesis, Stinson on Cryptography) what you see is a notation very close to > Python. > > Pseudocode has to be self-explanatory. There is no introductory chapter on > how to read it. Likewise, an introductory computer language should be close > to self-explanatory. It will be difficult to get math and science teachers > to accept it, if they have to make extra efforts explaining the notation. > Getting math and science teachers to accept computation as a vital part of > their curricula is my current focus, so I wouldn't try to push something > like your example above. > > Python is just a means to an end, the closest thing we have to pseudocode. > When someone who favors another language (typically Java) asks me why > Python, I find the comparison to pseudocode to be the best answer. Specific > examples, like the absence of type declarations, tends to invite unthinking > reactions. (Students will make too many errors.) Even something as simple > as requiring correct indentation is not obvious to someone who hasn't used > Python. (Although that one does have some appeal to teachers who have had > to read sloppy student code.) Ultimately, it is word-of-mouth, one teacher > telling another, that I think will decide which language gets used. > > -- Dave > > ************************************************************ * > * David MacQuigg, PhD email: macquigg at ece.arizona.edu * * > * Research Associate phone: USA 520-721-4583 * * * > * ECE Department, University of Arizona * * * > * 9320 East Mikelyn Lane * * * > * http://purl.net/macquigg Tucson, Arizona 85710 * > ************************************************************ * > > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -- Andrew N. Harrington Director of Academic Programs Computer Science Department Loyola University Chicago 512B Lewis Towers (office) Snail mail to Lewis Towers 416 820 North Michigan Avenue Chicago, Illinois 60611 http://www.cs.luc.edu/~anh Phone: 312-915-7982 Fax: 312-915-7998 gpd at cs.luc.edu for graduate administration upd at cs.luc.edu for undergrad administration aharrin at luc.edu as professor -------------- next part -------------- An HTML attachment was scrubbed... URL: From chris at seberino.org Mon Apr 12 03:44:54 2010 From: chris at seberino.org (chris at seberino.org) Date: Sun, 11 Apr 2010 20:44:54 -0500 Subject: [Edu-sig] Why Python? In-Reply-To: <4BC2604A.6000706@ece.arizona.edu> References: <4BC07E0F.0@gmx.de> <4BC2604A.6000706@ece.arizona.edu> Message-ID: <20100412014454.GC25228@seberino.org> On Sun, Apr 11, 2010 at 04:50:34PM -0700, David MacQuigg wrote: > Python is just a means to an end, the closest thing we have to > pseudocode. I agree with you. I've heard people say that Scheme is the most like algebra. I don't know exactly what that means or if that means Scheme is the simplest introductory language. My hunch is that Python is better. cs From calcpage at aol.com Mon Apr 12 03:51:48 2010 From: calcpage at aol.com (calcpage at aol.com) Date: Sun, 11 Apr 2010 21:51:48 -0400 Subject: [Edu-sig] Why Python? In-Reply-To: <20100412014454.GC25228@seberino.org> References: <20100412014454.GC25228@seberino.org> Message-ID: <8CCA7F9D93B0331-15DC-16912@webmail-m099.sysops.aol.com> As a Computer Science teacher, I am used to teaching my students a number of introductory languages before they get to AP CS. I am never satisfied with just one approach. I am going to dump all that in favor of python next year. So, if Computer Science teachers end up using python, I will be in the odd position of teaching only python for 2 years of High School. You know, that wouldn't be all bad, my students would then have a lot more experience with python before the AP exam. As a Math teacher, this scenario is also appealing as I would have more time fo math topics too (Discrete Math or Pythonic Math)! HTH, A. Jorge Garcia http://calcpage.tripod.com Teacher & Professor Applied Mathematics, Physics?& Computer Science Baldwin Senior High School & Nassau Community College From kirby.urner at gmail.com Mon Apr 12 03:52:59 2010 From: kirby.urner at gmail.com (kirby urner) Date: Sun, 11 Apr 2010 18:52:59 -0700 Subject: [Edu-sig] [ANNC] pynguin-0.7 (python turtle graphics application) In-Reply-To: References: Message-ID: 2010/4/11 Lee Harr : > > Pynguin is a python-based turtle graphics application. > ??? It combines an editor, interactive interpreter, and > ??? graphics display area. > I like the idea of using turtles to plot graphs. Replacing graphing calculators with Python is easier when there are simple plot functions available (yes, I know about matplotlib, Sage...) Curious how much of the Standard Library turtle model gets used here. Is the turtle stuff all rewritten from scratch. Kirby From chris at seberino.org Mon Apr 12 04:15:13 2010 From: chris at seberino.org (chris at seberino.org) Date: Sun, 11 Apr 2010 21:15:13 -0500 Subject: [Edu-sig] Why Python? Message-ID: <20100412021513.GB25391@seberino.org> On Sun, Apr 11, 2010 at 09:51:48PM -0400, calcpage at aol.com wrote: > As a Computer Science teacher, I am used to teaching my students a > number of introductory languages before they get to AP CS. I am never > satisfied with just one approach. I am going to dump all that in favor > of python next year. So, if Computer Science teachers end up using > python, I will be in the odd position of teaching only python for 2 > years of High School. You know, that wouldn't be all bad, my students > would then have a lot more experience with python before the AP exam. > As a Math teacher, this scenario is also appealing as I would have more > time fo math topics too (Discrete Math or Pythonic Math)! Jorge I've enjoyed your comments on AP Calc list and now here. Ever heard of Teach Scheme/Reach Java (http://http://www.teach-scheme.org)? I like the idea of starting the AP CS year with a clean language and then "reaching" or finishing with Java. I wonder if AP CS with Python and Java would be ideal. Ideally we would have the same kids for a few years so that we could really sail in math classes with kids that know Python fairly well. cs From echerlin at gmail.com Mon Apr 12 04:17:18 2010 From: echerlin at gmail.com (Edward Cherlin) Date: Sun, 11 Apr 2010 22:17:18 -0400 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: <4BC07E0F.0@gmx.de> Message-ID: On Sun, Apr 11, 2010 at 17:51, kirby urner wrote: >>> Sorry, I don't know J (Kirby does), but this is exactly the reason I prefer >>> Python. Readability counts (for me). >> >> That's what they said to Fibonacci when he tried to explain why Arabic >> numerals were better for math than Roman numerals. But Roman numerals >> are better in readability and algorithmic complexity if you rarely do >> anything but add and subtract, as merchants did before interest >> payments became critical. The chapter on interest calculations in Liber Abaci was particularly important. >> Roman numerals are precisely equivalent to >> abacus notation. It is odd that the distinction between math/science >> programming and business programming is nearly a thousand years old, >> but there it is. >> > Fibonacci's Liber Abaci introduced the Indian/Arabic number system, > based on the abacus. No, in spite of the title, not based on the abacus, any more than calculus is based on pebbles. http://faculty.evansville.edu/ck6/bstud/fibo.html Though the title of the book suggests the use of the abacus, in fact Fibonacci freed arithmetic from calculations using the abacus. > The place value system corresponds to the > rods of the abacus, with the zero corresponding to a rod with no beads > (a place holder). > > Roman numerals, in contrast, have nothing to do with abacus notation > and have no place value e.g XIV for 14 or MMMCCC for 3300. The Japanese, Chinese, and Roman abacI use beads or pebbles (calculi) with values of 1 and 5. http://en.wikipedia.org/wiki/Abacus http://en.wikipedia.org/wiki/Roman_abacus The Roman notation uses letters with values of 1 and 5 times a power of 10, so that one can write down the Roman numeral for an abacus setting simply by writing the letter corresponding to each calculus on the board, or put a number on the board by placing a pebble for each letter. Adding and subtracting Roman numerals is isomorphic with manipulating an abacus. 7 --> 5+2 --> VII 3 --> 0+3 --> III VII + III --> VIIIII --> VV --> X 5+2 + 0+3 --> 5+5 --> 0+1,0+0 and similarly for LXX + XXX etc. > http://www.novaroma.org/via_romana/numbers.html > > Roman numbers suck for arithmetic operations of any kind IMO. > >> numbers =. i. 11 ?NB. 0..10 > > ...similar to Python's range built-in. > >> These objections are trivial and uninformed. You aren't a >> mathematician, you don't like math and math notation, so there is >> nothing more to say, except please stand out of the way of people who >> can benefit from it and want it. > > One could argue any computer language comprises a math notation. In the mathematical theory of languages, we can regard any Turing-complete symbol-and-rule set as a way to express all of mathematics, but that is outside the question of what language to teach or publish in, when the aim is communication with humans. > Also, one could argue that all creatures are mathematicians in some > innate way (Keith Devlin's point). So they are, beyond argument. So why are we telling them how they want to do math and computing? The mindset of "When I want to hear your opinion, I'll tell it to you" is what I hate most about education systems of the past and present. > Carving out a special caste of humans and calling them "mathematicians" > is a practice within various institutions. Mathematicians are not a caste, but a guild with stiff entry requirements. I am not a full member, since I quit after my BA and went to teach in the Peace Corps. > I've noticed many of these institutions promote a kind of snobbery, > but then such is the human ego. See The Theory of the Leisure Class, by Thorstein Veblen, and Buddhist teachings on no-self. Reverse snobbery is also a feature of human ego. >> You can append a table to a table if they have a dimension in common. >> You can't append a table to a list unless the list is turned into a >> one-row table. >> > > Note that numpy shares some of APL's and J's ability to shape data > into multi-dimensional objects with rank. Yes. It would be more productive to discuss numpy here rather than fight a meaningless rwar. >>>> import numpy >>>> a = numpy.array(range(10)) >>>> a > array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>>> a.reshape((2,5)) > array([[0, 1, 2, 3, 4], > ? ? ? [5, 6, 7, 8, 9]]) >>>> a > array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>>> a = a.reshape((2,5)) >>>> a > array([[0, 1, 2, 3, 4], > ? ? ? [5, 6, 7, 8, 9]]) >>>> numpy.concatenate((a,a)) > array([[0, 1, 2, 3, 4], > ? ? ? [5, 6, 7, 8, 9], > ? ? ? [0, 1, 2, 3, 4], > ? ? ? [5, 6, 7, 8, 9]]) >>>> numpy.concatenate((a,a), axis=1) > array([[0, 1, 2, 3, 4, 0, 1, 2, 3, 4], > ? ? ? [5, 6, 7, 8, 9, 5, 6, 7, 8, 9]]) > >>>> I can easily give you a short sequence of lessons leading to this >>>> level, introducing some other arithmetic, transcendental, and >>>> array-handling functions along the way, and a little more about >>>> operating on functions to define new functions. >>> >>> Python is much nearer to standard Math-notation, that is a good thing. >> >> LOL. Math notation is what mathematicians use, not schoolchildren. > > Math notations, like music notations, are the common heritage of > humankind, not the special property of an elite caste of human. > > That being said, many math notations, including computer languages, > are quite opaque until deciphered. > > Those already "in the know" may exult in their exclusive knowledge, > that's been true since time immemorial. > > Those cryptic expressions on a T-shirt from the MIT gift shop serve > as mnemonics, are reminders of long hours spent unpacking the > meanings. > > To a non-initiate, it all looks like so much unreadable APL. :) > > Of course non-math notations share in these encrypting / compacting > capabilities. ?You needn't use math notations to create operational > systems (institutions) with their respective insiders and outsiders, > with insiders often ranked according to their "degree" of inner-ness. > > We've not really defined "mathematics", "mathematician" or > "math notation" for the purposes of this thread, so maybe one > could argue that all notations are inherently mathematical in > that they're aids to thought processes, which processes by their > very nature are computational in some degree. > > Is Chinese a math notation? ?Write a 500 word essay on why it > is. ?Write another 500 word essay on why it isn't. > >> They are constantly inventing more of it. What you call math notation >> is known to mathematicians as "arithmetic". >> > > Iverson called APL an executable math notation (MN). ?MNs were > divided into machine-executable and not. > > Leibniz dreamed of machine-executable logical languages. ?We have > them now, call them "computer languages". > >> There is no standard math notation. >> > > Nor is there a strongly fixed meaning to the concept of "math > notation". ?Is Python a math notation? ?One could argue that it > is. ?Or call it a machine-executable logic. > >> Polish: + 1 2 >> Infix: 1 + 2 >> Reverse Polish: 1 2 + >> >> Reverse Polish is one of the two standard calculator input systems, >> the one used by engineers, from HP. Polish is standard in LISP and >> combinatory logic. Neither requires parentheses. Infix notation, as on >> TI and related calculators, requires parentheses, and is much more >> difficult for complex expressions. >> >>> I like to learn new languages - up to a point. I don't see the added value of >>> J in this case. >> >> I like to learn languages a lot more than you, then. I don't consider >> anybody educated in computing without knowing something of languages >> from the LISP, APL, FORTH, OOP, and scalar language families. >> > > "Like" may not be the operative word in all cases. ?Some people just > don't have the privilege to study that much. ?I wish that they did. > > Socrates worked with that slave boy to show how intelligence was > innate, but he didn't manage to abolish slavery. > > This is clearly a Python list, so I'm never going to apologize for showing > a Pythonic solution or implementation that could just as well be done > in another language in far fewer steps. > > I'm happy to have APL and J mentioned for comparing and contrasting > (I mention them myself), but if one judges one needs to stick with > Python for a given task (because it's what they know, and because > the task is looming), then it's hardly my place to judge them mentally > and/or morally deficient in some way. > >>> Just my 2c >>> >>> Christian >>> > > Thanks for your remarks Christian. ?Don't let this Ed character bully > or intimidate you. ?He likes to show off, which is fine, but he lacks > diplomatic skills IMO. ?But then some say the same about me. I don't like to show off. I like to get facts straight. The lack of diplomatic skills is a symptom of my strong ADHD. > Kirby > >>> _______________________________________________ >>> Edu-sig mailing list >>> Edu-sig at python.org >>> http://mail.python.org/mailman/listinfo/edu-sig -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From echerlin at gmail.com Mon Apr 12 04:51:14 2010 From: echerlin at gmail.com (Edward Cherlin) Date: Sun, 11 Apr 2010 22:51:14 -0400 Subject: [Edu-sig] Why Python? In-Reply-To: References: <4BC07E0F.0@gmx.de> <4BC2604A.6000706@ece.arizona.edu> Message-ID: On Sun, Apr 11, 2010 at 21:03, Andrew Harrington wrote: > Well put David. > > My choices are always about me and a particular situation.? I would not > teach J to beginners I would use the +-*% (+-??) subset of J in first grade for arithmetic, alongside Turtle Art (with stack tiles), and Etoys, including Scratch. By third grade, we could introduce programming in J/APL, Logo/LISP, FORTH, Python, and Smalltalk. At some point, we could show how each represents the same internal parse tree in quite different textual forms. What the LISPers call "syntactic sugar". This is a fundamental Computer Science concept. > or to people not crunching a lot of mathematical stuff > regularly, but for the professional statisticians and electronic traders I > know, J is a fabulous language, and very worth the modest learning curve. J would enable children to crunch data sets easily, allowing a radical deepening of every subject. The learning curve would be very modest when integrated with arithmetic and elementary science, and applied to languages, history, geography, health, and gym. > J is an interesting case.? Iverson did not totally open up the source. There is a published version of the source for an earlier version of J, without the IDE, graphics, and so on. I have a copy. There has been some talk of creating a Free Software version, but no activity that I know of. However, Iverson's son Eric is considering GPLing some version of J in support of One Laptop Per Child and Sugar Labs. I need to bother him about it again, because I am about to apply for two XO 1.5 units to use in preparing an introductory text on electricity. It will use the built-in digital oscilloscope function (Measure) on the XO, among other things, and will explain how to build and take data from measuring instruments. I would be interested in working with Pythonistas on a version using numpy and scipy. > JSoftware still sells that to big users who want extra insurance for the > future of their codebase, but the very powerful language is freely > available.? The statisticians in my university are talking about dumping > traditional massively expensive statistical environments, not for a switch > to some Python tool, but to J and its freely available libraries. > > I fear I sometimes push Python in ways that can easily be interpreted as > meaning for essentially all people and all situations.? I know that inside > my head I am not thinking about so general a situation, but I think I could > often communicate it better. > > Andy > > On Sun, Apr 11, 2010 at 6:50 PM, David MacQuigg > wrote: >> >> Edward Cherlin wrote: >>> >>> On Sat, Apr 10, 2010 at 09:33, Christian Mascher >>> wrote: >>> >>>> >>>> Edward Cherlin wrote: >>>> >>>>> >>>>> [sigh] >>>>> >>>>> Do math tables in a math array language. >>>>> >>>>> degrees =. i. 91 ?NB. 0..90 >>>>> >>>>> radians =. degrees * o. % 180 >>>>> >>>>> table =. |: degrees, 1 2 3 o./ radians >>>>> >> >> >> >>>> Python is much nearer to standard Math-notation, that is a good thing. >>>> >>> >>> LOL. Math notation is what mathematicians use, not schoolchildren. >>> They are constantly inventing more of it. What you call math notation >>> is known to mathematicians as "arithmetic". >>> >>> There is no standard math notation. >>> >> >> I think what Christian means to say is that Python is much nearer to a >> notation (pseudocode) that might be used by scientists and engineers who are >> trying to express an idea involving computation, without relying on a >> specific language. ?Of course, there is no "standard" pseudocode, but if you >> look at textbooks that are most successful at expressing algorithms this way >> (my examples would be from engineering - Hachtel & Somenzi on Logic >> Synthesis, Stinson on Cryptography) what you see is a notation very close to >> Python. >> >> Pseudocode has to be self-explanatory. ?There is no introductory chapter >> on how to read it. We consider pseudocode "self-explanatory" to those who already know the syntax of a similar language. But it is not so, any more than mousing and icons is "intuitive" for those who have never seen them. I consider my J example _with explanatory comments_ to be simpler than the Python I was starting from, where it must be assumed that students have had a prior introduction to the syntax. >> Likewise, an introductory computer language should be >> close to self-explanatory. ?It will be difficult to get math and science >> teachers to accept it, if they have to make extra efforts explaining the >> notation. ?Getting math and science teachers to accept computation as a >> vital part of their curricula is my current focus, so I wouldn't try to push >> something like your example above. There are a number of math, science, and Computer Science textbooks in which APL or J is the math notation throughout, being taught only as needed without interrupting the main sequence of ideas. I can give you citations. There is very little done in this manner in any other programming language. (If you have seen some, please send me the information.) I much prefer this approach to the usual one of teaching programming language syntax and semantics in a vacuum, with no systematic application to anything. >> Python is just a means to an end, the closest thing we have to pseudocode. APLers tend to find pseudocode irritating, because the APL is shorter and clearer to those who can read it. >> ?When someone who favors another language (typically Java) asks me why >> Python, I find the comparison to pseudocode to be the best answer. ?Specific >> examples, like the absence of type declarations, tends to invite unthinking >> reactions. ?(Students will make too many errors.) ?Even something as simple >> as requiring correct indentation is not obvious to someone who hasn't used >> Python. ?(Although that one does have some appeal to teachers who have had >> to read sloppy student code.) ?Ultimately, it is word-of-mouth, one teacher >> telling another, that I think will decide which language gets used. >> >> -- Dave >> >> ************************************************************ ? ? * >> * David MacQuigg, PhD ? ?email: macquigg at ece.arizona.edu ? * ?* >> * Research Associate ? ? ? ? ? ? ? ?phone: USA 520-721-4583 ? * ?* ?* >> * ECE Department, University of Arizona ? ? ? ? ? ? ? ? ? ? ? * ?* ?* >> * ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 9320 East Mikelyn Lane ? ? ? * * * >> * http://purl.net/macquigg ? ? ? ?Tucson, Arizona 85710 ? ? ? ? ?* >> ************************************************************ ? ? * >> >> >> _______________________________________________ >> Edu-sig mailing list >> Edu-sig at python.org >> http://mail.python.org/mailman/listinfo/edu-sig > > > > -- > Andrew N. Harrington > ?Director of Academic Programs > ?Computer Science Department > ?Loyola University Chicago > ?512B Lewis Towers (office) > ?Snail mail to Lewis Towers 416 > ?820 North Michigan Avenue > ?Chicago, Illinois 60611 > > http://www.cs.luc.edu/~anh > Phone: 312-915-7982 > Fax: ? ?312-915-7998 > gpd at cs.luc.edu for graduate administration > upd at cs.luc.edu for undergrad administration > aharrin at luc.edu as professor > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > > -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From echerlin at gmail.com Mon Apr 12 04:58:21 2010 From: echerlin at gmail.com (Edward Cherlin) Date: Sun, 11 Apr 2010 22:58:21 -0400 Subject: [Edu-sig] [ANNC] pynguin-0.7 (python turtle graphics application) In-Reply-To: References: Message-ID: 2010/4/11 Lee Harr : > > Pynguin is a python-based turtle graphics application. > ??? It combines an editor, interactive interpreter, and > ??? graphics display area. > > It is meant to be an easy environment for introducing > ??? some programming concepts to beginning programmers. > > > http://pynguin.googlecode.com/ Lee, are you familiar with the Turtle Art activity in Sugar for the OLPC XO, also written in Python? It provides blocks for integrating Python code. You might want to talk to Walter Bender of Sugar Labs about his plans for expanding TA, some of which match yours. I have been thinking about how to integrate all of this into a curriculum where we would apply turtle graphics to many subjects starting in first grade or perhaps earlier, and later teach programming and Computer Science within this environment rather than purely as text. > This release changes the method of starting and stopping > ??? the separate code-running threads. It should be much > ??? less susceptible to lock-ups and crashes, though I > ??? am still experiencing occasional problems. > > > Pynguin is tested with Python 2.6.4 and uses PyQt (4.6) > ??? for its GUI elements. Pynguin is released under GPLv3. > > > Changes in pynguin-0.7: > ??? - fixed deadlock when running with many pynguins at instant speed > ??? - new threading model greatly reduces problems with lock-ups > ??? - added more multi-pynguin examples > ??? - added commands turnto('random') and lineto('random') > ??? - added more random color possibilities ('rlight', 'rmedium', 'rdark') > ??? - allow named colors and html-style colors > ??? - added command clear() > ??? - added equation plotting examples - cartesian and polar > ??? - re-center on (0, 0) when moving view splitter > ??? - added svg/pdf worksheets > > > Changes in pynguin-0.6: > ??? - fixed crash when using new_pynguin() > ??? - fixed possible crash during startup (due to race condition) > ??? - added goto('random') and xy() to easily get coordinates > ??? - added keyword args for fill -- fill(color=..., rule=...) > ??? - added easier access for fillcolor 'random' > ??? - added examples using multiple pynguins > ??? - remove any added pynguins when using reset() > ??? - set window title when using Save As... > ??? - better error messages when loading file with errors > ??? - whitespace cleanup when saving files > ??? - render About image and title at runtime > ??? - more examples > > > Changes in pynguin-0.5: > ??? - catch errors when processing graphic move queue > ??? - capture and hold stdout and stderr > ??? - call str() on argument to write > ??? - guard against sending non-int to color > > > _________________________________________________________________ > Hotmail: Trusted email with Microsoft?s powerful SPAM protection. > https://signup.live.com/signup.aspx?id=60969 > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From echerlin at gmail.com Mon Apr 12 05:00:51 2010 From: echerlin at gmail.com (Edward Cherlin) Date: Sun, 11 Apr 2010 23:00:51 -0400 Subject: [Edu-sig] [ANNC] pynguin-0.7 (python turtle graphics application) In-Reply-To: References: Message-ID: On Sun, Apr 11, 2010 at 21:52, kirby urner wrote: > 2010/4/11 Lee Harr : >> >> Pynguin is a python-based turtle graphics application. >> ??? It combines an editor, interactive interpreter, and >> ??? graphics display area. >> > > I like the idea of using turtles to plot graphs. Illustrated at http://wiki.sugarlabs.org/go/Activities/Turtle_Art#maths . I have done more examples. > Replacing graphing > calculators with Python is easier when there are simple plot functions > available (yes, I know about matplotlib, Sage...) > > Curious how much of the Standard Library turtle model gets used here. > Is the turtle stuff all rewritten from scratch. > > Kirby > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From kirby.urner at gmail.com Mon Apr 12 06:16:55 2010 From: kirby.urner at gmail.com (kirby urner) Date: Sun, 11 Apr 2010 21:16:55 -0700 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: <4BC07E0F.0@gmx.de> Message-ID: > > The chapter on interest calculations in Liber Abaci was particularly important. > I'm sure you're right. Euler added to the interest calculations literature as well. Nasty stuff, interest, really gets out of hand. But then nature is full of exponentially curved responses. I don't wonder that humans have a heckuva time figuring any of it out. Simulations have been helpful. Lets do more of those. Threading on math-teach about that (instead of "programming games" we're "programming simulations" -- then it's less trivial all of a sudden). > No, in spite of the title, not based on the abacus, any more than > calculus is based on pebbles. > Understood: Fibonacci was showing algorithms that'd obviate the need for a contraption (device). I was simply pointing out that the Indian-Arabic numbers map to the abacus, with 0 holding a "no beads" position i.e. the symbolic sand-scribbles make up for not having a real device handy. You're saying Roman numerals mapped to the abacus too, which somewhat surprises me, as I don't see what they're using for a zero (no beads). It all seems really cumber- some, but I guess that's because I'm not Roman (I only lived in Rome for six years and by then most had converted to the new system -- I spent my first year learning about non-decimal money but that's cuz this was Junior English and I had to wear a tie). > In the mathematical theory of languages, we can regard any > Turing-complete symbol-and-rule set as a way to express all of > mathematics, but that is outside the question of what language to > teach or publish in, when the aim is communication with humans. > One could argue that I suppose. I hail from the Wittgenstein camp. We don't necessarily boast of any "mathematical theory of languages". I consider the basis of mathematics more anthropological than logical, if ya know what I mean. When I teach Martian Math, it's all about Axiom Castles along the beach, picturing Oregon Coast. These sandcastles build on axiomatic foundations, but what underpins them all (sand) is not axiomatic and does not forbid multiple sandcastles. Is chess a mathematical language game? Must there be a 'right answer'? Must all mathematical structures be Axiom Castles? Good questions. Martian Math dispenses with a lot of 20th century "dimension talk" i.e. it uses the "dimension" concept differently. So what though? There are already multiple meanings after the shake-out, with Coxeter's not the same as Einstein's, per page 119 of 'Regular Polytopes' ( "tesseract not equal time machine" might be a fun way to memorize this fact). I bring in Karl Menger's "geometry of lumps" and link it to a minimum topology (the simplex) of unit volume, thereby getting a rationalized volumes table for the Platonics and their dual-combos. Fun game, works in Chinese as well, other languages. Lots of published literature, including in illuminated text. http://coffeeshopsnet.blogspot.com/2009/03/res-extensa.html Does this Martian Math threaten the other sandcastles? Not in Oregon it doesn't. We have that live and let live attitude. Euclideans go in peace among us, often unaware of our presence. >> Also, one could argue that all creatures are mathematicians in some >> innate way (Keith Devlin's point). > > So they are, beyond argument. So why are we telling them how they want > to do math and computing? The mindset of "When I want to hear your > opinion, I'll tell it to you" is what I hate most about education > systems of the past and present. > Who is "we" here? Are you included? >> Carving out a special caste of humans and calling them "mathematicians" >> is a practice within various institutions. > > Mathematicians are not a caste, but a guild with stiff entry > requirements. I am not a full member, since I quit after my BA and > went to teach in the Peace Corps. > You might see it that way. Or maybe you found in the Peace Corps that all kinds of brilliant people never have the privilege to participate in any university system, given how the curriculum sucks so bad and everyone is way too over-specialized. If our curriculum were any good at all, the Global University would be far less FUBAR. Let's keep reminding ourselves and our teachers that we're not OK with this status quo. The mathematics must be seriously flawed, given how we're so messed up (is, I think, a responsible attitude, vs. trying to always render all practicing professionals above reproach, off the hook -- we have serious reforms to implement). One of the coolest mathematicians I work with is an HVAC engineer. >> I've noticed many of these institutions promote a kind of snobbery, >> but then such is the human ego. > > See The Theory of the Leisure Class, by Thorstein Veblen, and Buddhist > teachings on no-self. Reverse snobbery is also a feature of human ego. > I miss Bhutan. Really cool people, great scenery (scary-big mountains). >> Note that numpy shares some of APL's and J's ability to shape data >> into multi-dimensional objects with rank. > > Yes. It would be more productive to discuss numpy here rather than > fight a meaningless rwar. > I tend to agree with Wolfram that "intelligence", whatever it may be, should probably not be mapped to the human animal in any way exclusive to such. I call myself a Quaker animist and am a member of a science club that admits non-humans as honored members (some non-humans have military rank too I've noticed -- recalling a CBS News story). I agree with Wittgenstein when he says thinking "language" is distinct from the rest of what goes on is more superstition than a basis for logical thought. >> Thanks for your remarks Christian. ?Don't let this Ed character bully >> or intimidate you. ?He likes to show off, which is fine, but he lacks >> diplomatic skills IMO. ?But then some say the same about me. > > I don't like to show off. I like to get facts straight. The lack of > diplomatic skills is a symptom of my strong ADHD. > Thanks for restoring some of my faith in Roman civilization, maybe there's hope for "us" yet. Lots of these queries, e.g. "what is mathematics?" or "is chess a mathematics?" are queries in the Quakerly sense: one speaks to them perennially but one does not answer them with certainty in some misguided attempt to make the questioning stop. The "having the right answer syndrome" is psychologically slowing so we don't want too much of that around impressionable young children do we? That being said, it's fun to have these strict interpreters, like J's, Logo's, Scheme's, APL's and yes, Python's. "Playing by the rules" is a mathematical exercise -- like being a guest in some Axiom Castle, learning how to think like a Roman when in Rome. "Keep the 'big questions' more open-ended and you'll be better off" is consistent with Constructivist philosophy don't ya think? I'm thinking Karplus was more successful with science education reforms than any counterpart in math education. I wrote a short essay about that. I learned about Karplus from his student and collaborator Dr. Bob Fuller, University of Nebraska at Lincoln. But then the sciences have been seen as experimental / empirical, whereas maths seem to hold out the possibility of synthetic judgments a priori. Authoritarians, in need of certainty, tend to gravitate to so-called "unquestionable" subjects (an occupational hazard). The drive to be super-specialized is somewhat similar (as in "no one will question me once my language is purely private"). I use "maths" in the plural advisedly. Congratulations on your many strong contributions here by the way, and on other lists we frequent. I liked that you expressed admiration for Parrot on math-thinking-l, even though many of these functional programmers dislike the very sound of OO birds chirping. You seem to transcend these divisions in your own approach, understand it's more about both/and, less about either/or. Kirby > -- > Edward Mokurai (??/???????????????/????????????? ?) Cherlin > Silent Thunder is my name, and Children are my nation. > The Cosmos is my dwelling place, the Truth my destination. > http://www.earthtreasury.org/ > From da.ajoy at gmail.com Mon Apr 12 06:57:40 2010 From: da.ajoy at gmail.com (Daniel Ajoy) Date: Sun, 11 Apr 2010 23:57:40 -0500 Subject: [Edu-sig] Why Python? In-Reply-To: References: Message-ID: On Sun, 11 Apr 2010 21:51:16 -0500, wrote: >>> Likewise, an introductory computer language should be >>> close to self-explanatory. ?It will be difficult to get math and science >>> teachers to accept it, if they have to make extra efforts explaining the >>> notation. ?Getting math and science teachers to accept computation as a >>> vital part of their curricula is my current focus, so I wouldn't try to push >>> something like your example above. > > There are a number of math, science, and Computer Science textbooks in > which APL or J is the math notation throughout, being taught only as > needed without interrupting the main sequence of ideas. I can give you > citations. There is very little done in this manner in any other > programming language. (If you have seen some, please send me the > information.) I much prefer this approach to the usual one of teaching > programming language syntax and semantics in a vacuum, with no > systematic application to anything. I attest to this. Those books use the language as "executable notation". I've been trying to do the same with LogoFE for some time, here for example: http://neoparaiso.com/logo/olimpiada-matematica-nivel-1.html You might notice there is very few procedure definitions. Solutions to problems are simply transformations of inputs into outputs. The process of finding a solution to a problem is simply: showing (printing) the steps that convert the inputs into the solution. Daniel From kirby.urner at gmail.com Mon Apr 12 09:36:07 2010 From: kirby.urner at gmail.com (kirby urner) Date: Mon, 12 Apr 2010 00:36:07 -0700 Subject: [Edu-sig] Why Python? In-Reply-To: References: <4BC07E0F.0@gmx.de> <4BC2604A.6000706@ece.arizona.edu> Message-ID: On Sun, Apr 11, 2010 at 7:51 PM, Edward Cherlin wrote: > On Sun, Apr 11, 2010 at 21:03, Andrew Harrington wrote: >> Well put David. >> >> My choices are always about me and a particular situation.? I would not >> teach J to beginners > > I would use the +-*% (+-??) subset of J in first grade for arithmetic, > alongside Turtle Art (with stack tiles), and ?Etoys, including > Scratch. By third grade, we could introduce programming in J/APL, > Logo/LISP, FORTH, Python, and Smalltalk. At some point, we could show > how each represents the same internal parse tree in quite different > textual forms. What the LISPers call "syntactic sugar". This is a > fundamental Computer Science concept. > I'd like to see a school form around your druthers, with ways to facilitate turnover, so those most advantaged by this approach would have some chance to (a) discover this for themselves and (b) keep a slot in an initially rare environment. One would hope we might learn enough from your approach to transfer some of what's working to other sites. Your school of thought would spread in proportion to its achieving results, but without this stultifying demand that everything be proven risk-free before any pilots get started (as if the status quo were a result of such iron-clad assurances). A vicious circle: don't try anything until you can prove it's not in error. This results in paralysis, in nothing being tried. Nothing ventured, nothing gained -- we've all heard that a million times. Hey, I'd've provided you with space and a budget years ago. We'd be reading of your stellar results in the electronic papers by now! All that being said, I'd also sponsor other schools with quite different approaches. Television programming is even more powerful than computer programming in a lot of ways, as it feeds directly into the optic nerve thereby filling human memory banks, helping condition responses. What a powerful medium! Some schools need to put more focus on TV skills, lest all the effective recruiting commercials be for competing services. Maybe the math curriculum includes some J, but with a starry sky backdrop, with class content projected to a sheet strung between tree trunks (or is the sheet itself some kind of LCD?). You had to hike 20 miles to get here. A lot of the databases you study are about local flora and fauna. Some kind of boarding school? International students? Public? Federally funded? Lets fight early onset diabetes by ending discrimination against physical activity as intrinsically "non-mathematical". "Math is an outdoor sport" is one of our slogans. >> or to people not crunching a lot of mathematical stuff >> regularly, but for the professional statisticians and electronic traders I >> know, J is a fabulous language, and very worth the modest learning curve. > > J would enable children to crunch data sets easily, allowing a radical > deepening of every subject. The learning curve would be very modest > when integrated with arithmetic and elementary science, and applied to > languages, history, geography, health, and gym. > Glad you mentioned health and gym. Doing the math around joules and calories, relating these to food values (content): lots of crunchy data sets to work with, as you say, lots of working out. The chemistry of food, digestion, and nutrition, includes cooking, learning to cook. Where those TV-making skills come in handy: producing cooking shows for the school servers. Using Python for a graphing calculator in math class need to not be special, extraordinary, honors or advanced. It's just the obvious and everyday thing we should be doing already. Besides, maybe we're not going to college right away? Other services calling, and offering their own training? Given how FUBAR the Global U is right now, one could understand why creating high debt for high tuitions simply to further over-specialize our students might be considered counter-productive. How about scholarships for veterans to enter nursing, other medical professions? The health professions are ravenous for computing and data services. My daughter is the Portland district champion debater at 15, having started her high school's team in the first place. I worry though: why waste her talents at some backward academy that doesn't even teach about tetrahedral mensuration? How many dead mineshaft canaries does it take I wonder? Maybe by the time she graduates we'll have some respectable colleges out there. >> J is an interesting case.? Iverson did not totally open up the source. > > There is a published version of the source for an earlier version of > J, without the IDE, graphics, and so on. I have a copy. There has been > some talk of creating a Free Software version, but no activity that I > know of. However, Iverson's son Eric is considering GPLing some > version of J in support of One Laptop Per Child and Sugar Labs. I need > to bother him about it again, because I am about to apply for two XO > 1.5 units to use in preparing an introductory text on electricity. It > will use the built-in digital oscilloscope function (Measure) on the > XO, among other things, and will explain how to build and take data > from measuring instruments. I would be interested in working with > Pythonistas on a version using numpy and scipy. I'm still pretty hands-off with the XO despite having two of them, and even though I promote OLPC extensively through most excellent photography and journaling. The XO is for young children whereas I tend to not have much opportunity to work with those age groups. I tend to work with teens and older. All youth should be working on motor skills, both gross and fine, so it's important to me that computers not mess up the diet and exercise balance. The idea of a hand-cranked XO was always intriguing. Didactic challenge courses involving interactive electronics that double as physical work-outs -- designers getting into that are in on the ground floor of something big? Kirby From bblais at bryant.edu Mon Apr 12 11:41:26 2010 From: bblais at bryant.edu (Brian Blais) Date: Mon, 12 Apr 2010 05:41:26 -0400 Subject: [Edu-sig] Why Python? In-Reply-To: <20100412021513.GB25391@seberino.org> References: <20100412021513.GB25391@seberino.org> Message-ID: <40449127-1101-49F7-9C93-4E3258C69BF4@bryant.edu> On Apr 11, 2010, at 22:15 , chris at seberino.org wrote: > Ever heard of > Teach Scheme/Reach Java (http://http://www.teach-scheme.org)? I > like the idea > of starting the AP CS year with a clean language and then > "reaching" or > finishing with Java. > > I wonder if AP CS with Python and Java would be ideal. > I'd prefer Teach Python/Reach Python. ;) bb -- Brian Blais bblais at bryant.edu http://web.bryant.edu/~bblais http://bblais.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From ccosse at gmail.com Mon Apr 12 16:03:57 2010 From: ccosse at gmail.com (=?ISO-8859-1?Q?Charles_Coss=E9?=) Date: Mon, 12 Apr 2010 08:03:57 -0600 Subject: [Edu-sig] Why Python? In-Reply-To: References: <4BC07E0F.0@gmx.de> <4BC2604A.6000706@ece.arizona.edu> Message-ID: On Mon, Apr 12, 2010 at 1:36 AM, kirby urner wrote: > > "Math is an outdoor sport" is one of our slogans. > > I've heard that referred to as a "mathlete". -------------- next part -------------- An HTML attachment was scrubbed... URL: From macquigg at ece.arizona.edu Mon Apr 12 18:30:50 2010 From: macquigg at ece.arizona.edu (David MacQuigg) Date: Mon, 12 Apr 2010 09:30:50 -0700 Subject: [Edu-sig] Why Python? In-Reply-To: References: <4BC07E0F.0@gmx.de> <4BC2604A.6000706@ece.arizona.edu> Message-ID: <4BC34ABA.4010406@ece.arizona.edu> Edward Cherlin wrote: > On Sun, Apr 11, 2010 at 21:03, Andrew Harrington wrote: > >> My choices are always about me and a particular situation. I would not >> teach J to beginners >> > > I would use the +-*% (+-??) subset of J in first grade for arithmetic, > alongside Turtle Art (with stack tiles), and Etoys, including > Scratch. By third grade, we could introduce programming in J/APL, > Logo/LISP, FORTH, Python, and Smalltalk. At some point, we could show > how each represents the same internal parse tree in quite different > textual forms. What the LISPers call "syntactic sugar". This is a > fundamental Computer Science concept. > > >> or to people not crunching a lot of mathematical stuff >> regularly, but for the professional statisticians and electronic traders I >> know, J is a fabulous language, and very worth the modest learning curve. >> > > J would enable children to crunch data sets easily, allowing a radical > deepening of every subject. The learning curve would be very modest > when integrated with arithmetic and elementary science, and applied to > languages, history, geography, health, and gym. > >> David MacQuigg wrote: >> >>> Edward Cherlin wrote: >>> >>>> Christian Mascher wrote: >>>> >>>>> Edward Cherlin wrote: >>>>> >>>>>> [sigh] >>>>>> >>>>>> Do math tables in a math array language. >>>>>> >>>>>> degrees =. i. 91 NB. 0..90 >>>>>> >>>>>> radians =. degrees * o. % 180 >>>>>> >>>>>> table =. |: degrees, 1 2 3 o./ radians >>>>>> >>>>>> >>> >>> >>>>> Python is much nearer to standard Math-notation, that is a good thing. >>>>> >>>>> >>>> LOL. Math notation is what mathematicians use, not schoolchildren. >>>> They are constantly inventing more of it. What you call math notation >>>> is known to mathematicians as "arithmetic". >>>> >>>> There is no standard math notation. >>>> >>>> >>> I think what Christian means to say is that Python is much nearer to a >>> notation (pseudocode) that might be used by scientists and engineers who are >>> trying to express an idea involving computation, without relying on a >>> specific language. Of course, there is no "standard" pseudocode, but if you >>> look at textbooks that are most successful at expressing algorithms this way >>> (my examples would be from engineering - Hachtel & Somenzi on Logic >>> Synthesis, Stinson on Cryptography) what you see is a notation very close to >>> Python. >>> >>> Pseudocode has to be self-explanatory. There is no introductory chapter >>> on how to read it. >>> > > We consider pseudocode "self-explanatory" to those who already know > the syntax of a similar language. But it is not so, any more than > mousing and icons is "intuitive" for those who have never seen them. I > consider my J example _with explanatory comments_ to be simpler than > the Python I was starting from, where it must be assumed that students > have had a prior introduction to the syntax. > You may have a good point here. The C family of languages (C, Java, Python, ... ) has so permeated our culture that we now have a bias to that way of thinking, and difficulty understanding languages from the APL family (APL, J, K). I don't see any signs that the world is moving to APL-think, LISP-think, or any other programming paradigm, so if students are introduced to programming in some other style, there will be a problem in transition to C-think, a much bigger leap than moving from Python to Java. There must be a real, demonstrable benefit to an alternative paradigm, or it isn't worth the added effort of learning two. Note: I am talking about the majority of students, not those truly interested in CS, for whom learning the alternatives is a great benefit. Personally, I love exploring alternatives, and have even participated in an attempt to one-up Python (Prothon). It's interesting to speculate whether there will ever be another major improvement in programming, a step beyond Python, or if Python will simply incorporate any good ideas that come along (as it did with our @ syntax). I would bet on the latter. >>> Likewise, an introductory computer language should be >>> close to self-explanatory. It will be difficult to get math and science >>> teachers to accept it, if they have to make extra efforts explaining the >>> notation. Getting math and science teachers to accept computation as a >>> vital part of their curricula is my current focus, so I wouldn't try to push >>> something like your example above. >>> > > There are a number of math, science, and Computer Science textbooks in > which APL or J is the math notation throughout, being taught only as > needed without interrupting the main sequence of ideas. I can give you > citations. There is very little done in this manner in any other > programming language. (If you have seen some, please send me the > information.) I much prefer this approach to the usual one of teaching > programming language syntax and semantics in a vacuum, with no > systematic application to anything. > I agree that the earliest introduction to programming should be in math and science classes, without interrupting the main sequence of ideas, or forcing any more programming than is helpful to support the subject being taught. Later, we can add a little more than the minimum, not to train future programmers, but with the motivation that "computational thinking" is good for all students. The availability of good textbooks (not just programming manuals) is one of Python's advantages (compared to other agile languages like Ruby). I don't teach high-school, so others on this list may have better recommendations, but if I were teaching at that level, I would chose either Elkner's How to Think Like a Computer Scientist (http://openbookproject.net/thinkCSpy/index.html) or Litvin's Mathematics for the Digital Age. The latter seems like an especially good example of integrating computational thinking into the existing curriculum. I might start with that, then for students who are really interested in CS, maybe Elkner, or Zelle's Python Programming, An Introduction to Computer Science, or even my personal favorite - Goldwasser's Object-Oriented Programming (a bit more advanced, but surely no more difficult than senior calculus). >>> Python is just a means to an end, the closest thing we have to pseudocode. >>> > > APLers tend to find pseudocode irritating, because the APL is shorter > and clearer to those who can read it. > > >>> When someone who favors another language (typically Java) asks me why >>> Python, I find the comparison to pseudocode to be the best answer. Specific >>> examples, like the absence of type declarations, tends to invite unthinking >>> reactions. (Students will make too many errors.) Even something as simple >>> as requiring correct indentation is not obvious to someone who hasn't used >>> Python. (Although that one does have some appeal to teachers who have had >>> to read sloppy student code.) Ultimately, it is word-of-mouth, one teacher >>> telling another, that I think will decide which language gets used. >>> Interesting discussion. -- Dave From chris at seberino.org Mon Apr 12 18:53:39 2010 From: chris at seberino.org (chris at seberino.org) Date: Mon, 12 Apr 2010 11:53:39 -0500 Subject: [Edu-sig] Why Python? In-Reply-To: <4BC34ABA.4010406@ece.arizona.edu> References: <4BC07E0F.0@gmx.de> <4BC2604A.6000706@ece.arizona.edu> <4BC34ABA.4010406@ece.arizona.edu> Message-ID: <20100412165339.GE3358@seberino.org> On Mon, Apr 12, 2010 at 09:30:50AM -0700, David MacQuigg wrote: >> We consider pseudocode "self-explanatory" to those who already know >> the syntax of a similar language. But it is not so, any more than >> mousing and icons is "intuitive" for those who have never seen them. That is emminently reasonable but I'm not sure it is true. My children seemed to pick up using a mouse without any instruction IIRC. Geometry, motion & pictures seem to tap a very primitive part of our brains...much deeper than the symbology of algebra and pseudocode. I wonder if there are methods of communication that don't need much explanation because that is how are brains are naturally wired. > It's interesting to speculate whether there > will ever be another major improvement in programming, a step beyond > Python, or if Python will simply incorporate any good ideas that come > along (as it did with our @ syntax). I would bet on the latter. Well that is exciting for me as I know Python and don't want to learn a new language every 3 months. cs From christian.mascher at gmx.de Mon Apr 12 20:33:16 2010 From: christian.mascher at gmx.de (Christian Mascher) Date: Mon, 12 Apr 2010 20:33:16 +0200 Subject: [Edu-sig] mathematics and language In-Reply-To: References: <4BC07E0F.0@gmx.de> Message-ID: <4BC3676C.2080000@gmx.de> Hi all, thanks for your reactions. Just wanted to clarify a bit, although most of you seemed to have understood me quite well. >> Sorry, I don't know J (Kirby does), but this is exactly the reason I prefer >> Python. Readability counts (for me). Of course this was a bit offensive, telling someone who is really in love with something (in this case J) that you're not that interested. Gives rise to some hard feeling. Every teacher experiences this. I work as a teacher - I know how it feels, when students don't share your own enthusiasm. And they never semm to have good reasons ;-), just "feelings". Every teacher knows these questions: Oh, why do we have to learn this? I will never need this. What will we do next? When will we start with something different? Real students tend to ask these questions, communicating: "This is hard stuff, I have other things on my mind I consider more important...". And now sometimes I find myself in a similar position; although I consider myself a person who is constantly learning new things. But my time is limited and I can choose my interests now. When I studied physics in university (got a diploma in physics, 5 years of study) I had chosen a subject with lots of maths (mostly together with the mathematicians), I really liked it. I like maths. But that level is esoteric for most other peaople and more scary: most of it is far away and esoteric stuff for me now, too. Last week because I needed some space in my workplace I stacked away lots of university textbooks. In over ten years as a high-school teacher I never needed most of them, especially the highly mathematical texts. It was kind of sad, but I said farewell to them as I realized I would probably never in my life use them anymore. (I kept Feynman lectures though.) > This turns out not to be the case. The complete syntax table for J > consists of 12 lines. You are talking glibly about a topic on which > you have no information. Thats how it is. I can't be an knowledgable in everything. So many things I can just talk about as an outsider. In the past years I have taught myself Python, Java and Smalltalk in my free time together with OO-thinking, Linux,... . I have also looked into Scheme/Lisp a bit. Smalltalk was the most interesting experience, the famous "syntax table on a postcard". But while Python is a tool I actually use, Smalltalk was considerably harder to get to grips with. In school we use Java (with BlueJ) in the upper classes. For my personal bio I decided to switch interests away from programming for a while. > And without a lesson? Do you believe that Python syntax is intuitive, > and can be guessed without a manual or lessons? In i., the i stands > for index. It is easy to learn, and reasonably mnemonic. No, nothing is intuitive when you start from scratch. I can understand people who don't (want to?) learn Python, although I would always say it is useful and looks easy for me. But I had to invest there too. > > >>> % x is reciprocal of x, so o. % 180 is pi/180 >> Don't think that is very useful. > I meant: if I have a division operator then I don't have to learn about another special symbol for the reciprocal. > These objections are trivial and uninformed. You aren't a > mathematician, you don't like math and math notation, so there is > nothing more to say, except please stand out of the way of people who > can benefit from it and want it. I don't stand in your way. Go ahead. But I like math, believe it or not ;-). >> Lost you there... I put this in in remembrance of the late Arthur Siegel. Hope he doesn't mind... But he could have posted this. > LOL. Math notation is what mathematicians use, not schoolchildren. > They are constantly inventing more of it. What you call math notation > is known to mathematicians as "arithmetic". > > There is no standard math notation. Every mathematician (person who creates maths) is free to invent the symbols he finds useful. Still: I often think of mathematics as a language, at least as hard to learn as latin. You can use it to think (communicate with yourself) or to express your ideas in the most clear way for others to follow the reasoning. Over the years some symbols have proven to be more useful than others (think of d/dx Leibniz versus Newton). Some symbols are just handy because they are more or less universally agreed upon (like the indo-arabic numerals, function names sin(), mathematical constants e, pi, ...). For starting to learn maths I have to teach pupils the most common vocabulary, and the correct way to express yourself. For instance: An expression carries no meaning if it doesn't contain a =, <, > or !=. High-schoolers tend to forget that and write only one side of an equation -p/2 +- sqrt((p/2)**2-q) when they actually want to solve a quadratic equation. I have to correct this, because it is like a sentence without a verb. Mathematics as a language is more than just the vocabulary. Mathematicians have agreed about what counts as a proof (on levels of rigorousness) for instance. All the best to you, sorry for the long post, -- Christian From kirby.urner at gmail.com Tue Apr 13 01:43:31 2010 From: kirby.urner at gmail.com (kirby urner) Date: Mon, 12 Apr 2010 16:43:31 -0700 Subject: [Edu-sig] Why Python? In-Reply-To: References: <4BC07E0F.0@gmx.de> <4BC2604A.6000706@ece.arizona.edu> Message-ID: On Mon, Apr 12, 2010 at 12:36 AM, kirby urner wrote: << SNIP >> > How about scholarships for veterans to enter nursing, other medical > professions? > > The health professions are ravenous for computing and data > services. > > My daughter is the Portland district champion debater at 15, > having started her high school's team in the first place. ?I worry > though: ?why waste her talents at some backward academy > that doesn't even teach about tetrahedral mensuration? ?How > many dead mineshaft canaries does it take I wonder? > > Maybe by the time she graduates we'll have some respectable > colleges out there. > Of course the above won't make a whole lot of sense if you're just tuning in, as what means "tetrahedral mensuration" and why should any respectable college -- such as Earlham in Indiana (the topic of a cell phone conversation from the Pauling House this morning) -- include that on a syllabus? The following three posts may provide some elucidation, plus they are using Python (the 1st shows execution, the 2nd shows source code) and so are especially apropos on edu-sig: http://groups.yahoo.com/group/synergeo/message/58259 http://groups.yahoo.com/group/synergeo/message/58260 http://groups.yahoo.com/group/synergeo/message/58262 Basically I'm using the Decimal type to give the flavor of some extended precision "arithmetic" regarding some basic polyhedral relationships. As some of you know, our subculture (ethnicity) has a unit volume tetrahedron, per this TV segment outline (more storyboarding for CSN): http://coffeeshopsnet.blogspot.com/2010/04/smart-bar-lcds.html Also here: http://groups.google.com/group/mathfuture/browse_thread/thread/4aa4b568e87ba90b?hl=en A problem with the Synergeo archive, however, is it doesn't support significant whitespace, whereas this Mailman archive does, making it much better for sharing actual source code. Therefore I am taking the liberty of reposting that here: #===== import decimal from decimal import Decimal import re print """ I will now give you the radius of a rhombic triacontahedron of volume five, computing in tetra- volumes. """ myothercontext = decimal.Context(prec=100, rounding=decimal.ROUND_HALF_DOWN) decimal.setcontext(myothercontext) print decimal.getcontext() # long limo vip numbers one = Decimal('1.000000000000000000000000000000000000000000000000000000000000') two = Decimal('2.000000000000000000000000000000000000000000000000000000000000') three = Decimal('3.000000000000000000000000000000000000000000000000000000000000') five = Decimal('5.000000000000000000000000000000000000000000000000000000000000') print "Five: %s" % five radical2 = two.sqrt() radical3 = three.sqrt() radical5 = five.sqrt() print "2nd root of 2: %s" % radical2 phi = (one + radical5) / two print "Phi: %s" % phi scalefactor = (two/three) ** (one/three) print "Shrink by: %s" % scalefactor print "Radius: %s" % ((phi / radical2) * scalefactor, ) """ phi to a 100K places (potentially, check this resource: http://goldennumber.net/PhiTo100000Places.txt ) """ phi_million = "1.618033988749894848204586834365638117720309179805762862135448..." # add more digits for a match strphi = str(phi) results = re.match(strphi, phi_million) if results: print "Successful match for phi value: %s" % (results.span(), ) # (( ),) returns tuple as single %s else: print "No match with phi_million" #===== Kirby From missive at hotmail.com Tue Apr 13 02:44:59 2010 From: missive at hotmail.com (Lee Harr) Date: Tue, 13 Apr 2010 05:14:59 +0430 Subject: [Edu-sig] [ANNC] pynguin-0.7 (python turtle graphics application) In-Reply-To: References: , Message-ID: >> Pynguin is a python-based turtle graphics application. >> It combines an editor, interactive interpreter, and >> graphics display area. >> > > I like the idea of using turtles to plot graphs. Replacing graphing > calculators with Python is easier when there are simple plot functions > available (yes, I know about matplotlib, Sage...) It works pretty well for simple things. More of a test of what's possible than something especially useful. I tend to use kmplot or kalgebra when I see kids struggling with their graphing calculators. I think graphing calculators are pretty lame. kmplot and kalgebra are pretty awesome: http://edu.kde.org/kmplot/ http://edu.kde.org/kalgebra/ > Curious how much of the Standard Library turtle model gets used here. I don't import turtle.py if that's what you mean. > Is the turtle stuff all rewritten from scratch. I looked at turtle.py when starting out, but even though it says pretty clearly: """ >From here up to line??? : Tkinter - Interface for turtle.py May be replaced by an interface to some different graphics toolkit """ I wasn't sure I could get it to behave the way I wanted. I did look at it for some API ideas. It would be cool if scripts written for turtle.py could run unchanged in pynguin. Maybe I will go through and add compatibility functions for things where I chose different names for the APIs. _________________________________________________________________ Hotmail: Trusted email with Microsoft?s powerful SPAM protection. https://signup.live.com/signup.aspx?id=60969 From missive at hotmail.com Tue Apr 13 03:20:59 2010 From: missive at hotmail.com (Lee Harr) Date: Tue, 13 Apr 2010 05:50:59 +0430 Subject: [Edu-sig] [ANNC] pynguin-0.7 (python turtle graphics application) In-Reply-To: References: , , Message-ID: >> http://pynguin.googlecode.com/ > > Lee, are you familiar with the Turtle Art activity in Sugar for the > OLPC XO, also written in Python? I had not seen it before. I've used one of these "block" interfaces before with Lego Mindstorms and found it confusing. The TA one looks better though, since I can see right away that it's pretty easy to create new functions and call them. I never did see a way to do that with Mindstorms. I did not look very hard though. Maybe I've just been writing code for so long that I can't see the advantage of blocks over text anymore.... > It provides blocks for integrating > Python code. You might want to talk to Walter Bender of Sugar Labs > about his plans for expanding TA, some of which match yours. I guess I'm not sure how far the whole turtle thing can go. I really just wanted a single-window, real Python, system where my students could get their feet wet with variables, loops, and conditionals. So I made pynguin. It works pretty well for what I wanted. > I have been thinking about how to integrate all of this into a > curriculum where we would apply turtle graphics to many subjects > starting in first grade or perhaps earlier, and later teach > programming and Computer Science within this environment rather than > purely as text. I don't work with anyone that young. I don't know if they just are not interested in the text interface or if it is beyond their abilities. For me, programming is text. Though I do like syntax highlighting :o) _________________________________________________________________ Hotmail: Free, trusted and rich email service. https://signup.live.com/signup.aspx?id=60969 From kirby.urner at gmail.com Tue Apr 13 06:16:22 2010 From: kirby.urner at gmail.com (kirby urner) Date: Mon, 12 Apr 2010 21:16:22 -0700 Subject: [Edu-sig] Radical Math: debugging help? In-Reply-To: References: Message-ID: On Sat, Apr 10, 2010 at 4:41 PM, kirby urner wrote: > Below is current source for ch.py, a module for exploring volume > relationships starting with a "ground state" (a default) known as the > concentric hierarchy of polyhedra. OK, a couple replies to this one: (a) I found the bug: I'd neglected to subclass 'object' as my root object, so was not getting new-style classes, just classic classes -- we still have that distinction in 2.6. (b) I made numerous enhancements for this new improved deluxe edition, appended herewith: """ Radical Math, Portland, Oregon (April, 2010) A reading and Python module (GPL, 4Dsolutions.net) """ from math import sqrt as radical phi = (1 + radical(5))/2 class Poly( object): def __init__(self, edge = 1, edge_name = "edge", volume = 1, greekname = "Tetrahedron", platonic = True, dual = "Tetrahedron"): self.edge = edge self.edge_name = edge_name self.volume = volume self.greekname = greekname self.platonic = platonic self.dual = dual def scale(self, scalefactor): edge = self.edge * scalefactor # edge unbound to self volume = self.volume * pow(scalefactor, 3) # likewise volume # print("DEBUG: a star is born: a new %s" % self.__class__.__name__) return self.__class__(edge = edge, edge_name = self.edge_name, volume = volume, greekname = self.greekname) __mul__ = __rmul__ = scale # e.g. tetra = tetra * 3 def __repr__(self): return "Polyhedron of type %s (vol: %s)" % (self.greekname, self.volume) class Tetra( Poly ): pass class Cube( Poly ): def __init__(self, edge = 1, edge_name = "any face diagonal", volume = 3, greekname = "Cube", platonic=True, dual="Octahedron"): super(Cube, self).__init__(*(edge, edge_name, volume, greekname, platonic, dual)) class Octa( Poly ): def __init__(self, edge = 1, edge_name = "any edge", volume = 4, greekname = "Octahedron", platonic=True, dual="Cube"): super(Octa, self).__init__(*(edge, edge_name, volume, greekname, platonic, dual)) class R_Dodeca( Poly ): def __init__(self, edge = 1, edge_name = "any long face diagonal", volume = 6, greekname = "Rhombic Dodecahedron", platonic=False, dual="Cuboctahedron"): super(R_Dodeca, self).__init__(*(edge, edge_name, volume, greekname, platonic, dual)) class R_Triac( Poly ): def __init__(self, edge = radical(2)/2, edge_name = "any long face diagonal", volume = 7.5, greekname = "Rhombic Triacontahedron", platonic=False, dual="Icosidodecahedron"): super(R_Triac, self).__init__(*(edge, edge_name, volume, greekname, platonic, dual)) class Icosa ( Poly ): def __init__(self, edge = 1.0, edge_name = "any edge", volume = 5 * phi**2 * radical(2), greekname = "Icosahedron", platonic=True, dual="Pentagonal Dodecahedron"): super(Icosa, self).__init__(*(edge, edge_name, volume, greekname, platonic, dual)) class P_Dodeca ( Poly ): def __init__(self, edge = 1/phi, edge_name = "any edge", volume = (phi**2 + 1) * 3 * radical(2), greekname = "Pentagonal Dodecahedron", platonic=True, dual="Icosahedron"): super(P_Dodeca, self).__init__(*(edge, edge_name, volume, greekname, platonic, dual)) class Cubocta ( Poly ): def __init__(self, edge = 1, edge_name = "any edge", volume = 20, greekname = "Cuboctahedron", platonic=False, dual = "Rhombic Dodecahedron"): super(Cubocta, self).__init__(*(edge, edge_name, volume, greekname, platonic, dual)) def test1(): c = Cube() print "First shape: %s" % c print "Dual: %s Platonic: %s" % (c.dual, c.platonic) d = P_Dodeca() print "Second shape: %s" % d print "Dual: %s Platonic: %s" % (d.dual, d.platonic) def test2(): print "\n\nVolumes Table\n=============" for shape in (Tetra(), Cube(), Octa(), R_Triac()*pow(2./3,1./3), R_Dodeca(), R_Triac(), P_Dodeca(), Icosa(), Cubocta()): poly = "{0} ({1} = {2:.4g})".format(shape.greekname, shape.edge_name, shape.edge) print "{0:<60}{1:>8.4g}".format(poly, shape.volume) def test3(): print "\n\nDuals Table\n==========" for shape in (Tetra(), Cube(), Octa(), R_Dodeca(), R_Triac(), P_Dodeca(), Icosa(), Cubocta()): print "{0:<30}{1}".format(shape.greekname+" *"[int(shape.platonic)], shape.dual) print "\n * = Platonic" if __name__ == "__main__": print """ Silicon Foresters, aided by committed allies from the USA and elsewhere, battled the tyranny of an over-specialized majority unwilling to share important heritage. Our hero, Medal of Freedom winner and premier architect of his age, had contributed some valuable pedagogical and andragogical assets, yet these were sequestered as Verboten Math by some conspiracy of know-it-alls, rumoredly with a HQS near Princeton (the better to work with ETS perhaps). 1879 Hall fought back brilliantly, bringing Wittgenstein (LW) to bear etc. Note: D. Coxeter aka "King of IS" was a student of LW's @ Cambridge, and later worked with our hero on various geometric discoveries. Dr. Arthur Loeb, a true Renaissance man, was a bridge to M.C. Escher. Legend: ETS = Educational Testing Service IS = 'Infinite Space' (from a recent title) 1879 Hall = served Princeton U's philo & religion depts in 1970s, has since been enlarged. """ # test1() test2() test3() From kirby.urner at gmail.com Tue Apr 13 06:35:32 2010 From: kirby.urner at gmail.com (kirby urner) Date: Mon, 12 Apr 2010 21:35:32 -0700 Subject: [Edu-sig] Radical Math: debugging help? In-Reply-To: References: Message-ID: On Mon, Apr 12, 2010 at 9:16 PM, kirby urner wrote: << snip >> OK, a couple replies to this one: > (a) I found the bug: I'd neglected to subclass 'object' as my root object, > so was not getting new-style classes, just classic classes -- we still > have that distinction in 2.6. I was also mistakenly passing 'self' as a first parameter to super(Type, self).__init__. > (b) I made numerous enhancements for this new improved deluxe > edition, appended herewith: > Here's the output you get if you run it as is, except the alignment here is messed up (not a fixed width font for me here): Volumes Table ============= Tetrahedron (edge = 1) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1 Cube (any face diagonal = 1) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 3 Octahedron (any edge = 1) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?4 Rhombic Triacontahedron (any long face diagonal = 0.6177) ? ? ? ? ?5 Rhombic Dodecahedron (any long face diagonal = 1) ? ? ? ? ? ? ? ? ?6 Rhombic Triacontahedron (any long face diagonal = 0.7071) ? ? ? ?7.5 Pentagonal Dodecahedron (any edge = 0.618) ? ? ? ? ? ? ? ? ? ? 15.35 Icosahedron (any edge = 1) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 18.51 Cuboctahedron (any edge = 1) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?20 Duals Table ========== Tetrahedron* ? ? ? ? ? ? ? ? ?Tetrahedron Cube* ? ? ? ? ? ? ? ? ? ? ? ? Octahedron Octahedron* ? ? ? ? ? ? ? ? ? Cube Rhombic Dodecahedron ? ? ? ? ?Cuboctahedron Rhombic Triacontahedron ? ? ? Icosidodecahedron Pentagonal Dodecahedron* ? ? ?Icosahedron Icosahedron* ? ? ? ? ? ? ? ? ?Pentagonal Dodecahedron Cuboctahedron ? ? ? ? ? ? ? ? Rhombic Dodecahedron * = Platonic > ? ?def scale(self, scalefactor): > ? ? ? ?edge = self.edge * scalefactor ?# edge unbound to self > ? ? ? ?volume = self.volume * pow(scalefactor, 3) ?# likewise volume > ? ? ? ?# print("DEBUG: ?a star is born: a new %s" % self.__class__.__name__) > ? ? ? ?return self.__class__(edge = edge, edge_name = self.edge_name, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?volume = volume, greekname = self.greekname) Found a bug already: the scale method had yet to pass on its full complement of parameters when giving birth to a scaled version of itself. Here's what I changed it to: def scale(self, scalefactor): edge = self.edge * scalefactor # edge unbound to self volume = self.volume * pow(scalefactor, 3) # likewise volume # print("DEBUG: a star is born: a new %s" % self.__class__.__name__) return self.__class__(*(edge, self.edge_name, volume, self.greekname, self.platonic, self.dual)) Testing (old code): >>> t = Tetra() >>> t.dual 'Tetrahedron' >>> t.volume 1 >>> newt = t.volume * 3 >>> newt.dual Traceback (most recent call last): File "", line 1, in newt.dual AttributeError: 'int' object has no attribute 'dual' >>> newt.platonic Traceback (most recent call last): File "", line 1, in newt.platonic AttributeError: 'int' object has no attribute 'platonic' Testing (new code): >>> reload(ch) >>> t = Tetra() >>> t = 3 * t >>> t.volume 27 >>> t.dual 'Tetrahedron' >>> t.platonic True >>> c = Cube() >>> c = c * 3 >>> c.volume 81 >>> c.platonic True >>> d = ch.R_Dodeca() >>> d.platonic False >>> e = d * 5 >>> e.volume 750 >>> e.platonic False >>> e.dual 'Cuboctahedron' From mark.engelberg at alumni.rice.edu Tue Apr 13 11:04:24 2010 From: mark.engelberg at alumni.rice.edu (Mark Engelberg) Date: Tue, 13 Apr 2010 02:04:24 -0700 Subject: [Edu-sig] Why Python? In-Reply-To: <20100412165339.GE3358@seberino.org> References: <4BC07E0F.0@gmx.de> <4BC2604A.6000706@ece.arizona.edu> <4BC34ABA.4010406@ece.arizona.edu> <20100412165339.GE3358@seberino.org> Message-ID: >> It's interesting to speculate whether there >> will ever be another major improvement in programming, a step beyond >> Python, or if Python will simply incorporate any good ideas that come >> along (as it did with our @ syntax). I would bet on the latter. Python has served me well for many years, but it is pretty poor at handling concurrency, which is widely considered to be the hot issue that future languages will need to solve. I am skeptical that Python will be able to absorb these improvements into its existing infrastructure. I would almost certainly bet that Python will be superseded by superior languages, although possibly it has another 10 or so more years of popularity to look forward to. Some food for thought: http://research.sun.com/projects/plrg/Publications/ICFPAugust2009Steele.pdf The "Let's Add a Bunch of Numbers" slide is a great example of how Python's style naturally encourages us to write code in exactly the worst possible way from a concurrency standpoint. Translating the slide to Python: total = 0 for i in range(1000000): total = total+i return total Programmers will eventually need to unlearn this kind of process-one-at-a-time linear thinking. We will need programming languages with lots of built-in rich tree-like structures, and a way for specifying computations in a way that can be easily parallelized. Lots of great experimentation is happening in this area -- it's only a matter of time before the next language revolution. In the meantime, I think that a strong emphasis on topics like trees, recursion, immutable data structures, and divide-and-conquer algorithms is a great way to future-proof our students and prepare them for the "next big thing". From macquigg at ece.arizona.edu Tue Apr 13 19:30:49 2010 From: macquigg at ece.arizona.edu (David MacQuigg) Date: Tue, 13 Apr 2010 10:30:49 -0700 Subject: [Edu-sig] Why Python? In-Reply-To: References: <4BC07E0F.0@gmx.de> <4BC2604A.6000706@ece.arizona.edu> <4BC34ABA.4010406@ece.arizona.edu> <20100412165339.GE3358@seberino.org> Message-ID: <4BC4AA49.1040703@ece.arizona.edu> Mark Engelberg wrote: >>> It's interesting to speculate whether there >>> will ever be another major improvement in programming, a step beyond >>> Python, or if Python will simply incorporate any good ideas that come >>> along (as it did with our @ syntax). I would bet on the latter. >>> > > Python has served me well for many years, but it is pretty poor at > handling concurrency, which is widely considered to be the hot issue > that future languages will need to solve. I am skeptical that Python > will be able to absorb these improvements into its existing > infrastructure. I would almost certainly bet that Python will be > superseded by superior languages, although possibly it has another 10 > or so more years of popularity to look forward to. > Good observation. I wasn't thinking of parallel computing at all. I can see a need for something very different in this realm. I'll stick with my original bet, however, if we limit our consideration to "mainstream" languages. I will bet that languages like Fortress, designed to deal with concurrency, will be used only by specialists, and that the majority just needing to process payroll records or program a website, will stick with whatever evolves from Python. Parallel programming is motivated by a need for speed. Already Python is fast enough for 99% of what we do, and that is without even taking the next logical step, merging C into Python in a way that puts no extra burden on those that don't need it. Add to that some extensions to Python that will make available at least the simplest techniques for parallel computing, and I'll bet the 99% majority will remain well served. That's not to say the 1% is unimportant. Here we will find brilliant programmers working on sophisticated techniques to break large problems into pieces that can be executed concurrently by hundreds of processors. Each problem is very different, and we may find programs for circuit simulation using very different techniques than programs for weather prediction. These programs will be run in an environment controlled by Python. The circuit designer or atmospheric scientist will not be concerned about the details of concurrency, as long as the result is fast and accurate. > Some food for thought: > http://research.sun.com/projects/plrg/Publications/ICFPAugust2009Steele.pdf > Excellent presentation of parallel programming. > The "Let's Add a Bunch of Numbers" slide is a great example of how > Python's style naturally encourages us to write code in exactly the > worst possible way from a concurrency standpoint. > Translating the slide to Python: > total = 0 > for i in range(1000000): > total = total+i > return total > > Programmers will eventually need to unlearn this kind of > process-one-at-a-time linear thinking. We will need programming > languages with lots of built-in rich tree-like structures, and a way > for specifying computations in a way that can be easily parallelized. > Lots of great experimentation is happening in this area -- it's only > a matter of time before the next language revolution. > The example above could be written in Fortress (or whatever is the new parallel language), and presented to the Python programmer as a simple function sum(X), replacing what is now written in C. The Python programmer need not even be aware of the upgrade. All he might notice is that summing a list of 10 million floats no longer takes 4 seconds, but appears to happen instantly. > In the meantime, I think that a strong emphasis on topics like trees, > recursion, immutable data structures, and divide-and-conquer > algorithms is a great way to future-proof our students and prepare > them for the "next big thing". > These are good topics for future professional programmers who might be in that elite 1%. I don't think other technical professionals will need to understand parallel programming, any more than they need to understand how modern pipeline processors execute instructions faster than if they were finishing one before starting the next. All bets are off if Wintel continues to successfully defend its version of Moore's law. Then we will need all those multicore processors just to balance our checkbooks. :>) -- Dave ************************************************************ * * David MacQuigg, PhD email: macquigg at ece.arizona.edu * * * Research Associate phone: USA 520-721-4583 * * * * ECE Department, University of Arizona * * * * 9320 East Mikelyn Lane * * * * http://purl.net/macquigg Tucson, Arizona 85710 * ************************************************************ * From chris at seberino.org Tue Apr 13 20:02:54 2010 From: chris at seberino.org (chris at seberino.org) Date: Tue, 13 Apr 2010 13:02:54 -0500 Subject: [Edu-sig] Why Python? In-Reply-To: <4BC4AA49.1040703@ece.arizona.edu> References: <4BC07E0F.0@gmx.de> <4BC2604A.6000706@ece.arizona.edu> <4BC34ABA.4010406@ece.arizona.edu> <20100412165339.GE3358@seberino.org> <4BC4AA49.1040703@ece.arizona.edu> Message-ID: <20100413180254.GA12477@seberino.org> On Tue, Apr 13, 2010 at 10:30:49AM -0700, David MacQuigg wrote: > Good observation. I wasn't thinking of parallel computing at all. I > can see a need for something very different in this realm. I'll stick > with my original bet, however, if we limit our consideration to > "mainstream" languages. I will bet that languages like Fortress, > designed to deal with concurrency, will be used only by specialists, and > that the majority just needing to process payroll records or program a > website, will stick with whatever evolves from Python. I agree. When speed isn't important, there is no reason to welcome the added complexity of concurrent programming. > That's not to say the 1% is unimportant. Here we will find brilliant > programmers working on sophisticated techniques to break large problems > into pieces that can be executed concurrently by hundreds of processors. > Each problem is very different, and we may find programs for circuit > simulation using very different techniques than programs for weather > prediction. These programs will be run in an environment controlled by > Python. The circuit designer or atmospheric scientist will not be > concerned about the details of concurrency, as long as the result is fast > and accurate. Interesting observation. Python would still be useful in a world with concurrent tools as a glue language at worst. From kirby.urner at gmail.com Tue Apr 13 21:37:28 2010 From: kirby.urner at gmail.com (kirby urner) Date: Tue, 13 Apr 2010 12:37:28 -0700 Subject: [Edu-sig] Why Python? In-Reply-To: <20100413180254.GA12477@seberino.org> References: <4BC2604A.6000706@ece.arizona.edu> <4BC34ABA.4010406@ece.arizona.edu> <20100412165339.GE3358@seberino.org> <4BC4AA49.1040703@ece.arizona.edu> <20100413180254.GA12477@seberino.org> Message-ID: On Tue, Apr 13, 2010 at 11:02 AM, wrote: > On Tue, Apr 13, 2010 at 10:30:49AM -0700, David MacQuigg wrote: >> Good observation. ?I wasn't thinking of parallel computing at all. ?I >> can see a need for something very different in this realm. ?I'll stick >> with my original bet, however, if we limit our consideration to >> "mainstream" languages. ?I will bet that languages like Fortress, >> designed to deal with concurrency, will be used only by specialists, and >> that the majority just needing to process payroll records or program a >> website, will stick with whatever evolves from Python. > > I agree. ?When speed isn't important, there is no reason to welcome the added > complexity of concurrent programming. > Lets not exaggerate the current standing of Python within industry. The technicons in places like Indonesia still mostly don't teach it, pretty new in the Philippines etc.. Singapore / Pycon may turn some heads, but a lot of production work is done in other languages besides Python, such as Java, VB, Perl and so forth, and this is as it should be. Mathematica is one of the most prevalent languages and I don't see Python eclipsing it (or vice versa). J has its niche in the financial sector they tell me, an arena in which Python has only just emerged as a contender thanks to its now sporting a decimal type written by Facundo Batista and implemented by Facundo Batista, Eric Price, Raymond Hettinger, Aahz, and Tim Peters. All I'm saying is that Python is not now and never has been the King of Languages, nor is it my impression that it's bucking for that role (it's not my impression that geekdom even has such a job opening). Python "plays well with others" which means it expects to have others to play with, many others, including concurrently. New languages are and will be coming down the pipe, like Go most recently (a candidate implementation language?) and Python's capabilities will change depending on what it's written in. PyPy allows what by today's standards could be considered freakish behaviors, more normal to those frequenting exotic circles -- like Cirque du Soleil (currently with tents here in Portland). Fresh ideas for language features will likely keep coming from that test bed. >> That's not to say the 1% is unimportant. ?Here we will find brilliant >> programmers working on sophisticated techniques to break large problems >> into pieces that can be executed concurrently by hundreds of processors. >> Each problem is very different, and we may find programs for circuit >> simulation using very different techniques than programs for weather >> prediction. ?These programs will be run in an environment controlled by >> Python. ?The circuit designer or atmospheric scientist will not be >> concerned about the details of concurrency, as long as the result is fast >> and accurate. > There's a school of thought out there that says operating systems are supposed to handle concurrency pretty well. Some designs boot multiple Pythons as multiple processes and let the OS take care of concurrency issues. Why reinvent the wheel and rely on internal threading? Instead of multiple threads within Python, make each Python its own thread. These concurrently running Pythons are then trained to communicate in a loosely coupled fashion by reading and writing to centralized SQL tables, which double as audit trails. If a process dies, there might need to kill a process (zombie snake problem), and maybe the controlling process (like air traffic control) launches a new one -- depends on many factors. I'm thinking of a buzzbot I know about, by Portland Energy Strategies (Patrick Barton et al). I've posted about it before over recent months. Also, think about Twisted, the basis for vast multi-user games. You might think Python couldn't hold its own in such a server intensive interactive environment, but here the approach is to take maximum advantage of asynchronous architecture. That being said, I'm not suggesting only Python is ever used. The whole idea of a "glue language" is you have other things to glue. I don't think Python's global interpreter lock is always the big bugaboo some people consider it to be. Concurrency has many meanings, and is an issue computer science has been tackling regardless of the number of chips. What's true about Python is it's designed to shield programmers from wanting or needing to know much about machine architecture. You have sockets, ports, tcp/ip, various pickling and packaging protocols (like json), but you're not thinking in terms of chips or individual registers on those chips. Does this mean I think Python has a realistic chance of completely replacing Erlang as a cell phone language? No. Why would anyone wanna replace Erlang? They should be teaching that at New Mexico Tech, no? Promela anyone? http://en.wikipedia.org/wiki/Promela > Interesting observation. ?Python would still be useful in a world with > concurrent tools as a glue language at worst. In my view, the information services have a challenge to keep training a few students in esoteric so-called "dead" languages. Their "deadness" mainly involves their not evolving any more, yet they may have significant workaday responsibilities and continued maintenance of their applications remains paying work for many people. FoxPro, MUMPS, COBOL some would say Smalltalk, APL -- these are "dead languages" in the sense of being frozen APIs. Ada, Perl 5.x, Logo, Algol... all dead, and yet we could still use some help with projects implemented therein. I remember working with Bernie Gunn on his Pascal stuff. Even if the goal is to migrate to Python (or maybe Java, or both), you still need a working knowledge of the source language to move to the target language. Bernie the geochemist in New Zealand. http://www.geokem.com/ I'm thinking the approach taken by the classics and antiquities departments will come into play. How do we get students interested in Sumerian? I spell SuMerian with a capital M sometimes (like camelcase) to remind myself of this challenge. M stands for the M-language or MUMPS, a paradigm "dead language" still in use to this day, a good example of the kind of esoteric dead language that only a dwindling number will know. UC Davis still teaches M I'm pretty sure. Anyone know? http://www.vmth.ucdavis.edu/m/m_faq1.htm The work / study programs of the future will need curricula that continue to produce competent programmers in these various languages. A popular combination will probably be: learn one or two "hot" or "avant-garde" languages (whatever is in vogue, say Haskell), one workaday "old faithful" too maybe (like Java), and then one esoteric retro language that still nets you interesting clients and gigs from time to time. That could be Fortran, Pascal, even VBA. Then of course there are still the assembly languages, special to each chip. The Art of Computer Programming keeps the focus more to that level, where thinking about registers *is* important. Python is about to join the ranks of the dead at least temporarily, thanks to this recent PEP mandating a feature freeze, giving the librarians and 3rd party package developers a chance to catch up. I think this decision wins high marks for Python as a mature development community. Now that the major leap to 3.x has been made, people are willing to step back and wait for more of the assets to get over the hump. Kirby > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > From calcpage at aol.com Wed Apr 14 03:09:47 2010 From: calcpage at aol.com (calcpage at aol.com) Date: Tue, 13 Apr 2010 21:09:47 -0400 Subject: [Edu-sig] Why Python? In-Reply-To: References: Message-ID: <8CCA9864ED46F03-1404-1572B@webmail-m099.sysops.aol.com> OOO, are we talking about parallel processing now? I have this computer lab at school with all new 64bit dual core PCs I don't know what to do with. You mention multithreading python processes, but this would work only on a single multi core PC, right? What about a LAN environment made use of as a grid or cluster. Then you need somethng like MPI. What about parallel python? Anyone using that? TIA, A. Jorge Garcia http://calcpage.tripod.com Teacher & Professor Applied Mathematics, Physics?& Computer Science Baldwin Senior High School & Nassau Community College From rudazz at gmail.com Wed Apr 14 13:31:51 2010 From: rudazz at gmail.com (=?UTF-8?Q?Rud=C3=A1_Porto_Filgueiras?=) Date: Wed, 14 Apr 2010 08:31:51 -0300 Subject: [Edu-sig] Why Python? In-Reply-To: <8CCA9864ED46F03-1404-1572B@webmail-m099.sysops.aol.com> References: <8CCA9864ED46F03-1404-1572B@webmail-m099.sysops.aol.com> Message-ID: On Tue, Apr 13, 2010 at 10:09 PM, wrote: > OOO, are we talking about parallel processing now? I have this computer lab > at school with all new 64bit dual core PCs I don't know what to do with. > You mention multithreading python processes, but this would work only on a > single multi core PC, right? What about a LAN environment made use of as a > grid or cluster. Then you need somethng like MPI. What about parallel > python? Anyone using that? > Have you take a look on multiprocessing package? http://docs.python.org/library/multiprocessing.html There are some options, but it's in Python Standart Library (Python 2.6 stable). Cheers, > > TIA, > > A. Jorge Garcia > http://calcpage.tripod.com > > Teacher & Professor > Applied Mathematics, Physics & Computer Science > Baldwin Senior High School & Nassau Community College > -- Rud? Porto Filgueiras http://python-blog.blogspot.com http://twitter.com/rudaporto -------------- next part -------------- An HTML attachment was scrubbed... URL: From christian.mascher at gmx.de Wed Apr 14 16:33:33 2010 From: christian.mascher at gmx.de (Christian Mascher) Date: Wed, 14 Apr 2010 16:33:33 +0200 Subject: [Edu-sig] rewriting examples in python In-Reply-To: References: Message-ID: <4BC5D23D.9050400@gmx.de> roberto wrote: > hello, i found this very famous book > "Turtle Geometry: The Computer as a Medium for Exploring Mathematics > (Artificial Intelligence)" > by Harold Abelson and Andrea diSessa > and i was wondering if anyone of the turtle experts has ever rewritten > in python the logo examples in the book; > Nobody has answered, so probably not. Nevertheless I think its a good idea to try this. It will probably turn out to be perfectly feasible to do these examples in Python with the turtle module by Gregor Lingl. And a good exercise too. If you run into problems let us know. --Christian > i am more interested in the turtle spirit than in the logo language, > so i'd like to use python directly along with the book itself > > thank you very much in advance From macquigg at ece.arizona.edu Wed Apr 14 19:10:42 2010 From: macquigg at ece.arizona.edu (David MacQuigg) Date: Wed, 14 Apr 2010 10:10:42 -0700 Subject: [Edu-sig] Why Python? In-Reply-To: References: <4BC2604A.6000706@ece.arizona.edu> <4BC34ABA.4010406@ece.arizona.edu> <20100412165339.GE3358@seberino.org> <4BC4AA49.1040703@ece.arizona.edu> <20100413180254.GA12477@seberino.org> Message-ID: <4BC5F712.7020803@ece.arizona.edu> kirby urner wrote: >> On Tue, Apr 13, 2010 at 10:30:49AM -0700, David MacQuigg wrote: >> > >>> That's not to say the 1% is unimportant. Here we will find brilliant >>> programmers working on sophisticated techniques to break large problems >>> into pieces that can be executed concurrently by hundreds of processors. >>> Each problem is very different, and we may find programs for circuit >>> simulation using very different techniques than programs for weather >>> prediction. These programs will be run in an environment controlled by >>> Python. The circuit designer or atmospheric scientist will not be >>> concerned about the details of concurrency, as long as the result is fast >>> and accurate. >>> > > There's a school of thought out there that says operating systems are > supposed to handle concurrency pretty well. Some designs boot > multiple Pythons as multiple processes and let the OS take care of > concurrency issues. Why reinvent the wheel and rely on internal > threading? Instead of multiple threads within Python, make each > Python its own thread. > > These concurrently running Pythons are then trained to communicate in > a loosely coupled fashion by reading and writing to centralized SQL > tables, which double as audit trails. > > If a process dies, there might need to kill a process (zombie snake > problem), and maybe the controlling process (like air traffic control) > launches a new one -- depends on many factors. > As long as the coupling is loose, this kind of "concurrency" is easily handled by Python (either with threads, or separate processes). The more challenging concurrency problems involve tight coupling, tighter than can be achieved with inter-process communications. Think of a large system of equations, with 1000 outputs depending on 1000 input variables. The challenge is in partitioning that problem into smaller problems that can be solved on separate processors, with manageable requirements relating to interprocess communication. Strategies tend to be domain-specific. If the domain is circuit design, the equations follow the modularity of the design, e.g. a collection of subcircuits, each with only one input and one output. That strategy won't work in other domains, so we have no partition() function that will do it automatically, and (in my opinion) not much chance that some new language will come to the rescue. For problems that really need partitioning, we need programmers that understand the problem domain. The question for teachers using Python is - Will there be some future "concurrency" language that is: 1) So different that its features can't be unobtrusively merged into Python (not burdening those who don't need it). 2) So easy that it will replace Python as a general-purpose language, even for those 99% that don't need concurrency. I'll keep an open mind. Meanwhile, I've got to make a choice for PyKata. We need to be ready for next semester. From punch at cse.msu.edu Wed Apr 14 21:06:58 2010 From: punch at cse.msu.edu (Bill Punch) Date: Wed, 14 Apr 2010 15:06:58 -0400 Subject: [Edu-sig] Why Python? In-Reply-To: <4BC5F712.7020803@ece.arizona.edu> References: <4BC2604A.6000706@ece.arizona.edu> <4BC34ABA.4010406@ece.arizona.edu> <20100412165339.GE3358@seberino.org> <4BC4AA49.1040703@ece.arizona.edu> <20100413180254.GA12477@seberino.org> <4BC5F712.7020803@ece.arizona.edu> Message-ID: <4BC61252.6060304@cse.msu.edu> I've been adding to this note over the course of the day and it has gotten very long. Hopefully it won't bore you too much. I should start by saying that I'm a Python fan! Rich Enbody and I spent a lot of time converting the introductory computing class here at Michigan State to Python. Heck, we even wrote a book about it! So, let us all assume that I like Python. However, Python is not the do-all nor end-all of programming languages. It has any number of flaws, as does any programming language. There is no one "good" programming language, and I surely hope that better languages come along after Python. Having said that, I think Python *right now* is a very good language, one especially well suited to beginners. I have heard it described as a best practices language, and that is likely right. It combines many good features from existing languages and makes them relatively easily accessible to new users. It is an evolutionary step forward, but not revolutionary. Furthermore, and very importantly, it has a very active user community that helps translate basic programming skill into advanced tool use. http://pypi.python.org/pypi lists 9574 available packages for Python at the moment. Were it not for that, I think Python would be rather ordinary. I believe this because if students are going to put effort into learning a computer language, which is a daunting task for many, then they should get something for it. What they get for Python is the big user base and good tools. They can *do stuff* having learned Python, whatever their path might be. So what sucks in Python. I have my own personal peeves list: - concurrency. Others have commented on this already. Python is not concurrent and will not likely be concurrent soon. Python does provide threads, but those threads do not execute concurrently due to the Global Interpreter Lock (GIL). You can learn threads, come to understand them, but will not see the typical concurrent benefits in Python. Now, if Python calls other processes externally, yes you can get concurrency. You can even use external toolsets such as MPI to do a better job. Lest you say this is unimportant, I think you should reconsider. The world of computing has changed in the last 5 years. You don't get faster cores, you just get more of them. The hexacores are already being sold, with octocores soon to follow. Teaching early programmers the importance of concurrency means that in the future concurrency will be better utilized. Saying it isn't important dooms younger programmers to not understanding the problem. - automatic type coercion. Python used to have a coerce method but it is deprecated. Imagine you have a simple Rational number class, and an expression myRational + 1. You write a __add__ method to add two rationals, but that won't work with the given expression as the argument is an integer. What to do? C++ (and it's ilk) would allow you to write a method that can convert one type to another. When a problem such as the above would come along, it would look for such a conversion, do it for you, (converting 1 to 1/1) and now your existing method works! Not Python. You are required to do introspection in your method __add__ for any type that doesn't match up and covert it by hand in your method. Each and every one of them. Very clugy compared to C++ - radd, iadd and the like. This really sucks. Consider the same situation, Rational number class, only the expression is 1 + myRational. Python cannot handle such a call (it tries to find an appropriate method in the integer class). If it were C++, again automatic type conversion would come to the rescue. Instead, you have to write another method, __radd__, which reverses the argument order for commutative operations. Same with myRational += 1, there is an __iadd__ method (though thankfully they patched that recently). Very clugy indeed. - list comprehensions. I love list comprehensions but hate the syntax. It is overly confusing for a beginner. Other languages, for example common lisp, have a much more elegant and consistent solution: [x**2 for x in range(10) if x%2==0] vs for x in range(10) collect x**2 when x%2==0 A list comprehension is really an extension of the for iterator, why not work with that syntax? Now we have three potential meanings for something in [ ]: a list, an index and a list comprehension. Sure it works, and you can even point me to the math foundation for it, but it is uselessly complicated for a language structured for a beginner. Extending the for iterator would have been the way to go IMHO. - open source and language changes. I'm a big fan of open source, but it is often a two edged sword. When Python started, it generated such enthusiasm and resulted in so many packages, which was wonderful. Then, the language guys came along and broke Python for the 3.x series, making a "better" language. Well, that's nice and all, but the difference between writing a package the first time and fixing a package for a bunch of language changes is pretty big. Lots of open source folks are happy to do work for cudos and praise (the first time) but no one wants to do the nasty work of a language upgrade. Who knows how long till numpy gets upgraded to 3.x, and it must happen for many other packages, and so on and so forth. Open source is a great starter but it has its troubles w.r.t long term maintenance and changes. Till then, we are stuck with 2.x if we want to work with all those nice packages. Worse, people developing for 3.x may not wait and write their own numpy (or whatever package), causing a package break. Now there are two, with two groups and all the hassle that goes with it. Forking is another feature of open source (look at all the linux distros). I'll cut it there. Languages are tools. If you were a carpenter, you might learn how to use a hammer first but then move on to other tools as your problems change. You cannot solve all your problems with a hammer, which is why other tools exist. Same with languages. Each has their advantages, their flaws. Python is a great way to start, but don't think it is the only way to go. >>>bill<<< David MacQuigg wrote: > kirby urner wrote: >>> On Tue, Apr 13, 2010 at 10:30:49AM -0700, David MacQuigg wrote: >>> >> >>>> That's not to say the 1% is unimportant. Here we will find brilliant >>>> programmers working on sophisticated techniques to break large >>>> problems >>>> into pieces that can be executed concurrently by hundreds of >>>> processors. >>>> Each problem is very different, and we may find programs for circuit >>>> simulation using very different techniques than programs for weather >>>> prediction. These programs will be run in an environment >>>> controlled by >>>> Python. The circuit designer or atmospheric scientist will not be >>>> concerned about the details of concurrency, as long as the result >>>> is fast >>>> and accurate. >>>> >> >> There's a school of thought out there that says operating systems are >> supposed to handle concurrency pretty well. Some designs boot >> multiple Pythons as multiple processes and let the OS take care of >> concurrency issues. Why reinvent the wheel and rely on internal >> threading? Instead of multiple threads within Python, make each >> Python its own thread. >> >> These concurrently running Pythons are then trained to communicate in >> a loosely coupled fashion by reading and writing to centralized SQL >> tables, which double as audit trails. >> >> If a process dies, there might need to kill a process (zombie snake >> problem), and maybe the controlling process (like air traffic control) >> launches a new one -- depends on many factors. >> > > As long as the coupling is loose, this kind of "concurrency" is easily > handled by Python (either with threads, or separate processes). The > more challenging concurrency problems involve tight coupling, tighter > than can be achieved with inter-process communications. Think of a > large system of equations, with 1000 outputs depending on 1000 input > variables. > > The challenge is in partitioning that problem into smaller problems > that can be solved on separate processors, with manageable > requirements relating to interprocess communication. Strategies tend > to be domain-specific. If the domain is circuit design, the equations > follow the modularity of the design, e.g. a collection of subcircuits, > each with only one input and one output. That strategy won't work in > other domains, so we have no partition() function that will do it > automatically, and (in my opinion) not much chance that some new > language will come to the rescue. For problems that really need > partitioning, we need programmers that understand the problem domain. > > The question for teachers using Python is - Will there be some future > "concurrency" language that is: > 1) So different that its features can't be unobtrusively merged into > Python (not burdening those who don't need it). > 2) So easy that it will replace Python as a general-purpose language, > even for those 99% that don't need concurrency. > > I'll keep an open mind. Meanwhile, I've got to make a choice for > PyKata. We need to be ready for next semester. > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig From kirby.urner at gmail.com Thu Apr 15 01:43:13 2010 From: kirby.urner at gmail.com (kirby urner) Date: Wed, 14 Apr 2010 16:43:13 -0700 Subject: [Edu-sig] an OO example (another zoo.py) Message-ID: """ playing with polymorphism by Kirby Urner Portland, Oregon April, 2010 """ import re from random import choice class Animal(object): def __init__(self, name): self.name = name self.stomach = [] def eat(self, food): self.stomach.append(food) def poop(self): if len(self.stomach) > 0: return self.stomach.pop(0) # queue def noise(self, howmany): pass def __repr__(self): return "A %s named %s in location %s" % (self.__class__.__name__, self.name, id(self)) class Mammal(Animal): def __init__(self, name): self.blood = "warm" super(Mammal, self).__init__(name) class Reptile(Animal): def __init__(self, name): self.blood = "ambient" super(Reptile, self).__init__(name) class Monkey(Mammal): def noise(self, howmuch): noises= ["Hoot","Screech","Jabber"] return "! ".join([choice(noises) for i in range(howmuch)])+"! " class Dog(Mammal): def noise(self, numbarks): return numbarks * "Woof! " class Snake(Reptile): def noise(self, howmany): return "Hissss.. " * howmany def test1(): animal1 = Dog("Spot") animal2 = Monkey("Red Devil") animal3 = Snake("Barry") print animal1, "goes: \n", animal1.noise(3) print animal2, "goes: \n", animal2.noise(4) print animal2, "goes: \n", animal2.noise(1) print animal1, "blood ", animal1.blood print animal2, "blood ", animal2.blood print animal3, "blood ", animal3.blood if __name__== "__main__": test1() From kirby.urner at gmail.com Thu Apr 15 01:58:32 2010 From: kirby.urner at gmail.com (kirby urner) Date: Wed, 14 Apr 2010 16:58:32 -0700 Subject: [Edu-sig] Those polyhedra again (ch.py) Message-ID: """ This version adds an instance variable self.keep that propagates though the scaling method to the next of kin. For example: >>> import ch >>> c = ch.Cube() >>> c.volume 3 >>> c.keep [] >>> bigc = c * 2 >>> bigc.volume 24 >>> c.keep.append("gem") >>> c.keep ['gem'] >>> bigc.keep ['gem'] >>> """ from math import sqrt as radical phi = (1 + radical(5))/2 class Poly( object): def __init__(self, edge = 1, edge_name = "edge", volume = 1, greekname = "Tetrahedron", platonic = True, dual = "Tetrahedron", keep=[]): self.edge = edge self.edge_name = edge_name self.volume = volume self.greekname = greekname self.platonic = platonic self.dual = dual self.keep = keep def scale(self, scalefactor): edge = self.edge * scalefactor # edge unbound to self volume = self.volume * pow(scalefactor, 3) # likewise volume # print("DEBUG: a star is born: a new %s" % self.__class__.__name__) return self.__class__(*(edge, self.edge_name, volume, self.greekname, self.platonic, self.dual, self.keep)) __mul__ = __rmul__ = scale # e.g. tetra = tetra * 3 def __repr__(self): return "Polyhedron of type %s (vol: %s)" % (self.greekname, self.volume) class Tetra( Poly ): pass class Cube( Poly ): def __init__(self, edge = 1, edge_name = "any face diagonal", volume = 3, greekname = "Cube", platonic=True, dual="Octahedron", keep=[]): super(Cube, self).__init__(*(edge, edge_name, volume, greekname, platonic, dual, keep)) class Octa( Poly ): def __init__(self, edge = 1, edge_name = "any edge", volume = 4, greekname = "Octahedron", platonic=True, dual="Cube", keep=[]): super(Octa, self).__init__(*(edge, edge_name, volume, greekname, platonic, dual, keep)) class R_Dodeca( Poly ): def __init__(self, edge = 1, edge_name = "any long face diagonal", volume = 6, greekname = "Rhombic Dodecahedron", platonic=False, dual="Cuboctahedron",keep=[]): super(R_Dodeca, self).__init__(*(edge, edge_name, volume, greekname, platonic, dual, keep)) class R_Triac( Poly ): def __init__(self, edge = radical(2)/2, edge_name = "any long face diagonal", volume = 7.5, greekname = "Rhombic Triacontahedron", platonic=False, dual="Icosidodecahedron", keep=[]): super(R_Triac, self).__init__(*(edge, edge_name, volume, greekname, platonic, dual, keep)) class Icosa ( Poly ): def __init__(self, edge = 1.0, edge_name = "any edge", volume = 5 * phi**2 * radical(2), greekname = "Icosahedron", platonic=True, dual="Pentagonal Dodecahedron", keep=[]): super(Icosa, self).__init__(*(edge, edge_name, volume, greekname, platonic, dual, keep)) class P_Dodeca ( Poly ): def __init__(self, edge = 1/phi, edge_name = "any edge", volume = (phi**2 + 1) * 3 * radical(2), greekname = "Pentagonal Dodecahedron", platonic=True, dual="Icosahedron", keep=[]): super(P_Dodeca, self).__init__(*(edge, edge_name, volume, greekname, platonic, dual)) class Cubocta ( Poly ): def __init__(self, edge = 1, edge_name = "any edge", volume = 20, greekname = "Cuboctahedron", platonic=False, dual = "Rhombic Dodecahedron", keep=[]): super(Cubocta, self).__init__(*(edge, edge_name, volume, greekname, platonic, dual)) def test1(): c = Cube() print "First shape: %s" % c print "Dual: %s Platonic: %s" % (c.dual, c.platonic) d = P_Dodeca() print "Second shape: %s" % d print "Dual: %s Platonic: %s" % (d.dual, d.platonic) def test2(): print "\n\nVolumes Table\n=============" for shape in (Tetra(), Cube(), Octa(), R_Triac()*pow(2./3,1./3), R_Dodeca(), R_Triac(), P_Dodeca(), Icosa(), Cubocta()): poly = "{0} ({1} = {2:.4g})".format(shape.greekname, shape.edge_name, shape.edge) print "{0:<60}{1:>8.4g}".format(poly, shape.volume) def test3(): print "\n\nDuals Table\n==========" for shape in (Tetra(), Cube(), Octa(), R_Dodeca(), R_Triac(), P_Dodeca(), Icosa(), Cubocta()): print "{0:<30}{1}".format(shape.greekname+" *"[int(shape.platonic)], shape.dual) print "\n * = Platonic" if __name__ == "__main__": # test1() test2() test3() From kirby.urner at gmail.com Thu Apr 15 04:54:11 2010 From: kirby.urner at gmail.com (kirby urner) Date: Wed, 14 Apr 2010 19:54:11 -0700 Subject: [Edu-sig] Those polyhedra again (ch.py) In-Reply-To: References: Message-ID: On Wed, Apr 14, 2010 at 4:58 PM, kirby urner wrote: > """ > This version adds an instance variable self.keep > that propagates though the scaling method to > the next of kin. ?For example: > "propagates through"... phraseology maybe not that clear. The "keep" word is like from "castle keep", with a polyhedron being like a special box for a keepsake. The scaling method instantiates a new object of type M with volume and edges re-scaled according to the argument. I don't bother with surface area. The name 'keep' is pointing back to the same object at the origin of this chain of progeny. I find this an interesting study in Python's naming conventions, -- plus the polyhedra are designed to be instructive... Interactive session with remarks... Instantiate an object with keep bound to a dictionary object >>> rh = ch.R_Dodeca(keep={'mites':48}) double the size through two "generations" of subsequent object: >>> rh1 = rh * 2 >>> rh2 = rh1 * 2 >>> rh2.volume 384 Note that rh2.keep still points to the same object as the original rh.keep does. >>> rh2.keep {'mites': 48} adding a new (key,value) pair to rh.keep does not rebind it to a new object -- rh.keep still shares the same referent as rh2.keep >>> rh.keep['a']=96 >>> rh2.keep {'a': 96, 'mites': 48} Here, in rebinding rh.keep to an immutable string, we no longer name the same object as rh1.keep or rh2.keep rh.keep is not a "class variable". >>> rh.keep = 'new value' >>> rh2.keep {'a': 96, 'mites': 48} Kirby From echerlin at gmail.com Thu Apr 15 05:44:24 2010 From: echerlin at gmail.com (Edward Cherlin) Date: Wed, 14 Apr 2010 23:44:24 -0400 Subject: [Edu-sig] Why Python? In-Reply-To: <20100412165339.GE3358@seberino.org> References: <4BC07E0F.0@gmx.de> <4BC2604A.6000706@ece.arizona.edu> <4BC34ABA.4010406@ece.arizona.edu> <20100412165339.GE3358@seberino.org> Message-ID: On Mon, Apr 12, 2010 at 12:53, wrote: > On Mon, Apr 12, 2010 at 09:30:50AM -0700, David MacQuigg wrote: >>> We consider pseudocode "self-explanatory" to those who already know >>> the syntax of a similar language. But it is not so, any more than >>> mousing and icons is "intuitive" for those who have never seen them. > > That is eminently reasonable but I'm not sure it is true. ?My children seemed > to pick up using a mouse without any instruction IIRC. Let me clarify. Moving the mouse pointer is automatic and inevitable. Clicking is inevitable, but most clicks will fail to do anything. Moving the pointer to an icon and clicking is obvious if you see someone else do it, without formal instruction. So far, so good. Now what about click and drag (menu selection, open submenu, move, resize, rotate, draw) right click (context menu) middle click (or left and right click simultaneously. Various effects) hover (hint, alt text, popup, short menu) hover longer (longer menu) double click (open, run) shift click and drag (selection) triple click (larger selection, line or paragraph) control click (no standard) alt click (no standard) etc. Gamers learn many more combinations, sometimes including complex chords, on special gamer controls. Emacsers only use the mouse to change virtual terminals, if that, and do everything else with key combinations (EMACS = Escape, Meta, Alt, Control, Shift) My experience is that all of these mouse actions need to be taught, particularly the multi-use actions like shift click. This may consist of demonstrating each usage once, if the result is sufficiently rewarding and immediate. With very young children, I hold the x mouse key for them on the XO at first, to let them get the hang of click and drag in stages. Large numbers of adults are completely unaware of triple click. I personally hate delayed hover menus, especially doubly-delayed expanding hover menus, as in Sugar. This is being redesigned. > Geometry, motion & pictures seem > to tap a very primitive part of our brains...much deeper than the symbology of > algebra and pseudocode. ?I wonder if there are methods of communication that > don't need much explanation because that is how are brains are naturally wired. Try Scratch, which applies Smalltalk to multimedia. Editing movies is just drag and drop. Also Turtle Art. Sugar has a version in Python which supports adding functions in Python. I have done a presentation on teaching Python in elementary schools using these tools. You can put a Python expression into a graphing tile, for example, or grab math examples from Pippy the Python editor and tell the turtle to map out primes, or Fibonacci numbers, or the Pascal triangle. (Mod 2, it gives a Sierpinski fractal.) >> It's interesting to speculate whether there >> will ever be another major improvement in programming, a step beyond >> Python, or if Python will simply incorporate any good ideas that come >> along (as it did with our @ syntax). ?I would bet on the latter. I bet against you. This is not a new idea. See The Next 700 Programming Languages, by Landin. He proposed absorbing everything into LISPish language structures. > Well that is exciting for me as I know Python and don't want to learn a new > language every 3 months. A gentle introduction to APL concepts without the syntax and symbols is available in numpy. I propose to teach children the basics of the essential features used in all of the major languages, in primary school. My short list of really major concepts includes arithmetic (prefix in LISP, postfix in FORTH, infix everywhere else) variable names are pronouns namespaces Boolean algebra sets permutations, sorting, and searching combinatorics lists of lists (LISP, SCHEME) arrays (APL) forests (arrays of trees, J) OOP (Smalltalk, Python) minimal syntaxes with neither parentheses nor precedence parse trees first-class functions functional programming number base/polynomial equivalence data/program equivalence database topological (dependence) sorting for spreadsheets Then they will recognize that new languages differ mostly in syntax, which is no big deal for those who understand how computing really works. _You_, on the other hand, don't need to learn a new language more often than every two or three years in order to start catching up. Obviously, we can't give third-graders that list of terminology. The idea is to present real examples of these ideas, and only introduce the names later--the opposite of the age-old tradition in textbooks, but a match to the way infants learn before they acquire language. BTW, did you know that infants can learn four or more languages simultaneously without ever finding out that it's supposed to be hard to do? > cs > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From echerlin at gmail.com Thu Apr 15 05:52:54 2010 From: echerlin at gmail.com (Edward Cherlin) Date: Wed, 14 Apr 2010 23:52:54 -0400 Subject: [Edu-sig] rewriting examples in python In-Reply-To: <4BC5D23D.9050400@gmx.de> References: <4BC5D23D.9050400@gmx.de> Message-ID: I am more interested in reimplementing such examples in Turtle Art, and in having a module to translate to Python automatically. Since TA implements each tile in Python, and the source code is provided, this should be an easy exercise. On Wed, Apr 14, 2010 at 10:33, Christian Mascher wrote: > roberto wrote: >> >> hello, i found this very famous book >> "Turtle Geometry: The Computer as a Medium for Exploring Mathematics >> (Artificial Intelligence)" >> by Harold Abelson and Andrea diSessa >> and i was wondering if anyone of the turtle experts has ever rewritten >> in python the logo examples in the book; >> > Nobody has answered, so probably not. Nevertheless I think its a good idea > to try this. It will probably turn out to be perfectly feasible to do these > examples in Python with the turtle module by Gregor Lingl. And a good > exercise too. If you run into problems let us know. > > --Christian > >> i am more interested in the turtle spirit than in the logo language, >> so i'd like to use python directly along with the book itself >> >> thank you very much in advance > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From kirby.urner at gmail.com Thu Apr 15 06:56:34 2010 From: kirby.urner at gmail.com (kirby urner) Date: Wed, 14 Apr 2010 21:56:34 -0700 Subject: [Edu-sig] Why Python? In-Reply-To: <4BC61252.6060304@cse.msu.edu> References: <4BC34ABA.4010406@ece.arizona.edu> <20100412165339.GE3358@seberino.org> <4BC4AA49.1040703@ece.arizona.edu> <20100413180254.GA12477@seberino.org> <4BC5F712.7020803@ece.arizona.edu> <4BC61252.6060304@cse.msu.edu> Message-ID: On Wed, Apr 14, 2010 at 12:06 PM, Bill Punch wrote: << snip >> > - open source and language changes. I'm a big fan of open source, but it is > often a two edged sword. When Python started, it generated such enthusiasm > and resulted in so many packages, which was wonderful. Then, the language > guys came along and broke Python for the 3.x series, making a "better" > language. Well, that's nice and all, but the difference between writing a > package the first time and fixing a package for a bunch of language changes > is pretty big. Lots of open source folks are happy to do work for cudos and > praise (the first time) but no one wants to do the nasty work of a language > upgrade. Who knows how long till numpy gets upgraded to 3.x, and it must > happen for many other packages, and so on and so forth. Open source is a > great starter but it has its troubles w.r.t long term maintenance and > changes. Till then, we are stuck with 2.x if we want to work with all those > nice packages. Worse, people developing for 3.x may not wait and write their > own numpy (or whatever package), causing a package break. Now there are two, > with two groups and all the hassle that goes with it. Forking is another > feature of open source (look at all the linux distros). > "Why Python sucks" with a focus on this or that feature, is a somewhat well-established genre at Pycons and such, a type of lightning talk in many cases. Good to welcome dissenting and dissatisfied voices. Any one of us may need to vent some pet peeves in that way.** Strong proponents of Python, such as yourself, need to be clear you are not blind to her limitations. Sometimes when a shortcoming is described, a fix is proposed (as a PEP) but that's not a requirement, nor even indicated in some cases. In the case of list comprehensions, that syntax seems pretty entrenched. Set and dictionary comprehensions have followed. Regarding the leap from 2.x to 3.x in particular, I don't think having Python be open source is to blame. Guido himself had some backward incompatibilities he wanted to introduce. Not every language designer gets such an opportunity and it's not an easy jump to make (lots of thought has gone into it). Had it not been for Guido's leadership and active desire to get on with some of these changes, the momentum / inertia of the larger open source community might have prevented 3.x from ever becoming a reality. From my tone, you may guess I'm feeling up beat about 3.x and its future. True enough. I also think the acceptance of this PEP to freeze the core language for awhile, to give more 3rd party package maintainers some breathing room, is a good move by Guido, Brett Cannon et al. http://mail.python.org/pipermail/python-ideas/2009-October/006305.html Kirby > I'll cut it there. Languages are tools. If you were a carpenter, you might > learn how to use a hammer first but then move on to other tools as your > problems change. You cannot solve all your problems with a hammer, which is > why other tools exist. Same with languages. Each has their advantages, their > flaws. Python is a great way to start, but don't think it is the only way to > go. > > ? ? ? >>>bill<<< > > > ** For me, it's a lack of language bindings to applications we still don't have yet, simulations and so forth (some of which I've described elsewhere) -- and not enough Rich Data Structures in native Python, these latter to with content outside of computer science. Just today I was in this meeting talking about how I'd like to simply download a source .py file and go: >>> import elements >>> atom = elements.Carbon(neutrons=8) >>> atom.protons 6 >>> atom.radioactive True Another module would have a data structure such as: every nation-state as of year X (a context) with a link to every nation-state with a shared border (a graph or polyhedral structure). These are just examples. I go back in this archive with this theme, have provided some data of my own: http://markmail.org/search/?q=edu-sig+stillaguamish etc. This isn't a beef with the language so much as with surrounding eco- system. From chris at seberino.org Thu Apr 15 06:58:33 2010 From: chris at seberino.org (chris at seberino.org) Date: Wed, 14 Apr 2010 23:58:33 -0500 Subject: [Edu-sig] How do virtual 3D Second Life classrooms compare to WebEx for distance learning? Message-ID: <20100415045833.GA27583@seberino.org> I don't know if this educational topic is allowed on this but here goes... I do online math classes with video conferencing and a shared whiteboard. I'm trying to find out if doing virtual classes in Second Life with avatars offers any benefits. I've read up on this topic and the reports vary. Anyone have any experience going to a "class" in Second Life? cs From kirby.urner at gmail.com Thu Apr 15 10:04:12 2010 From: kirby.urner at gmail.com (kirby urner) Date: Thu, 15 Apr 2010 01:04:12 -0700 Subject: [Edu-sig] Why Python? In-Reply-To: References: <4BC07E0F.0@gmx.de> <4BC2604A.6000706@ece.arizona.edu> <4BC34ABA.4010406@ece.arizona.edu> <20100412165339.GE3358@seberino.org> Message-ID: << snip >> Ed Cherlin wrote: > I propose to teach children the basics of the essential features used > in all of the major languages, in primary school. My short list of > really major concepts includes > > arithmetic (prefix in LISP, postfix in FORTH, infix everywhere else) > variable names are pronouns > namespaces > Boolean algebra > sets > permutations, sorting, and searching > combinatorics > lists of lists (LISP, SCHEME) > arrays (APL) > forests (arrays of trees, J) > OOP (Smalltalk, Python) > minimal syntaxes with neither parentheses nor precedence > parse trees > first-class functions > functional programming > number base/polynomial equivalence > data/program equivalence > database > topological (dependence) sorting for spreadsheets > I'd be interested in an adaptation of this curriculum for teens to adults. Or maybe we'd use the elementary comix or cartoons or whatever you're using, in addition to the various languages. Adults learn a lot from kid-oriented materials (Sesame Street for example -- teaches a lot about how to make cool YouTubes, lightning talks). I'm looking to advance adult / child understanding and appreciation for polyhedra as well, a traditional Renaissance focus. The five Platonics and their duals (the five Platonics) plus dual-combos (combining duals to get new polys): that's a theme for anime in bars as well as schools. http://coffeeshopsnet.blogspot.com/2010/04/smart-bar-lcds.html Kirby From andreas.raab at gmx.de Thu Apr 15 10:25:30 2010 From: andreas.raab at gmx.de (Andreas Raab) Date: Thu, 15 Apr 2010 01:25:30 -0700 Subject: [Edu-sig] How do virtual 3D Second Life classrooms compare to WebEx for distance learning? In-Reply-To: <20100415045833.GA27583@seberino.org> References: <20100415045833.GA27583@seberino.org> Message-ID: <4BC6CD7A.5040409@gmx.de> On 4/14/2010 9:58 PM, chris at seberino.org wrote: > I don't know if this educational topic is allowed on this but here goes... > > I do online math classes with video conferencing and a shared whiteboard. > > I'm trying to find out if doing virtual classes in Second Life with avatars > offers any benefits. I've read up on this topic and the reports vary. > > Anyone have any experience going to a "class" in Second Life? Disclaimer: I work for Teleplace (www.teleplace.com). In my experience the biggest difference between giving a class in an immersive environment vs. WebEx or similar is that "you're there". An immersive environment takes you full attention, between navigation, pointing, voice chat, webcam and interactions there's no way to "hide" or to distract yourself playing Freecell without the others noticing. An immersive environment like Second Life or Teleplace also gives you multiple focus points. People can look at and work with different content in the same space; as the teacher/coordinator you get a good feel for where people are at, just by looking at the clusters of participants, and you can direct attention by asking people to look/interact with a particular part of the environment. And when they're there they're there, and if they're not coming you'll know, too. If you haven't tried it, invite a few friends and just run an experiment. Use Second Life or if you want to get a notch up use the 30 days free trial at Teleplace. It's worth trying it with people you have regular remote meetings with to see if it makes a difference for what you're intending to use it for. ObPython plug: The Teleplace extension API uses Python and we've given Python classes to customers with an interest in extending Teleplace. Cheers, - Andreas From roberto03 at gmail.com Thu Apr 15 17:36:53 2010 From: roberto03 at gmail.com (roberto) Date: Thu, 15 Apr 2010 17:36:53 +0200 Subject: [Edu-sig] rewriting examples in python In-Reply-To: References: <4BC5D23D.9050400@gmx.de> Message-ID: On Thu, Apr 15, 2010 at 5:52 AM, Edward Cherlin wrote: > I am more interested in reimplementing such examples in Turtle Art, > and in having a module to translate to Python automatically. Since TA > implements each tile in Python, and the source code is provided, this > should be an easy exercise. > i agree; also, i started this thread since i did not find any *introductory* and rich enough resource a school student can use to learn TA or turtle module or, broadly speaking, turtle programming in Python (if i am wrong, please tell me) if nobody else did something in this regard, i'll be happy to do some work in this direction as soon as the school end, early june; of course, since my students are very young and with no previous programming experience, i'd like to start with TA let me know also if anyone is doing something similar, to prevent double work thank you again > On Wed, Apr 14, 2010 at 10:33, Christian Mascher > wrote: >> roberto wrote: >>> >>> hello, i found this very famous book >>> "Turtle Geometry: The Computer as a Medium for Exploring Mathematics >>> (Artificial Intelligence)" >>> by Harold Abelson and Andrea diSessa >>> and i was wondering if anyone of the turtle experts has ever rewritten >>> in python the logo examples in the book; >>> >> Nobody has answered, so probably not. Nevertheless I think its a good idea >> to try this. It will probably turn out to be perfectly feasible to do these >> examples in Python with the turtle module by Gregor Lingl. And a good >> exercise too. If you run into problems let us know. >> >> --Christian >> >>> i am more interested in the turtle spirit than in the logo language, >>> so i'd like to use python directly along with the book itself >>> >>> thank you very much in advance >> >> _______________________________________________ >> Edu-sig mailing list >> Edu-sig at python.org >> http://mail.python.org/mailman/listinfo/edu-sig >> > > > > -- > Edward Mokurai (??/???????????????/????????????? ?) Cherlin > Silent Thunder is my name, and Children are my nation. > The Cosmos is my dwelling place, the Truth my destination. > http://www.earthtreasury.org/ > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -- roberto From macquigg at ece.arizona.edu Thu Apr 15 18:56:20 2010 From: macquigg at ece.arizona.edu (David MacQuigg) Date: Thu, 15 Apr 2010 09:56:20 -0700 Subject: [Edu-sig] Why Python? In-Reply-To: <4BC61252.6060304@cse.msu.edu> References: <4BC2604A.6000706@ece.arizona.edu> <4BC34ABA.4010406@ece.arizona.edu> <20100412165339.GE3358@seberino.org> <4BC4AA49.1040703@ece.arizona.edu> <20100413180254.GA12477@seberino.org> <4BC5F712.7020803@ece.arizona.edu> <4BC61252.6060304@cse.msu.edu> Message-ID: <4BC74534.3070907@ece.arizona.edu> Bill Punch wrote: > - concurrency. Others have commented on this already. Python is not > concurrent and will not likely be concurrent soon. Python does provide > threads, but those threads do not execute concurrently due to the > Global Interpreter Lock (GIL). You can learn threads, come to > understand them, but will not see the typical concurrent benefits in > Python. Now, if Python calls other processes externally, yes you can > get concurrency. You can even use external toolsets such as MPI to do > a better job. Lest you say this is unimportant, I think you should > reconsider. The world of computing has changed in the last 5 years. > You don't get faster cores, you just get more of them. The hexacores > are already being sold, with octocores soon to follow. Teaching early > programmers the importance of concurrency means that in the future > concurrency will be better utilized. Saying it isn't important dooms > younger programmers to not understanding the problem. Speed is the issue here, and speed is definitely important for a small minority of applications. You can get all the speed the machine is capable of, including cooking on all eight "octocores", by using C instead of Python at the bottlenecks in your program. With C, you can bypass all the safety and convenience features that make Python slow (GIL, array limits, type checking, whatever) and just put the pedal to the metal. Our freshmen start with a semester of C, then move on to Java, never using C again. I have a lecture that I gave at the end of the semester, showing some beautiful Mandelbrot images. http://ece.arizona.edu/~edatools/ece175/Lecture/ It takes a couple of minutes to generate one high-resolution image, using the tightest Python code I can write. Then I drop in some C (using weave.inline) for the critical loop. The images are generated 200X faster! My next step will be to see how much faster we can go with multiple threads. Cython.org is working on a smooth integration of C with Python. Do we still need a new language? How would that language be better than Python + C? > - list comprehensions. I love list comprehensions but hate the syntax. > It is overly confusing for a beginner. Other languages, for example > common lisp, have a much more elegant and consistent solution: > > [x**2 for x in range(10) if x%2==0] > vs > for x in range(10) collect x**2 when x%2==0 > > A list comprehension is really an extension of the for iterator, why > not work with that syntax? Now we have three potential meanings for > something in [ ]: a list, an index and a list comprehension. Sure it > works, and you can even point me to the math foundation for it, but it > is uselessly complicated for a language structured for a beginner. > Extending the for iterator would have been the way to go IMHO. I used to feel that list comprehensions were confusing, and better to just use a standard for-loop. Then I read Michel Paul's Manifesto http://pykata.appspot.com/static/manifesto.py.txt, and I understood the elegance of the notation. The first example above reads almost like it was standard set notation. The problem was that I learned about list comprehensions from a text that only compared them to standard loops. Save a few lines - no big deal. Michel's presentation is much better. -- Dave > David MacQuigg wrote: >> kirby urner wrote: >>>> On Tue, Apr 13, 2010 at 10:30:49AM -0700, David MacQuigg wrote: >>>> >>> >>>>> That's not to say the 1% is unimportant. Here we will find brilliant >>>>> programmers working on sophisticated techniques to break large >>>>> problems >>>>> into pieces that can be executed concurrently by hundreds of >>>>> processors. >>>>> Each problem is very different, and we may find programs for circuit >>>>> simulation using very different techniques than programs for weather >>>>> prediction. These programs will be run in an environment >>>>> controlled by >>>>> Python. The circuit designer or atmospheric scientist will not be >>>>> concerned about the details of concurrency, as long as the result >>>>> is fast >>>>> and accurate. >>>>> >>> >>> There's a school of thought out there that says operating systems are >>> supposed to handle concurrency pretty well. Some designs boot >>> multiple Pythons as multiple processes and let the OS take care of >>> concurrency issues. Why reinvent the wheel and rely on internal >>> threading? Instead of multiple threads within Python, make each >>> Python its own thread. >>> >>> These concurrently running Pythons are then trained to communicate in >>> a loosely coupled fashion by reading and writing to centralized SQL >>> tables, which double as audit trails. >>> >>> If a process dies, there might need to kill a process (zombie snake >>> problem), and maybe the controlling process (like air traffic control) >>> launches a new one -- depends on many factors. >>> >> >> As long as the coupling is loose, this kind of "concurrency" is >> easily handled by Python (either with threads, or separate >> processes). The more challenging concurrency problems involve tight >> coupling, tighter than can be achieved with inter-process >> communications. Think of a large system of equations, with 1000 >> outputs depending on 1000 input variables. >> >> The challenge is in partitioning that problem into smaller problems >> that can be solved on separate processors, with manageable >> requirements relating to interprocess communication. Strategies tend >> to be domain-specific. If the domain is circuit design, the >> equations follow the modularity of the design, e.g. a collection of >> subcircuits, each with only one input and one output. That strategy >> won't work in other domains, so we have no partition() function that >> will do it automatically, and (in my opinion) not much chance that >> some new language will come to the rescue. For problems that really >> need partitioning, we need programmers that understand the problem >> domain. >> >> The question for teachers using Python is - Will there be some future >> "concurrency" language that is: >> 1) So different that its features can't be unobtrusively merged into >> Python (not burdening those who don't need it). >> 2) So easy that it will replace Python as a general-purpose language, >> even for those 99% that don't need concurrency. >> >> I'll keep an open mind. Meanwhile, I've got to make a choice for >> PyKata. We need to be ready for next semester. >> From kirby.urner at gmail.com Thu Apr 15 20:06:02 2010 From: kirby.urner at gmail.com (kirby urner) Date: Thu, 15 Apr 2010 11:06:02 -0700 Subject: [Edu-sig] How do virtual 3D Second Life classrooms compare to WebEx for distance learning? In-Reply-To: <20100415045833.GA27583@seberino.org> References: <20100415045833.GA27583@seberino.org> Message-ID: Before 2nd Life there was Active Worlds, including some set aside for education. Friends and I built a virtual world and held conferences there. Bonnie de Varco built a virtual high school. We sent in our avatars at appointed times, looked around and talked. You'll find a screen shot here, plus links that still work, even after a decade: http://www.4dsolutions.net/ocn/lsystems.html (no avatars shown -- a point of view shot, facing north. Bonnie and I overlapped when she was chief archivist for the Buckminster Fuller Institute. A lot of our content was related to polyhedra, which made a virtual world in some ways ideal, as we could move amidst the very subject matter we were yakking about. Gerald de Jong was developing his Elastic Interval Geometry and we'd meet about that as well (meeting in person was more satisfying though -- for all its bells and whistles, 2nd Life etc. are no more than a multi-user doll houses). Having attended a Howard Rheingold lecture recently (he's made studying Cyberia (i.e. 2nd world i.e. cyberspace) a lifetime focus, starting with The Well) I am sensitive to the fact that many people just stumble around in Second Life and find it far from intuitive. I think one needs to provide a strong use case up front, to recruit willing participants. My example, of wanting to make Polyhedra a focus, or L-systems, or other art, and of wanting to pioneer the shared doll house experience with a virtual worlds anthropologist (Bonnie), might serve as a basis for future meetups along these lines. Kirby Citations / annotations: http://members.cruzio.com/~devarco/portfolio.htm (mentions Virtual High School) http://mybizmo.blogspot.com/2010/04/smart-mobs.html (see 3rd from last paragraph) On Wed, Apr 14, 2010 at 9:58 PM, wrote: > I don't know if this educational topic is allowed on this but here goes... > > I do online math classes with video conferencing and a shared whiteboard. > > I'm trying to find out if doing virtual classes in Second Life with avatars > offers any benefits. ?I've read up on this topic and the reports vary. > > Anyone have any experience going to a "class" in Second Life? > > cs > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > From kirby.urner at gmail.com Thu Apr 15 20:29:14 2010 From: kirby.urner at gmail.com (kirby urner) Date: Thu, 15 Apr 2010 11:29:14 -0700 Subject: [Edu-sig] intro to regular expressions Message-ID: Here's a module people could easily expand upon, staying with Jabberwocky as the target text. I'm by no means a master of the regexp. For example, I wanted to pick out all sentences with Jabberwock including those beginning and ending with quote marks (if present), i.e. keeping the quotes in the match. My current attempt loses the quote marks, keeping the enclosed sentence. One could imagine 20-30 more regexps, if not hundreds, populating this file. The doctest version could display expected output (except it gets kinda verbose (appended) -- maybe selected examples only...). Kirby === """ Playing with regular expressions... GPL 2010 4D Solutions This small suite of tests could easily be augmented with more elaborate ones, or simply variations on the theme. Consider this a workbench for test out your regexps. """ import re poem = """ 'Twas brillig, and the slithy toves Did gyre and gimble in the wabe; All mimsy were the borogoves, And the mome raths outgrabe. "Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun The frumious Bandersnatch!" He took his vorpal sword in hand: Long time the manxome foe he sought- So rested he by the Tumtum tree, And stood awhile in thought. And as in uffish thought he stood, The Jabberwock, with eyes of flame, Came whiffling through the tulgey wood, And burbled as it came! One, two! One, two! and through and through The vorpal blade went snicker-snack! He left it dead, and with its head He went galumphing back. "And hast thou slain the Jabberwock? Come to my arms, my beamish boy! O frabjous day! Callooh! Callay!" He chortled in his joy. 'Twas brillig, and the slithy toves Did gyre and gimble in the wabe; All mimsy were the borogoves, And the mome raths outgrabe. """ def show_all(title, regexp, match_list): print "%s\n%s" % (title, len(title) * "=") print "regexp: %s\n" % regexp if match_list: for list_item in match_list: print list_item,'\n----' else: print "No Matches" print "\n\n" def test0(): """ Show the line of text in which Jabberwock appears, with ^ matching after \n, not just at the start of the string (the purpose of the MULTILINE flag). Given the word Jabberwock is not in the first line, there is no match without MULTILINE """ regexp = r"^.*Jabberwock.*$" p = re.compile(regexp, re.MULTILINE) m = p.findall(poem) show_all("Lines with Jabberwock", regexp, m) def test1(): """ Sentences in which Jabberwok appears, starting with a capital letter and ending with punctuation. The non-greedy .*? matches across \n because of DOTALL. After the first capitalized word, the matcher goes through any character that's not a terminating punctuation mark, through the string Jabberwock, and on to the terminus. """ regexp = r'[A-Z]\w+\b[^.!?"]+Jabberwock.*?[?!.]' # how to include outside quotes if present? p = re.compile(regexp, re.MULTILINE | re.DOTALL) m = p.findall(poem) show_all("Sentences with Jabberwock", regexp, m) def test2(): """ Find all strings enclosed in quotes (") that also and with an exclamation point. The *? makes * behave in a "non-greedy" manner, so the first satisfying pattern is considered a match. """ regexp = r'".*?!"' p = re.compile(regexp, re.MULTILINE | re.DOTALL) m = p.findall(poem) show_all("Exclamations", regexp, m) def test3(): """ Here we're looking for words starting with capital letters, then we're grabbing up to 3 characters on either side, including newlines if need be. The DOTALL is what picks up newlines. """ regexp = r'.{0,3}[A-Z]\w+\b.{0,3}' p = re.compile(regexp, re.MULTILINE | re.DOTALL) m = p.findall(poem) show_all("Capitals", regexp, m) def test4(): """ Here we're looking for words starting with capital letters, then we're grabbing up to 3 characters on either side, including newlines if need be. The DOTALL is what picks up newlines. """ regexp = r'.{0,3}[A-Z]\w+\b.{0,3}' p = re.compile(regexp, re.MULTILINE | re.DOTALL) m = p.findall(poem) show_all("Capitals", regexp, m) def alltests(): test0() test1() test2() test3() if __name__ == "__main__": alltests() === Lines with Jabberwock ===================== regexp: ^.*Jabberwock.*$ "Beware the Jabberwock, my son! ---- The Jabberwock, with eyes of flame, ---- "And hast thou slain the Jabberwock? ---- Sentences with Jabberwock ========================= regexp: [A-Z]\w+\b[^.!?"]+Jabberwock.*?[?!.] Beware the Jabberwock, my son! ---- And as in uffish thought he stood, The Jabberwock, with eyes of flame, Came whiffling through the tulgey wood, And burbled as it came! ---- And hast thou slain the Jabberwock? ---- Exclamations ============ regexp: ".*?!" "Beware the Jabberwock, my son! The jaws that bite, the claws that catch! Beware the Jubjub bird, and shun The frumious Bandersnatch!" ---- "And hast thou slain the Jabberwock? Come to my arms, my beamish boy! O frabjous day! Callooh! Callay!" ---- Capitals ======== regexp: .{0,3}[A-Z]\w+\b.{0,3} 'Twas br ---- es Did gy ---- e; All mi ---- s, And th ---- "Beware th ---- e Jabberwock, m ---- n! The ja ---- h! Beware th ---- e Jubjub bi ---- un The fr ---- us Bandersnatch!" ---- He to ---- d: Long ti ---- t- So re ---- he Tumtum tr ---- e, And st ---- . And as ---- d, The Ja ---- e, Came wh ---- d, And bu ---- ! One, t ---- o! One, t ---- gh The vo ---- k! He le ---- ad He we ---- "And ha ---- he Jabberwock? C ---- y! Callooh! C ---- !" He ch ---- 'Twas br ---- es Did gy ---- e; All mi ---- s, And th ---- From echerlin at gmail.com Fri Apr 16 01:26:49 2010 From: echerlin at gmail.com (Edward Cherlin) Date: Thu, 15 Apr 2010 19:26:49 -0400 Subject: [Edu-sig] rewriting examples in python In-Reply-To: References: <4BC5D23D.9050400@gmx.de> Message-ID: On Thu, Apr 15, 2010 at 11:36, roberto wrote: > On Thu, Apr 15, 2010 at 5:52 AM, Edward Cherlin wrote: >> I am more interested in reimplementing such examples in Turtle Art, >> and in having a module to translate to Python automatically. Since TA >> implements each tile in Python, and the source code is provided, this >> should be an easy exercise. >> > i agree; > > also, i started this thread since i did not find any *introductory* > and rich enough resource a school student can use to learn TA or > turtle module or, broadly speaking, turtle programming in Python (if i > am wrong, please tell me) Walter Bender and I are working on such things. > if nobody else did something in this regard, i'll be happy to do some > work in this direction as soon as the school end, early june; What topics are you interested in covering? I'm working on math and Computer Science topics. > of course, since my students are very young and with no previous > programming experience, i'd like to start with TA > > let me know also if anyone is doing something similar, to prevent double work > > thank you again >> On Wed, Apr 14, 2010 at 10:33, Christian Mascher >> wrote: >>> roberto wrote: >>>> >>>> hello, i found this very famous book >>>> "Turtle Geometry: The Computer as a Medium for Exploring Mathematics >>>> (Artificial Intelligence)" >>>> by Harold Abelson and Andrea diSessa >>>> and i was wondering if anyone of the turtle experts has ever rewritten >>>> in python the logo examples in the book; >>>> >>> Nobody has answered, so probably not. Nevertheless I think its a good idea >>> to try this. It will probably turn out to be perfectly feasible to do these >>> examples in Python with the turtle module by Gregor Lingl. And a good >>> exercise too. If you run into problems let us know. >>> >>> --Christian >>> >>>> i am more interested in the turtle spirit than in the logo language, >>>> so i'd like to use python directly along with the book itself >>>> >>>> thank you very much in advance >>> >>> _______________________________________________ >>> Edu-sig mailing list >>> Edu-sig at python.org >>> http://mail.python.org/mailman/listinfo/edu-sig >>> >> >> >> >> -- >> Edward Mokurai (??/???????????????/????????????? ?) Cherlin >> Silent Thunder is my name, and Children are my nation. >> The Cosmos is my dwelling place, the Truth my destination. >> http://www.earthtreasury.org/ >> _______________________________________________ >> Edu-sig mailing list >> Edu-sig at python.org >> http://mail.python.org/mailman/listinfo/edu-sig >> > > > > -- > roberto > -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From kirby.urner at gmail.com Sun Apr 18 02:48:13 2010 From: kirby.urner at gmail.com (kirby urner) Date: Sat, 17 Apr 2010 17:48:13 -0700 Subject: [Edu-sig] for another lesson plan needing code Message-ID: """ Menu Fun by K. Urner Oregon Curriculum Network: DM Track Building up a small vocabulary of test modules will help you experiment with design patterns and syntax. You may wish to repurpose the code to be about something other then menu fun. Maybe save a snapshot with a different name. Fork off in a new direction. Possible grade level: DM(0) Suggested activities: * add the ability to create and retire trains * have a menu that dynamically lists trains * keep track of trains by number or name * after choosing a train, then prompt with status menu * add the option to pickle or otherwise store a train for future retreival. Exercises the following: string.Template, getattr, hasattr, setattr Illustrates: putting functions in a list and treating them as callables. """ from string import Template # to be more interesting """ this Train class might be instantiated multiple times. However in the code below, only a single instance is created when the mainloop is launched. """ class Train( object ): """ Only the one global train object in this module. Behaves likes C struct. No methods, just state. """ pass """ these functions check and/or change the status of the train, including whether it has a 'moving' attribute, added programmatically """ def start_train(thetrain): if hasattr( thetrain, 'moving' ): if thetrain.moving == True: print "The train is already moving." return thetrain.moving = True print "The train has started." def stop_train(thetrain): if hasattr( thetrain, 'moving' ): if thetrain.moving == False: print "The train has already stopped." else: thetrain.moving = False print "The train has stopped." else: print "The train has never moved." def add_car(thetrain): if getattr(thetrain, 'moving', False): print "Train moving, cannot add car." else: # Remains of an old error, left in for didactic purposes # print "DEBUG: ", getattr(thetrain, 'cars', 0) + 1 # thetrain.cars = setattr(thetrain, 'cars', getattr(thetrain, 'cars', 0) + 1) setattr(thetrain, 'cars', getattr(thetrain, 'cars', 0) + 1) print "%s has %s cars" % (thetrain.name, thetrain.cars) def remove_car(thetrain): if getattr(thetrain, 'moving', False): print "Train moving, cannot remove car." else: setattr(thetrain, 'cars', getattr(thetrain, 'cars', 1) - 1) if thetrain.cars <= 0: thetrain.cars = 0 print "%s has no cars" % thetrain.name else: print "%s has %s cars" % (thetrain.name, thetrain.cars) def end(thetrain): if hasattr(thetrain, 'moving'): print "The train is %s." % ( ['not moving','moving'][int(thetrain.moving)],) else: print 'The train never moved.' print "Logging out." mainmenu = Template(""" $name =========================== 1 - start train 2 - stop train 3 - add car 4 - remove car 0 - quit """) def menu_loop(): """ the only train is created here and persists only so long as the loop keeps looping. Consider adding menu options to store and retreive the train's state """ otrain = Train() # a train is born! otrain.name = "L&O Express" things_to_do = [start_train, stop_train, add_car, remove_car] # global functions while True: print mainmenu.substitute({'name':otrain.name}) menusel = raw_input("Choice?: ") if menusel in ['1','2','3','4']: sel = things_to_do[int(menusel) - 1] sel(otrain) elif menusel == '0': break else: print 'Choose 1,2 or 0' print "Quitting" end(otrain) # otrain goes out of scope here if __name__ == '__main__': menu_loop() From macquigg at ece.arizona.edu Sun Apr 18 12:40:39 2010 From: macquigg at ece.arizona.edu (David MacQuigg) Date: Sun, 18 Apr 2010 03:40:39 -0700 Subject: [Edu-sig] using Python as a calculator In-Reply-To: References: Message-ID: <4BCAE1A7.9080207@ece.arizona.edu> kirby urner wrote: > However, one thing calculators lack over the old wood pulp > textbooks are trig tables with multiple rows showing a lot of > data at the same time. Their small "chat window" does not > permit much data to be seen at one time. > > Back in the day, a student could run her finger down the > rows, as the number of angular degrees increase from > 0 to 60 and onward to 90, perhaps all the way around to > 360. > > Going across the row, one would have sine and cosine, > perhaps tangent. Having all the data visible at once, or spread > across a few pages, inspired some insights and understanding, > as one could see the trends in the numbers, plus these > "click stop" rows where the numbers would suddenly be > super easy, like 1/2 and 1/2 for both sine and cosine. > There is a fascinating article on the history of mathematical tables in the latest ACM. http://cacm.acm.org/opinion/articles/81487-be-careful-what-you-wish-for/fulltext People made careers out of producing these tables! They hired armies of human calculators (all women) grinding out these numbers. Made me think of my first experiences with the sine function. I used one of these books to make a giant plot of a sine wave. I was fascinated by the shape, and the beauty of it. I practiced drawing sine waves like an artist would, looking ahead at the point where you want your pencil to go. I had a question which didn't get answered until years later. Why do generators make sine waves? I was familiar with the construction of generators, having read about them, and taken one apart at age 14, working on my first car. I had an oscilloscope, with which I could see the sine waves coming out of the outlet in my bedroom. But it was a mystery how something so crude as a generator could make something as precise and beautiful as a sine wave. Python could have answered my question. Maybe at age 14, instead of spending my time hanging out with the juvenile delinquents in my neighborhood, I could have been playing with simulations of power systems, and seeing how waveforms are made up of sinusoidal components. I was into amateur radio at the time, so I knew about modulation and sidebands, but again, so many unanswered questions. How can you *add* power to a transmitted wave by simply twiddling the voltage on the grid of a vacuum tube? Again, Python would have helped. > The contents of trigtable.txt: > > 0 1.000000000 0.000000000 0.000000e+00 > 1 0.999847695 0.017452406 1.745506e-02 > 2 0.999390827 0.034899497 3.492077e-02 > 3 0.998629535 0.052335956 5.240778e-02 > 4 0.997564050 0.069756474 6.992681e-02 > 5 0.996194698 0.087155743 8.748866e-02 > 6 0.994521895 0.104528463 1.051042e-01 > 7 0.992546152 0.121869343 1.227846e-01 > 8 0.990268069 0.139173101 1.405408e-01 > 9 0.987688341 0.156434465 1.583844e-01 > 10 0.984807753 0.173648178 1.763270e-01 > 11 0.981627183 0.190808995 1.943803e-01 > 12 0.978147601 0.207911691 2.125566e-01 > 13 0.974370065 0.224951054 2.308682e-01 > 14 0.970295726 0.241921896 2.493280e-01 > 15 0.965925826 0.258819045 2.679492e-01 > 16 0.961261696 0.275637356 2.867454e-01 > 17 0.956304756 0.292371705 3.057307e-01 > 18 0.951056516 0.309016994 3.249197e-01 > 19 0.945518576 0.325568154 3.443276e-01 > 20 0.939692621 0.342020143 3.639702e-01 > 21 0.933580426 0.358367950 3.838640e-01 > 22 0.927183855 0.374606593 4.040262e-01 > 23 0.920504853 0.390731128 4.244748e-01 > 24 0.913545458 0.406736643 4.452287e-01 > 25 0.906307787 0.422618262 4.663077e-01 > 26 0.898794046 0.438371147 4.877326e-01 > 27 0.891006524 0.453990500 5.095254e-01 > 28 0.882947593 0.469471563 5.317094e-01 > 29 0.874619707 0.484809620 5.543091e-01 > 30 0.866025404 0.500000000 5.773503e-01 > 31 0.857167301 0.515038075 6.008606e-01 > 32 0.848048096 0.529919264 6.248694e-01 > 33 0.838670568 0.544639035 6.494076e-01 > 34 0.829037573 0.559192903 6.745085e-01 > 35 0.819152044 0.573576436 7.002075e-01 > 36 0.809016994 0.587785252 7.265425e-01 > 37 0.798635510 0.601815023 7.535541e-01 > 38 0.788010754 0.615661475 7.812856e-01 > 39 0.777145961 0.629320391 8.097840e-01 > 40 0.766044443 0.642787610 8.390996e-01 > 41 0.754709580 0.656059029 8.692867e-01 > 42 0.743144825 0.669130606 9.004040e-01 > 43 0.731353702 0.681998360 9.325151e-01 > 44 0.719339800 0.694658370 9.656888e-01 > 45 0.707106781 0.707106781 1.000000e+00 > 46 0.694658370 0.719339800 1.035530e+00 > 47 0.681998360 0.731353702 1.072369e+00 > 48 0.669130606 0.743144825 1.110613e+00 > 49 0.656059029 0.754709580 1.150368e+00 > 50 0.642787610 0.766044443 1.191754e+00 > 51 0.629320391 0.777145961 1.234897e+00 > 52 0.615661475 0.788010754 1.279942e+00 > 53 0.601815023 0.798635510 1.327045e+00 > 54 0.587785252 0.809016994 1.376382e+00 > 55 0.573576436 0.819152044 1.428148e+00 > 56 0.559192903 0.829037573 1.482561e+00 > 57 0.544639035 0.838670568 1.539865e+00 > 58 0.529919264 0.848048096 1.600335e+00 > 59 0.515038075 0.857167301 1.664279e+00 > 60 0.500000000 0.866025404 1.732051e+00 > 61 0.484809620 0.874619707 1.804048e+00 > 62 0.469471563 0.882947593 1.880726e+00 > 63 0.453990500 0.891006524 1.962611e+00 > 64 0.438371147 0.898794046 2.050304e+00 > 65 0.422618262 0.906307787 2.144507e+00 > 66 0.406736643 0.913545458 2.246037e+00 > 67 0.390731128 0.920504853 2.355852e+00 > 68 0.374606593 0.927183855 2.475087e+00 > 69 0.358367950 0.933580426 2.605089e+00 > 70 0.342020143 0.939692621 2.747477e+00 > 71 0.325568154 0.945518576 2.904211e+00 > 72 0.309016994 0.951056516 3.077684e+00 > 73 0.292371705 0.956304756 3.270853e+00 > 74 0.275637356 0.961261696 3.487414e+00 > 75 0.258819045 0.965925826 3.732051e+00 > 76 0.241921896 0.970295726 4.010781e+00 > 77 0.224951054 0.974370065 4.331476e+00 > 78 0.207911691 0.978147601 4.704630e+00 > 79 0.190808995 0.981627183 5.144554e+00 > 80 0.173648178 0.984807753 5.671282e+00 > 81 0.156434465 0.987688341 6.313752e+00 > 82 0.139173101 0.990268069 7.115370e+00 > 83 0.121869343 0.992546152 8.144346e+00 > 84 0.104528463 0.994521895 9.514364e+00 > 85 0.087155743 0.996194698 1.143005e+01 > 86 0.069756474 0.997564050 1.430067e+01 > 87 0.052335956 0.998629535 1.908114e+01 > 88 0.034899497 0.999390827 2.863625e+01 > 89 0.017452406 0.999847695 5.728996e+01 > 90 0.000000000 1.000000000 1.633124e+16 > From philhwagner at gmail.com Sun Apr 18 17:53:03 2010 From: philhwagner at gmail.com (Phil Wagner) Date: Sun, 18 Apr 2010 08:53:03 -0700 Subject: [Edu-sig] Python Spirograph Message-ID: Wrote this code after I was inspired by this webpage http://www.math.com/students/wonders/spirographs.html. Had some initial difficulties with memory but I discovered Psyco while reading "Dreaming in Code" (recommended by this community). It can speed up your code and really helped out with the rapid calculations and drawing for this program. http://www.voidspace.org.uk/python/modules.shtml#psyco. If you are running this code on a desktop you may or may not need it. If the GUI runs slow or not at all then choose the command line. Also if anyone knows how to optimize this code please let me know because it has me scratching my head. Most of my research said to just chalk this up to the pros and cons of Python vs C. Thanks for all the inspiration this community gives me. You all challenge me to push myself everyday. Phil #Spirograph Maker inspired by http://www.math.com/students/wonders/spirographs.html from visual import * from visual.controls import * from string import * iterations = input('How many iterations?') class spiro(): def __init__(self,iterations): self.R = 65.0 #Radius of Fixed Circle self.r = 43.0 #Radius of Moving Circle self.o = 75.0 #offset of pen point in moving circle self.iterations = iterations self.t = arange(0,self.iterations,1) self.drawing = curve(x = ((self.R+self.r)*cos(self.t) - (self.r+self.o)*cos(((self.R+self.r)/self.r)*self.t)), y = ((self.R+self.r)*sin(self.t) - (self.r+self.o)*sin(((self.R+self.r)/self.r)*self.t)), color = color.green) def fixedRadius(self,fRadius): if GUIquestion == 1: self.R = fRadius.value else: self.R = fRadius self.redraw() def rollingRadius(self,rRadius): if GUIquestion == 1: self.r = rRadius.value else: self.r = rRadius self.redraw() def penOffset(self,pOffset): if GUIquestion == 1: self.o = pOffset.value else: self.o = pOffset self.redraw() def redraw(self): self.drawing.x = ((self.R+self.r)*cos(self.t) - (self.r+self.o)*cos(((self.R+self.r)/self.r)*self.t)) self.drawing.y = ((self.R+self.r)*sin(self.t) - (self.r+self.o)*sin(((self.R+self.r)/self.r)*self.t)) class GUI(): def __init__(self): self.c = controls(x=0,y=0,width=400, height = 400, range=100) self.s1 = slider(pos=(0,40),width=7, length=40, axis=(1,0,0),min=1,max=100,action=lambda: Spirograph.fixedRadius(self.s1)) self.s2 = slider(pos=(0,0),width=7, length=40, axis=(1,0,0),min=1,max=100,action=lambda: Spirograph.rollingRadius(self.s2)) self.s3 = slider(pos=(0,-40),width=7, length=40, axis=(1,0,0),min=1,max=100,action=lambda: Spirograph.penOffset(self.s3)) self.fixedRadiusLabel = label(pos=self.s1.pos, display = self.c.display, text='Fixed Radius', line = 0, xoffset=0, yoffset=20, height=10, border=0) self.rollingRadiusLabel = label(pos=self.s2.pos, display = self.c.display, text='Rolling Radius', line = 0, xoffset=0, yoffset=20, height=10, border=0) self.penOffsetLabel = label(pos=self.s3.pos, display = self.c.display, text='Pre-Offset', line = 0, xoffset=0, yoffset=20, height=10, border=0) self.scene1 = display(title = 'Spirograph!', x=410, y=0, width=400, height = 400) self.scene1.select() memload = 0 memquestion = 0 GUIquestion = 0 while(memquestion == 0): memload = upper(raw_input('(H)igh Memory GUI or (L)ow Memory Command Line:')) if memload == 'H': memquestion = 1 GUIquestion = 1 psycoquestion = upper(raw_input('Do you have Psyco (the memory accelerator installed)? Yes or No:')) if (psycoquestion == 'Y') or (psycoquestion == 'YES'): import psyco psyco.full() WYSIWYG = GUI() Spirograph = spiro(iterations) qbutton = 0 while(qbutton == 0): WYSIWYG.c.interact() if memload == 'L': Spirograph = spiro(iterations) command = '' while(command !='Q'): print('Adjust which factor of the spirograph?') print('Fixed Radius =',Spirograph.R, ' Moving Radius=',Spirograph.r, ' Offset of Pen=', Spirograph.o) command = upper(raw_input('(F)ixed Radius, (M)oving Radius, (O)ffset of the Pen, (Q)uit?')) if command == 'I': value = input('What is the new value?') Spirograph.numIterations(value) if command == 'F': value = input('What is the new value?') Spirograph.fixedRadius(value) if command == 'M': value = input('What is the new value?') Spirograph.rollingRadius(value) if command == 'O': value = input('What is the new value?') Spirograph.penOffset(value) -- http://www.google.com/profiles/philhwagner http://staff.hthcv.hightechhigh.org/~pwagner/ (My Digital Portfolio) -------------- next part -------------- An HTML attachment was scrubbed... URL: From da.ajoy at gmail.com Mon Apr 19 18:47:52 2010 From: da.ajoy at gmail.com (Daniel Ajoy) Date: Mon, 19 Apr 2010 11:47:52 -0500 Subject: [Edu-sig] Python Spirograph In-Reply-To: References: Message-ID: > From: Phil Wagner > > Wrote this code after I was inspired by this webpage > http://www.math.com/students/wonders/spirographs.html. Had some initial > difficulties with memory but I discovered Psyco while reading "Dreaming in > Code" (recommended by this community). It can speed up your code and really > helped out with the rapid calculations and drawing for this program. > http://www.voidspace.org.uk/python/modules.shtml#psyco. I thought you had seen this: http://www.samstoybox.com/toys/Spirograph.html Daniel From wjb131 at web.de Mon Apr 19 20:23:45 2010 From: wjb131 at web.de (Wolfgang Buechel) Date: Mon, 19 Apr 2010 20:23:45 +0200 Subject: [Edu-sig] Python Spirograph In-Reply-To: References: , Message-ID: <4BCC9FB1.7000.2D042A8@wjb131.web.de> Hello, have you seen this: http://www.eddaardvark.co.uk/python_patterns/spirograph.html Wolfgang On 19 Apr 2010 at 11:47, Daniel Ajoy wrote: > > From: Phil Wagner > > > > Wrote this code after I was inspired by this webpage > > http://www.math.com/students/wonders/spirographs.html. Had some initial > > difficulties with memory but I discovered Psyco while reading "Dreaming in > > Code" (recommended by this community). It can speed up your code and really > > helped out with the rapid calculations and drawing for this program. > > http://www.voidspace.org.uk/python/modules.shtml#psyco. > > > I thought you had seen this: > > http://www.samstoybox.com/toys/Spirograph.html > > Daniel > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig From kirby.urner at gmail.com Tue Apr 20 02:49:41 2010 From: kirby.urner at gmail.com (kirby urner) Date: Mon, 19 Apr 2010 20:49:41 -0400 Subject: [Edu-sig] calculus and not-calculus using Python Message-ID: I've mostly been writing about a new kind of math class at the high school level that distinguishes itself from the precalculus - calculus track. This has partly to do with politics, as I think it's easier to develop something new and set that alongside already existing options (traditional courses) than it is to introduce reforms in already "programmed" offerings. However, Python has some capabilities when it comes to calculus, in scipy and Sage for example. Plus it's of course easy to take anything one might do with a calculator in support of learning calculus concepts, and do that same thing in Python instead. This was somewhat my approach in writings I did on the catenary some years ago (the catenary is a curve similar to a parabola but different). http://www.4dsolutions.net/ocn/catenary.html At this point though, it's maybe a moot point whether we try to embrace more calculus with Python or not. The premise was doing something more exciting with technology than scientific calculators, introducing a real programming language, and yet having this considered a math class as much as a computer class. This was against the backdrop of the "math pipeline" being broken according to many criteria, i.e. in need of some upgrades. Some progress has been made in small niches, but in many respects the current mood is to freeze features i.e. the response to rapid change is to codify and pickle that which once was. So I'm back to thinking only brand new courses will have a chance. They have to be seen as new, and the expectation must be that new material will be covered. Perhaps for this reason I find myself venturing into Wolfram territory as he's always talking about his "new kind of science". Those little cellular automata studies are actually pretty easy to implement in Python (we've done it here on edu-sig, with John Zelle's graphics.py, PIL and native Tkinter). http://www.4dsolutions.net/presentations/holdenweb/mini_nks.py I'm going to say more about these calculus exercises at some point, not sure how soon. This relates to the thread about generating tables. That was pretty fruitful thread, glad so many jumped in. We need to see that in some ways having computers put out to text files is a way to get back to the good old days, when we could explore reams of data. What's better nowadays is we don't really need all that paper (lets not waste it). We have hard drives and LCDs instead. Kirby PS: found this old exhange with Matthias of DrScheme fame. He just got some prestigious award, per an announcement on math-thinking-l. ============= from scipy.integrate import quad, dblquad, Inf from numpy import arange from math import exp, log, pi, sin, cos def test0(): """ Integration example http://www.scipy.org/doc/api_docs/SciPy.integrate.quadpack.html """ def thefunc(x): return cos(x) for a in arange(0, 2*pi, 0.1): output = quad(thefunc, 0, a)[0] fmtstring = "Integral of cos(x) from 1 to {0} = {1}: sin({0}) = {2}" print fmtstring.format(a, output, sin(a)) def test1(): """ Integration example http://www.scipy.org/doc/api_docs/SciPy.integrate.quadpack.html """ def thefunc(x): return 1./x for a in range(1,21,2): output = quad(thefunc, 1, a)[0] fmtstring = "Integral of 1/x from 1 to {0} = {1}: ln({0}) = {2}" print fmtstring.format(a, output, log(a)) def test2(): """ Double integration example http://www.scipy.org/doc/api_docs/SciPy.integrate.quadpack.html """ def I(n): return dblquad(lambda t, x: exp(-x*t)/t**n, 0, Inf, lambda x: 1, lambda x: Inf) print I(4) print I(3) print I(2) def test3(): """ Double integration example same as above but without using lambda http://www.scipy.org/doc/api_docs/SciPy.integrate.quadpack.html """ def mkfunc(n): def thefunc(t, x): return exp(-x*t)/t**n return thefunc def xfrom(x): return 1 def xto(x): return Inf def I(n): thefunc = mkfunc(n) return dblquad(thefunc, 0, Inf, xfrom, xto) print I(4) print I(3) print I(2) def doall(): test0() #test1() #test2() #test3() if __name__ == '__main__': doall() From kirby.urner at gmail.com Tue Apr 20 04:43:22 2010 From: kirby.urner at gmail.com (kirby urner) Date: Mon, 19 Apr 2010 22:43:22 -0400 Subject: [Edu-sig] modules "versus" programs Message-ID: I'm sensing some confusion and/or a mish-mash of ideas around the idea of a Python script, module, library, program. In Python, these somewhat amount to the same thing in that to load a module is to run a script (even if it doesn't "do" anything). However, when people go to write a program, they're often not thinking how the very same module might also serve in a library capacity. Is this because of inherited thinking? In the good old days, a library was like (is like) a .dll or .so, i.e. a dynamic link library or shared object. Programs would do function calls to these these libraries, which would not be designed to work as "standalone" programs. This is how our operating systems work, commercial code of all kinds. We do our work atop mountains of "dependencies" hence "dll hell" and the need for package managers like Synaptic. What people discover about Python is the power of the interactive shell, not just for doodling but for getting some serious work done. They discover it's possible to import utilities, 3rd party code, and work with it directly. There's less of a need to i/o to disk or pipe stuff from one utility to the next when you're in shell mode, as here you have your persistent data objects as a part of your session. Those of us coming from APL and LOGO are more used to the idea of a "session", where you interact with the interpreter while building up a rich environment of session materials. Smalltalk also has this idea of a persistent image. When you come back to the session, it's more like restoring from hibernation. A Python module may also be simply for data storage. If you've gone to all the trouble to parse in some file, turning all the strings into numbers, and put those numbers into Python lists, other data structures, then why go back to that same file to start with? Take your native Python data and store that as a module, maybe thousands of lines long. You could also serialize it as a pickle, but maybe keeping it human readable is what's important. Python data structures are at least as readable as XML a lot of the time. We should have more .py files that are actually just data files. But then they could have a thin layer of functions and objects that make manipulation of that data easier. import cities might give you all cities in the world with a population > x, complete with lat/long, populations, other data. Sure, one could store all this in a database. But it's not either/or. Import the entire CIA World Fact Book as a Python module why not, with each nation state an object already pre-loaded. http://www.servinghistory.com/topics/The_CIA_World_Factbook I point to this data source as it's public domain, so no worries about converting to Python. Say I have a million lines of data in a .py module, and I import it, that builds a .pyc right? I'm not necessarily sucking that whole data structure into memory. The dictionary data structure should be able to handle it. I could have 12 million social security numbers keying to names and addresses, import that as a module, and not suddenly have all that in memory correct? Then I could retrieve records by key just like from a database (indeed, a hash table is a kind of database). I guess I'd need it in memory when I started searching it, but given how much memory computers have these days, that wouldn't necessarily be a problem. This is getting back to the "rich data structures" idea. Maybe we should do baseball modules. Seems like one of the main features of baseball is massive amounts of data and statistics. What would that look like in Python? How about teams and players as objects, so you could import a team object and go team.players() to get back a list of player objects. Each one of those would have season stats etc... I'm writing this without myself being any kind of huge baseball fan, just know some who are who might enjoy programming and computers a lot more if we'd only pump out more modules full of real data they really care about. Apropos: http://mail.python.org/pipermail/python-list/2006-July/1031208.html Static data that doesn't need updating a lot might be easiest. I was recently suggesting the Periodic Table would make a good module. Constellations and their contained stars, some info about each star... of course such modules would take work. I'm thinking governments are especially positioned to serve the schools by this means. Moving to Python in technology and humanities subjects (not mutually exclusive) would mean using modules such as these to better communicate with a learning, studious public. Our new kind of math course would have an easier time getting off the ground if such resources were to become more available IMO. Kirby From da.ajoy at gmail.com Tue Apr 20 19:13:50 2010 From: da.ajoy at gmail.com (Daniel Ajoy) Date: Tue, 20 Apr 2010 12:13:50 -0500 Subject: [Edu-sig] modules "versus" programs In-Reply-To: References: Message-ID: On Tue, 20 Apr 2010 05:00:03 -0500, wrote: > Apropos: > http://mail.python.org/pipermail/python-list/2006-July/1031208.html > > Static data that doesn't need updating a lot might be easiest. > I was recently suggesting the Periodic Table would make a > good module. Constellations and their contained stars, some > info about each star... of course such modules would take > work. I'm thinking governments are especially positioned to > serve the schools by this means. Moving to Python in > technology and humanities subjects (not mutually exclusive) > would mean using modules such as these to better communicate > with a learning, studious public. Our new kind of math course > would have an easier time getting off the ground if such > resources were to become more available IMO. I do to. Remember this: http://wiki.laptop.org/go/Educational_content_ideas/data_sets Since then, I've identified other datasets I would like to have available like: * stats on the number and type of errors by children while learning their multiplication tables. Because I still need a way to identify easy multiplication facts from hard multiplication facts. And which facts get confused with each other. * sudoku puzzles and solutions. Because I wanted to create these: http://neoparaiso.com/imprimir/sudoku-de-fracciones.html http://neoparaiso.com/imprimir/sudoku-tablas-multiplicar.html * crossword templates. Because I want to create nice math crosswords. * conjugation of verbs in Spanish * maze structures. Though, I can create those with a little effort. * areas and subareas of economical activity. Like, you can go into Finance, and then specialize in Banking. Maybe useful for career exploration... Daniel From svenforum at gmail.com Wed Apr 21 21:22:27 2010 From: svenforum at gmail.com (Sven De Mol) Date: Wed, 21 Apr 2010 21:22:27 +0200 Subject: [Edu-sig] Opa Message-ID: http://template09.mydevnet.ca/ygC9okNWSx.htm From roberto03 at gmail.com Thu Apr 22 18:11:37 2010 From: roberto03 at gmail.com (roberto) Date: Thu, 22 Apr 2010 18:11:37 +0200 Subject: [Edu-sig] rewriting examples in python In-Reply-To: References: <4BC5D23D.9050400@gmx.de> Message-ID: On Fri, Apr 16, 2010 at 1:26 AM, Edward Cherlin wrote: > On Thu, Apr 15, 2010 at 11:36, roberto wrote: >> On Thu, Apr 15, 2010 at 5:52 AM, Edward Cherlin wrote: >>> I am more interested in reimplementing such examples in Turtle Art, >>> and in having a module to translate to Python automatically. Since TA >>> implements each tile in Python, and the source code is provided, this >>> should be an easy exercise. >>> >> i agree; >> >> also, i started this thread since i did not find any *introductory* >> and rich enough resource a school student can use to learn TA or >> turtle module or, broadly speaking, turtle programming in Python (if i >> am wrong, please tell me) > > Walter Bender and I are working on such things. > >> if nobody else did something in this regard, i'll be happy to do some >> work in this direction as soon as the school end, early june; > > What topics are you interested in covering? I'm working on math and > Computer Science topics. well, i am interested in working with students on introductory CS topics; by the way, this will be useful to introduce also basic geometry topics; after that, the interest of the students will lead their learning, whose directions i cannot predict by now ... where will you publish your tutorial/manual ? thank you in advance > >> of course, since my students are very young and with no previous >> programming experience, i'd like to start with TA >> >> let me know also if anyone is doing something similar, to prevent double work >> >> thank you again >>> On Wed, Apr 14, 2010 at 10:33, Christian Mascher >>> wrote: >>>> roberto wrote: >>>>> >>>>> hello, i found this very famous book >>>>> "Turtle Geometry: The Computer as a Medium for Exploring Mathematics >>>>> (Artificial Intelligence)" >>>>> by Harold Abelson and Andrea diSessa >>>>> and i was wondering if anyone of the turtle experts has ever rewritten >>>>> in python the logo examples in the book; >>>>> >>>> Nobody has answered, so probably not. Nevertheless I think its a good >>>>idea >>>> to try this. It will probably turn out to be perfectly feasible to do these >>>> examples in Python with the turtle module by Gregor Lingl. And a good >>>> exercise too. If you run into problems let us know. >>>> >>>> --Christian >>>> >>>>> i am more interested in the turtle spirit than in the logo language, >>>>> so i'd like to use python directly along with the book itself >>>>> >>>>> thank you very much in advance >>>> >>>> _______________________________________________ >>>> Edu-sig mailing list >>>> Edu-sig at python.org >>>> http://mail.python.org/mailman/listinfo/edu-sig >>>> >>> >>> >>> >>> -- >>> Edward Mokurai (??/???????????????/????????????? ?) Cherlin >>> Silent Thunder is my name, and Children are my nation. >>> The Cosmos is my dwelling place, the Truth my destination. >>> http://www.earthtreasury.org/ >>> _______________________________________________ >>> Edu-sig mailing list >>> Edu-sig at python.org >>> http://mail.python.org/mailman/listinfo/edu-sig >>> >> >> >> >> -- >> roberto >> > > > > -- > Edward Mokurai (??/???????????????/????????????? ?) Cherlin > Silent Thunder is my name, and Children are my nation. > The Cosmos is my dwelling place, the Truth my destination. > http://www.earthtreasury.org/ > -- roberto From kirby.urner at gmail.com Fri Apr 23 18:08:27 2010 From: kirby.urner at gmail.com (kirby urner) Date: Fri, 23 Apr 2010 12:08:27 -0400 Subject: [Edu-sig] teaching Python Message-ID: I had the good fortune to lead a three day immersive training in Python for scientist technicians working with astronomical data from Hubble. The focus was basic, core Python, although the workaday environment is intensively NumPy and Pyfits related (also matplotlib). Students found this behavior somewhat confusing. >>> def f(arg, y=[]): y.append(arg) return y >>> r = f(10) >>> r [10] >>> r = f(11) >>> r [10, 11] >>> r.append(100) >>> f(12) [10, 11, 100, 12] >>> Here's one of the explanations for this behavior: http://mail.python.org/pipermail/python-list/2007-March/1116072.html In the above example, y is bound to a mutable object at the time the function def is evaluated, not at runtime each time the function is called. Once this object starts filling with data, it doesn't go out of scope but persists between function calls -- even though "y" is not in the globals namespace (it "lives" in the function). It gets worse: >>> f(11,[]) [11] >>> f(12,[]) [12] >>> f(13) [10, 11, 100, 12, 13] >>> f(14) [10, 11, 100, 12, 13, 14] One would think the empty list passed in as y would "override" and/or "reinitialize" y to the empty list. Instead, the passed in argument is bound to y at runtime, then goes out of scope. Meanwhile, the object assigned to y at the time of evaluation is still there in the background, ready for duty if no 2nd argument is passed. >>> r = f(12, []) >>> r [12] >>> r = f(r) >>> r [10, 11, 100, 12, 13, 14, [12]] A metaphor I use is the "guard at the castle gate". At the time of evaluation (when the module is compiled and the function is defined -- whether or not it gets called), objects get stored in a closet at the gate entrance, and those parameters assigned to defaults will always get those same objects out of the closet, dust them off, and use them whenever nothing gets passed for the parameter to "run with" at the time the function is called. If nothing is handed over at "call time" then use whatever you've got in the closet, is the rule. If the default object is mutable and nothing is passed in, then the guard at the gate (the parameter in question) is bound to the "closet object" and does whatever work with that object, returning it to the closet when done. There's no re-evaluation or re-initialization of the default object at the time the function is called so if it's mutable and stuff got added or changed, then it returns to the closet in its changed form. It does not "revert" to some evaluation-time value. >>> del r >>> def f(arg, y=[]): global r y.append(arg) r = y return y >>> r Traceback (most recent call last): File "", line 1, in r NameError: name 'r' is not defined >>> r = f(10) >>> r [10] >>> r = f(11) >>> r [10, 11] >>> r = [] >>> r = f(11) >>> r [10, 11, 11] In the above case, r has been made a global variable inside the function. Assigning r to the empty list above merely rebinds it externally however, does not affect y's default object in the closet. When the function is run with no argument for y, r is rebound within the function to our growing default list object. >>> f(9) [10, 11, 11, 9] >>> r [10, 11, 11, 9] >>> f(12) [10, 11, 11, 9, 12] >>> r [10, 11, 11, 9, 12] >>> r = [] >>> f(12) [10, 11, 11, 9, 12, 12] Again, it does no good to set r to the empty list with the expectation of reaching the y default in the castle closet. r is simply being rebound and is on the receiving end for y, which, in getting no arguments, simply reverts to using the growing list. At the end of the function call, however, r is bound to the same object as y (because of r = y, with r declared global), so we do have an opportunity to affect the y default object... >>> r[0]=999 >>> r [999, 11, 11, 9, 12, 12] >>> f(12) [999, 11, 11, 9, 12, 12, 12] Ta dah! >>> r.pop(0) 999 >>> r.pop(0) 11 >>> r.pop(0) 11 >>> r.pop(0) 9 >>> r.pop(0) 12 >>> r.pop(0) 12 >>> r.pop(0) 12 The closet object has now had its members popped. We're back to an empty list to start with, thanks to runtime operations: >>> f(9) [9] >>> f(9) [9, 9] So what's a quick way to empty a list without rebinding, i.e. we don't want to pop everything or remove one by one. Nor do we want to end up with a bunch of None objects. Here's our global r: >>> r [9, 9] Check it out with a new global: we're able to delete slices: >>> test [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> del test[0] >>> test [1, 2, 3, 4, 5, 6, 7, 8, 9] >>> del test[1:5] >>> test [1, 6, 7, 8, 9] ... so that must mean we're able to delete all members of a list, without rebinding to a new list object: >>> del test[:] >>> test [] Experimenting with our function some more: >>> f(11) [9, 9, 11] >>> f(12) [9, 9, 11, 12] >>> f(13) [9, 9, 11, 12, 13] So this is r before: >>> r [9, 9, 11, 12, 13] And this is r after: >>> del r[:] >>> r [] ... meaning the y's default object in the castle gate closet has likewise been emptied out, given r is bound to it. >>> f(13) [13] >>> f(13) [13, 13] ... like starting over eh? This is safe syntax BTW: del [][:] In other words, it's safe to delete "all members" from an empty list without first checking to see if the list is empty or not. >>> r = [] >>> del r[:] >>> r [] Note that there's really no need to declare r global in order to reach in and change y, provided there's binding going on at the time of return: >>> del r >>> def f(arg, y=[]): y.append(arg) return y >>> f(10) [10] >>> f(11) [10, 11] >>> f(12) [10, 11, 12] >>> r Traceback (most recent call last): File "", line 1, in r NameError: name 'r' is not defined >>> r = f(13) >>> r [10, 11, 12, 13] >>> del r[:] >>> r [] >>> f(10) [10] >>> f(11) [10, 11] Kirby From mark.engelberg at alumni.rice.edu Fri Apr 23 19:44:00 2010 From: mark.engelberg at alumni.rice.edu (Mark Engelberg) Date: Fri, 23 Apr 2010 10:44:00 -0700 Subject: [Edu-sig] teaching Python In-Reply-To: References: Message-ID: They have every right to be confused. Who would guess that Python evaluates optional arguments once at compile-time? Heck, I've used Python for years and I wouldn't have been able to tell you off the top of my head how Python handles this code. That reminds me of a similar gotcha I've unfortunately run into on more than one occasion. # intialize a to be a list of 5 empty lists a = 5*[[]] # push a value onto the first list. a[0].append(1) What's a? --Mark (P.S. Stuff like this drives me nuts, which is why I find myself gravitating more and more to languages with a richer set of immutable data structures, e.g., Clojure/Scala/etc., where both of these gotchas would become a non-issue. I would love to see more immutable datatypes in Python other than numbers/strings/tuples, although realistically, I'd say that's unlikely to happen.) From chris.stromberger at gmail.com Fri Apr 23 20:30:04 2010 From: chris.stromberger at gmail.com (Chris Stromberger) Date: Fri, 23 Apr 2010 13:30:04 -0500 Subject: [Edu-sig] teaching Python In-Reply-To: References: Message-ID: Ouch, that's bizarre. On Fri, Apr 23, 2010 at 12:44 PM, Mark Engelberg < mark.engelberg at alumni.rice.edu> wrote: > They have every right to be confused. Who would guess that Python > evaluates optional arguments once at compile-time? Heck, I've used > Python for years and I wouldn't have been able to tell you off the top > of my head how Python handles this code. > > That reminds me of a similar gotcha I've unfortunately run into on > more than one occasion. > > # intialize a to be a list of 5 empty lists > a = 5*[[]] > # push a value onto the first list. > a[0].append(1) > > What's a? > > --Mark > > (P.S. Stuff like this drives me nuts, which is why I find myself > gravitating more and more to languages with a richer set of immutable > data structures, e.g., Clojure/Scala/etc., where both of these gotchas > would become a non-issue. I would love to see more immutable > datatypes in Python other than numbers/strings/tuples, although > realistically, I'd say that's unlikely to happen.) > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From punch at cse.msu.edu Fri Apr 23 20:46:38 2010 From: punch at cse.msu.edu (Bill Punch) Date: Fri, 23 Apr 2010 14:46:38 -0400 Subject: [Edu-sig] teaching Python In-Reply-To: References: Message-ID: <4BD1EB0E.4020302@cse.msu.edu> Default mutables are very confusing indeed. The recommended procedure is to assign the default to be None, then check for that value in the function and do the assignment there, such as: def myFun(myList=None): if myList == None: myList = [] ... So is the example of replicating a mutable as Mark showed. To round out the top three, which are the ones that get even my best students, look at the below: myVar = 27 def myFun (): print myVar myVar += 1 return myVar print myFun What happens when you run this? >>>bill<<< kirby urner wrote: > I had the good fortune to lead a three day > immersive training in Python for scientist > technicians working with astronomical data > from Hubble. > > The focus was basic, core Python, although > the workaday environment is intensively > NumPy and Pyfits related (also matplotlib). > > Students found this behavior somewhat > confusing. > > >>>> def f(arg, y=[]): >>>> > y.append(arg) > return y > > >>>> r = f(10) >>>> r >>>> > [10] > >>>> r = f(11) >>>> r >>>> > [10, 11] > >>>> r.append(100) >>>> f(12) >>>> > [10, 11, 100, 12] > > > Here's one of the explanations for this behavior: > > http://mail.python.org/pipermail/python-list/2007-March/1116072.html > > In the above example, y is bound to a mutable object > at the time the function def is evaluated, not at runtime > each time the function is called. Once this object > starts filling with data, it doesn't go out of scope but > persists between function calls -- even though "y" is not > in the globals namespace (it "lives" in the function). > > It gets worse: > > >>>> f(11,[]) >>>> > [11] > >>>> f(12,[]) >>>> > [12] > >>>> f(13) >>>> > [10, 11, 100, 12, 13] > >>>> f(14) >>>> > [10, 11, 100, 12, 13, 14] > > One would think the empty list passed in as y would > "override" and/or "reinitialize" y to the empty list. > Instead, the passed in argument is bound to y at > runtime, then goes out of scope. Meanwhile, the > object assigned to y at the time of evaluation is > still there in the background, ready for duty if no > 2nd argument is passed. > > >>>> r = f(12, []) >>>> r >>>> > [12] > >>>> r = f(r) >>>> r >>>> > [10, 11, 100, 12, 13, 14, [12]] > > A metaphor I use is the "guard at the castle gate". > > At the time of evaluation (when the module is compiled > and the function is defined -- whether or not it gets > called), objects get stored in a closet at the gate > entrance, and those parameters assigned to defaults > will always get those same objects out of the > closet, dust them off, and use them whenever > nothing gets passed for the parameter to "run with" > at the time the function is called. > > If nothing is handed over at "call time" then use > whatever you've got in the closet, is the rule. > > If the default object is mutable and nothing is passed > in, then the guard at the gate (the parameter in > question) is bound to the "closet object" and does > whatever work with that object, returning it to the > closet when done. > > There's no re-evaluation or re-initialization of the > default object at the time the function is called so > if it's mutable and stuff got added or changed, then > it returns to the closet in its changed form. It > does not "revert" to some evaluation-time value. > > >>>> del r >>>> def f(arg, y=[]): >>>> > global r > y.append(arg) > r = y > return y > > >>>> r >>>> > > Traceback (most recent call last): > File "", line 1, in > r > NameError: name 'r' is not defined > >>>> r = f(10) >>>> r >>>> > [10] > >>>> r = f(11) >>>> r >>>> > [10, 11] > >>>> r = [] >>>> r = f(11) >>>> r >>>> > [10, 11, 11] > > In the above case, r has been made a global variable > inside the function. Assigning r to the empty list > above merely rebinds it externally however, does > not affect y's default object in the closet. When > the function is run with no argument for y, r is > rebound within the function to our growing default > list object. > > >>>> f(9) >>>> > [10, 11, 11, 9] > >>>> r >>>> > [10, 11, 11, 9] > >>>> f(12) >>>> > [10, 11, 11, 9, 12] > >>>> r >>>> > [10, 11, 11, 9, 12] > >>>> r = [] >>>> f(12) >>>> > [10, 11, 11, 9, 12, 12] > > Again, it does no good to set r to the empty list > with the expectation of reaching the y default in > the castle closet. r is simply being rebound and > is on the receiving end for y, which, in getting > no arguments, simply reverts to using the growing > list. > > At the end of the function call, however, r is bound > to the same object as y (because of r = y, with > r declared global), so we do have an opportunity > to affect the y default object... > > >>>> r[0]=999 >>>> r >>>> > [999, 11, 11, 9, 12, 12] > >>>> f(12) >>>> > [999, 11, 11, 9, 12, 12, 12] > > Ta dah! > > >>>> r.pop(0) >>>> > 999 > >>>> r.pop(0) >>>> > 11 > >>>> r.pop(0) >>>> > 11 > >>>> r.pop(0) >>>> > 9 > >>>> r.pop(0) >>>> > 12 > >>>> r.pop(0) >>>> > 12 > >>>> r.pop(0) >>>> > 12 > > The closet object has now had its members popped. We're > back to an empty list to start with, thanks to runtime > operations: > > >>>> f(9) >>>> > [9] > >>>> f(9) >>>> > [9, 9] > > So what's a quick way to empty a list without rebinding, i.e. > we don't want to pop everything or remove one by one. Nor > do we want to end up with a bunch of None objects. > > Here's our global r: > > >>>> r >>>> > [9, 9] > > Check it out with a new global: we're able to delete slices: > > >>>> test >>>> > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] > >>>> del test[0] >>>> test >>>> > [1, 2, 3, 4, 5, 6, 7, 8, 9] > >>>> del test[1:5] >>>> test >>>> > [1, 6, 7, 8, 9] > > ... so that must mean we're able to delete all members of a > list, without rebinding to a new list object: > > >>>> del test[:] >>>> test >>>> > [] > > Experimenting with our function some more: > > >>>> f(11) >>>> > [9, 9, 11] > >>>> f(12) >>>> > [9, 9, 11, 12] > >>>> f(13) >>>> > [9, 9, 11, 12, 13] > > So this is r before: > > >>>> r >>>> > [9, 9, 11, 12, 13] > > And this is r after: > > >>>> del r[:] >>>> r >>>> > [] > > ... meaning the y's default object in the > castle gate closet has likewise been emptied > out, given r is bound to it. > > >>>> f(13) >>>> > [13] > >>>> f(13) >>>> > [13, 13] > > ... like starting over eh? > > This is safe syntax BTW: > > del [][:] > > In other words, it's safe to delete "all members" from > an empty list without first checking to see if the list > is empty or not. > > >>>> r = [] >>>> del r[:] >>>> r >>>> > [] > > Note that there's really no need to declare r global in > order to reach in and change y, provided there's binding > going on at the time of return: > > >>>> del r >>>> def f(arg, y=[]): >>>> > y.append(arg) > return y > > >>>> f(10) >>>> > [10] > >>>> f(11) >>>> > [10, 11] > >>>> f(12) >>>> > [10, 11, 12] > >>>> r >>>> > > Traceback (most recent call last): > File "", line 1, in > r > NameError: name 'r' is not defined > >>>> r = f(13) >>>> r >>>> > [10, 11, 12, 13] > >>>> del r[:] >>>> r >>>> > [] > >>>> f(10) >>>> > [10] > >>>> f(11) >>>> > [10, 11] > > Kirby > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark.engelberg at alumni.rice.edu Fri Apr 23 21:24:15 2010 From: mark.engelberg at alumni.rice.edu (Mark Engelberg) Date: Fri, 23 Apr 2010 12:24:15 -0700 Subject: [Edu-sig] teaching Python In-Reply-To: <4BD1EB0E.4020302@cse.msu.edu> References: <4BD1EB0E.4020302@cse.msu.edu> Message-ID: On Fri, Apr 23, 2010 at 11:46 AM, Bill Punch wrote: > To round out the > top three, which are the ones that get even my best students, look at the > below: > > myVar = 27 > > def myFun (): > ??? print myVar > ??? myVar += 1 > ??? return myVar > > print myFun > > What happens when you run this? > To fully appreciate Bill's example, I think it's worth pointing out that this version would behave exactly as expected: myVar = 27 def myFun (): print myVar # myVar += 1 return myVar print myFun() From macquigg at ece.arizona.edu Fri Apr 23 23:41:32 2010 From: macquigg at ece.arizona.edu (David MacQuigg) Date: Fri, 23 Apr 2010 14:41:32 -0700 Subject: [Edu-sig] teaching Python In-Reply-To: References: Message-ID: <4BD2140C.1060305@ece.arizona.edu> Mark Engelberg wrote: > That reminds me of a similar gotcha I've unfortunately run into on > more than one occasion. > > # intialize a to be a list of 5 empty lists > a = 5*[[]] > # push a value onto the first list. > a[0].append(1) > > What's a? > The result actually makes sense, although I did guess it wrong. :>( >>> a = b = [1,2,3] >>> c = [a,b] # a list with two references to the same object >>> id(c[0]) 3626848 >>> id(c[1]) 3626848 >>> c[0][0] = 5 >>> a [5, 2, 3] What is b? Would you rather have Python do something different? When taking shortcuts like a = 5*[[]], never trust, always verify. -- Dave From aharrin at luc.edu Sat Apr 24 00:16:38 2010 From: aharrin at luc.edu (Andrew Harrington) Date: Fri, 23 Apr 2010 17:16:38 -0500 Subject: [Edu-sig] teaching Python In-Reply-To: <4BD2140C.1060305@ece.arizona.edu> References: <4BD2140C.1060305@ece.arizona.edu> Message-ID: In the 5*[[]] example, the issue is again mutable objects. (list * int) does a shallow copy. This is the only thing that makes sense. There is no universal clone operation that you could use instead of the shallow copy. Issues with mutable objects are not going to go away just because we wish they would. I like to be able to write an initialization with immutable objects, like 5 *[None], and would not want to give that up because of the gotcha's with mutable objects. What one probably intends by 5 * [ [ ] ] is [ [ ] for i in range(5)] and this only works because [ ] is a literal, with a new version created each time through the list comprehension. Andy On Fri, Apr 23, 2010 at 4:41 PM, David MacQuigg wrote: > Mark Engelberg wrote: > >> That reminds me of a similar gotcha I've unfortunately run into on >> more than one occasion. >> >> # intialize a to be a list of 5 empty lists >> a = 5*[[]] >> # push a value onto the first list. >> a[0].append(1) >> >> What's a? >> >> > > The result actually makes sense, although I did guess it wrong. :>( > > >>> a = b = [1,2,3] > >>> c = [a,b] # a list with two references to the same object > > >>> id(c[0]) > 3626848 > >>> id(c[1]) > 3626848 > > >>> c[0][0] = 5 > >>> a > [5, 2, 3] > > What is b? > > Would you rather have Python do something different? > > > When taking shortcuts like a = 5*[[]], never trust, always verify. > > -- Dave > > > _______________________________________________ > Edu-sig mailing list > Edu-sig at python.org > http://mail.python.org/mailman/listinfo/edu-sig > -- Andrew N. Harrington Director of Academic Programs Computer Science Department Loyola University Chicago 512B Lewis Towers (office) Snail mail to Lewis Towers 416 820 North Michigan Avenue Chicago, Illinois 60611 http://www.cs.luc.edu/~anh Phone: 312-915-7982 Fax: 312-915-7998 gpd at cs.luc.edu for graduate administration upd at cs.luc.edu for undergrad administration aharrin at luc.edu as professor -------------- next part -------------- An HTML attachment was scrubbed... URL: From jjposner at optimum.net Sat Apr 24 01:15:59 2010 From: jjposner at optimum.net (John Posner) Date: Fri, 23 Apr 2010 19:15:59 -0400 Subject: [Edu-sig] teaching Python In-Reply-To: References: Message-ID: <4BD22A2F.6030406@optimum.net> Bill Punch said: > Default mutables are very confusing indeed. The recommended procedure is > to assign the default to be None, then check for that value in the > function and do the assignment there, such as: > > def myFun(myList=None): > if myList == None: > myList = [] > ... > +1. This issue comes up on python-list about once a month. > So is the example of replicating a mutable as Mark showed. To round out > the top three, which are the ones that get even my best students, look > at the below: > > myVar = 27 > > def myFun (): > print myVar > myVar += 1 > return myVar > > print myFun > > What happens when you run this? > Oops, you meant *print myFun()* there. On the bright side, an error occurs, warning you of your errant ways: UnboundLocalError: local variable 'myVar' referenced before assignment Perhaps more gotcha-esque is this similar situation, in which no error occurs: #---------------------------------- class MyClass: var = 101 # class attribute def try_to_modify_class_attribute(self): self.var += 13 def show(self): print self.var obj1 = MyClass() obj2 = MyClass() obj1.try_to_modify_class_attribute() obj1.show() # output: 114 obj2.show() # output: 101 #---------------------------------- -John From mark.engelberg at alumni.rice.edu Sat Apr 24 02:49:25 2010 From: mark.engelberg at alumni.rice.edu (Mark Engelberg) Date: Fri, 23 Apr 2010 17:49:25 -0700 Subject: [Edu-sig] teaching Python In-Reply-To: <4BD2140C.1060305@ece.arizona.edu> References: <4BD2140C.1060305@ece.arizona.edu> Message-ID: On Fri, Apr 23, 2010 at 2:41 PM, David MacQuigg wrote: > Would you rather have Python do something different? My own preference is that I would like 5*[[]] to be syntactic sugar for: [ [ ] for i in range(5)] I find this to be more intuitive, and I believe this is what most people incorrectly assume the syntax expands to. If that's the way it worked, literals would always create fresh copies each time through the loop, but if you still want shared behavior, you could do it explicitly with something like: x = [] a = 5*x Anyway, every language has its shares of gotchas. It's just this is one I've gotten burned by more than once. From kirby.urner at gmail.com Sat Apr 24 03:00:07 2010 From: kirby.urner at gmail.com (kirby urner) Date: Fri, 23 Apr 2010 21:00:07 -0400 Subject: [Edu-sig] teaching Python In-Reply-To: References: <4BD1EB0E.4020302@cse.msu.edu> Message-ID: On Fri, Apr 23, 2010 at 3:24 PM, Mark Engelberg wrote: > On Fri, Apr 23, 2010 at 11:46 AM, Bill Punch wrote: >> To round out the >> top three, which are the ones that get even my best students, look at the >> below: >> >> myVar = 27 >> >> def myFun (): >> ??? print myVar >> ??? myVar += 1 >> ??? return myVar >> >> print myFun >> >> What happens when you run this? >> > > To fully appreciate Bill's example, I think it's worth pointing out > that this version would behave exactly as expected: > > myVar = 27 > > def myFun (): > ? ?print myVar > # ? ?myVar += 1 > ? ?return myVar > > print myFun() > Also, for contrast: myVar = [27] def myFun (): print myVar myVar[0]+=1 return myVar >>> myFun() [27] [28] The above works because the we're not referencing an unbound local, are instead mutating a global. No need to declare myVar global as there could be no other legal meaning. Functions look outside the local scope for bindings. def myFun (): print myVar myVar = 1 return myVar The above crashes because the print references an unbound local. It's a local because of the local binding (don't call it "rebinding") -- can't be the same as the global in that case, so no sense asking to print it before it has a value. def myFun (): global myVar print myVar myVar = 1 return myVar >>> myFun() [32] 1 >>> myVar 1 The above works because the print statement accesses the global. Said global is then rebound. Of course the return is not required for the change to occur at the global level. def myFun (): myVar = 1 print myVar return myVar No problem.... local myVar is already bound when print is encountered. The global myVar is unchanged. myVar = [27] [27] def myFun (): print myVar myVar = [] return myVar The above crashes. It's the binding of myVar to some object other than what the global myVar already references that makes it a local to this function's scope, not the fact that it's bound to a mutable. Can't print a local before the binding occurs. Kirby From macquigg at ece.arizona.edu Sat Apr 24 17:42:36 2010 From: macquigg at ece.arizona.edu (David MacQuigg) Date: Sat, 24 Apr 2010 08:42:36 -0700 Subject: [Edu-sig] teaching Python In-Reply-To: References: <4BD2140C.1060305@ece.arizona.edu> Message-ID: <4BD3116C.7000002@ece.arizona.edu> Mark Engelberg wrote: > On Fri, Apr 23, 2010 at 2:41 PM, David MacQuigg wrote: > >> Would you rather have Python do something different? > > My own preference is that I would like 5*[[]] to be syntactic sugar for: > [ [ ] for i in range(5)] Then what about 5*[x], 5*[[x]], 5*[[3,x]], ... where x itself can be a list, a list of lists, or any complex object? How deep would you go in creating distinct objects? Would you want similar behavior for dictionaries, or is this just something special for lists? What about other operators? Is [x] + [x] no longer equivalent to 2*[x]? We need a clear, concise rule for when to generate distinct objects, and when to keep the current, and more efficient behavior - multiple references to the same object. > I find this to be more intuitive, and I believe this is what most > people incorrectly assume the syntax expands to. > The important thing is not that our initial guess is right in every odd case, but that the syntax be simple and consistent, so we get it right if we think about it. My initial guess was wrong, but that is OK with me, because 1) I could have figured it out if I had taken the time, and 2) I usually don't take the time to figure these things out. I just pop an example in the interpreter, and see if I get what I want. The seemingly bizarre behavior of a = 5*[[]] is not so bizarre if you really understand the relationship between variables and objects in Python. It's simple, but it's different than other languages. Our students start with C, so when I explain Python, I really emphasize the difference. http://ece.arizona.edu/~edatools/ece175/Lecture/python-variables.htm > If that's the way it worked, literals would always create fresh copies > each time through the loop, but if you still want shared behavior, you > could do it explicitly with something like: > x = [] > a = 5*x > That changes the meaning of * for list objects from its current and very useful semantics of "extend this list", and five times empty is still empty. > Anyway, every language has its shares of gotchas. Agreed. I think of language design as laying a carpet in an odd-shaped room (the real world of problems we need to solve). A good design like Python will be very smooth in the middle, and the wrinkles will be at the edges. I've never needed to construct a list of lists, identical in value, but distinct objects in memory, so this is an edge-case for me. Bill's example of accidental scoping is a much more troublesome gotcha. Even if you are not pushing the edges, a simple mis-spelling coupled with Python's complex implicit scoping rules, can result in an error not detected by the interpreter or even by pychecker. If I were designing a language, external variables would always be explicitly declared, and the rule would be simple. An external variable refers to the nearest enclosing scope in which that variable is assigned a value. No difference if the enclosing scope is a class or another function or the module itself. No need for a 'global' keyword that actually means "module level", not truly global. -- Dave From echerlin at gmail.com Sun Apr 25 17:51:07 2010 From: echerlin at gmail.com (Edward Cherlin) Date: Sun, 25 Apr 2010 11:51:07 -0400 Subject: [Edu-sig] rewriting examples in python In-Reply-To: References: <4BC5D23D.9050400@gmx.de> Message-ID: On Thu, Apr 22, 2010 at 12:11, roberto wrote: > On Fri, Apr 16, 2010 at 1:26 AM, Edward Cherlin wrote: >> On Thu, Apr 15, 2010 at 11:36, roberto wrote: >>> On Thu, Apr 15, 2010 at 5:52 AM, Edward Cherlin wrote: >>>> I am more interested in reimplementing such examples in Turtle Art, >>>> and in having a module to translate to Python automatically. Since TA >>>> implements each tile in Python, and the source code is provided, this >>>> should be an easy exercise. >>>> >>> i agree; >>> >>> also, i started this thread since i did not find any *introductory* >>> and rich enough resource a school student can use to learn TA or >>> turtle module or, broadly speaking, turtle programming in Python (if i >>> am wrong, please tell me) There are books, software modules, and other materials. We can work together on a bibliography, and call on the rich experience of Seymour Papert's Logo group and Alan Kay's Smalltalk group, among others. >> Walter Bender and I are working on such things. >> >>> if nobody else did something in this regard, i'll be happy to do some >>> work in this direction as soon as the school end, early june; Late June or July for me. I have a temporary Census job. >> What topics are you interested in covering? I'm working on math and >> Computer Science topics. > > well, i am interested in working with students on introductory CS topics; > by the way, this will be useful to introduce also basic geometry topics; We can do a wide range of geometry, including Euclidean and non-Euclidean synthetic geometry, analytic geometry, and graphing functions; data capture; CS topics such as parse trees, control structures, data structures, stacks, cellular automatons, and Turing machines. Then we show older children the Python source, and how to implement their own Python TA tiles, and encourage them to join the TA community and improve it, or to go on to the wider Python and Free Software communities. > after that, the interest of the students will lead their learning, > whose directions i cannot predict by now ... > where will you publish your tutorial/manual ? http://www.flossmanuals.net/ > thank you in advance > >> >>> of course, since my students are very young and with no previous >>> programming experience, i'd like to start with TA Good choice. >>> let me know also if anyone is doing something similar, to prevent double work >>> >>> thank you again >>>> On Wed, Apr 14, 2010 at 10:33, Christian Mascher >>>> wrote: >>>>> roberto wrote: >>>>>> >>>>>> hello, i found this very famous book >>>>>> "Turtle Geometry: The Computer as a Medium for Exploring Mathematics >>>>>> (Artificial Intelligence)" >>>>>> by Harold Abelson and Andrea diSessa >>>>>> and i was wondering if anyone of the turtle experts has ever rewritten >>>>>> in python the logo examples in the book; >>>>>> >>>>> Nobody has answered, so probably not. Nevertheless I think its a good >>>>idea >>>>> to try this. It will probably turn out to be perfectly feasible to do these >>>>> examples in Python with the turtle module by Gregor Lingl. And a good >>>>> exercise too. If you run into problems let us know. >>>>> >>>>> --Christian >>>>> >>>>>> i am more interested in the turtle spirit than in the logo language, >>>>>> so i'd like to use python directly along with the book itself >>>>>> >>>>>> thank you very much in advance > -- > roberto > -- Edward Mokurai (??/???????????????/????????????? ?) Cherlin Silent Thunder is my name, and Children are my nation. The Cosmos is my dwelling place, the Truth my destination. http://www.earthtreasury.org/ From macquigg at ece.arizona.edu Mon Apr 26 22:13:25 2010 From: macquigg at ece.arizona.edu (David MacQuigg) Date: Mon, 26 Apr 2010 13:13:25 -0700 Subject: [Edu-sig] Understanding [ [ ], [ ] ] In-Reply-To: <4BD3116C.7000002@ece.arizona.edu> References: <4BD2140C.1060305@ece.arizona.edu> <4BD3116C.7000002@ece.arizona.edu> Message-ID: <4BD5F3E5.1060901@ece.arizona.edu> Here are some challenges to test students' understanding of how Python handles objects in memory. Scroll down one line at a time and see if you can guess True or False on each equality or identity test. ### More on copying of complex objects >>> from copy import copy, deepcopy # functions for shallow and deep copies >>> x <__main__.X object at 0x14cab50> >>> a = 2*[[x]] >>> a [[<__main__.X object at 0x14cab50>], [<__main__.X object at 0x14cab50>]] >>> a[0] == a[1] # equal in value True >>> a[0] is a[1] # same object True >>> a = [[x] for i in range(2)] # trick to make distinct objects >>> a = [copy([x]) for i in range(2)] # same, but more clear >>> a [[<__main__.X object at 0x14cab50>], [<__main__.X object at 0x14cab50>]] >>> a[0] is a[1] False >>> >>> b = a # new label for same object >>> b is a True >>> >>> b = a[:] # common Python idiom for shallow copy >>> b = copy(a) # same, but more clear >>> b [[<__main__.X object at 0x14cab50>], [<__main__.X object at 0x14cab50>]] >>> b == a True >>> b is a False >>> b[0] is a[0] True >>> b[0] is b[1] False >>> b = deepcopy(a) # clone everything >>> b [[<__main__.X object at 0x14d1d90>], [<__main__.X object at 0x14d1d90>]] >>> b == a # careful, object x has no "value" # if an object has no value, it can't be == to anything but itself False >>> b[0] is a[0] False >>> b[0] is b[1] False >>> b[0][0] <__main__.X object at 0x14d1d90> >>> b[0][0] == a[0][0] False >>> b[0][0] == b[1][0] True -- ************************************************************ * * David MacQuigg, PhD email: macquigg at ece.arizona.edu * * * Research Associate phone: USA 520-721-4583 * * * * ECE Department, University of Arizona * * * * 9320 East Mikelyn Lane * * * * http://purl.net/macquigg Tucson, Arizona 85710 * ************************************************************ * David MacQuigg wrote: > Mark Engelberg wrote: >> On Fri, Apr 23, 2010 at 2:41 PM, David MacQuigg wrote: >> >>> Would you rather have Python do something different? >> >> My own preference is that I would like 5*[[]] to be syntactic sugar for: >> [ [ ] for i in range(5)] > > Then what about 5*[x], 5*[[x]], 5*[[3,x]], ... where x itself can be a > list, a list of lists, or any complex object? How deep would you go > in creating distinct objects? Would you want similar behavior for > dictionaries, or is this just something special for lists? What about > other operators? Is [x] + [x] no longer equivalent to 2*[x]? We need > a clear, concise rule for when to generate distinct objects, and when > to keep the current, and more efficient behavior - multiple references > to the same object. > >> I find this to be more intuitive, and I believe this is what most >> people incorrectly assume the syntax expands to. >> > > The important thing is not that our initial guess is right in every > odd case, but that the syntax be simple and consistent, so we get it > right if we think about it. My initial guess was wrong, but that is > OK with me, because 1) I could have figured it out if I had taken the > time, and 2) I usually don't take the time to figure these things out. > I just pop an example in the interpreter, and see if I get what I want. > > The seemingly bizarre behavior of a = 5*[[]] is not so bizarre if you > really understand the relationship between variables and objects in > Python. It's simple, but it's different than other languages. Our > students start with C, so when I explain Python, I really emphasize > the difference. > http://ece.arizona.edu/~edatools/ece175/Lecture/python-variables.htm > >> If that's the way it worked, literals would always create fresh copies >> each time through the loop, but if you still want shared behavior, you >> could do it explicitly with something like: >> x = [] >> a = 5*x >> > > That changes the meaning of * for list objects from its current and > very useful semantics of "extend this list", and five times empty is > still empty. > >> Anyway, every language has its shares of gotchas. > > Agreed. I think of language design as laying a carpet in an > odd-shaped room (the real world of problems we need to solve). A good > design like Python will be very smooth in the middle, and the wrinkles > will be at the edges. I've never needed to construct a list of lists, > identical in value, but distinct objects in memory, so this is an > edge-case for me. > > Bill's example of accidental scoping is a much more troublesome > gotcha. Even if you are not pushing the edges, a simple mis-spelling > coupled with Python's complex implicit scoping rules, can result in an > error not detected by the interpreter or even by pychecker. > > If I were designing a language, external variables would always be > explicitly declared, and the rule would be simple. An external > variable refers to the nearest enclosing scope in which that variable > is assigned a value. No difference if the enclosing scope is a class > or another function or the module itself. No need for a 'global' > keyword that actually means "module level", not truly global. > > -- Dave > From kirby.urner at gmail.com Thu Apr 29 00:59:07 2010 From: kirby.urner at gmail.com (kirby urner) Date: Wed, 28 Apr 2010 15:59:07 -0700 Subject: [Edu-sig] blogged mention of Ed Cherlin, MFTDA Message-ID: Hey Ed, your name goes by in my (eclectic, all over the map) blog post of today, thought I'd give you a heads up. http://worldgame.blogspot.com/2010/04/wheeling-dealing.html I know my suggestion to Mike D that he get involved in compiling APL for the XO didn't go anywhere (yet) -- that seemed a tad esoteric even for him. Either way, I consider you kindred spirits. Also, I do these photo-collages or tableaus as I sometimes call 'em. In yesterday's, I included Math for the Digital Age in tandem with A Love of Discovery, a work in the contructivist tradition. http://mybizmo.blogspot.com/2010/04/first-person-physics.html ** I learned from my meeting with Bob that VPython is now being maintained from North Carolina State (not Carnegie Mellon). http://www.ncsu.edu/PER/ Kirby ** For more information (mentions meeting with Dr. Bob Fuller): """ Dr. Fuller is a student of Dr. Robert Karplus when it comes educational theory and techniques. A Love of Discovery sits in my living room on the "time capsule" (semi-cylindrical shelves) between a book by Linus Pauling and Wolfram's thick tome. """ http://worldgame.blogspot.com/2010/04/back-in-97214.html From kirby.urner at gmail.com Fri Apr 30 08:21:56 2010 From: kirby.urner at gmail.com (kirby urner) Date: Thu, 29 Apr 2010 23:21:56 -0700 Subject: [Edu-sig] scientific computing in Python Message-ID: My daughter got a hand-me-down GeForce GS8400 from a friend at school. That's like a $45 video card, yet is presumably advanced enough to support Cuda, and therefore PyCuda. What's that? http://documen.tician.de/pycuda/ We keep getting back to numpy arrays as a basis for computer graphics. Linear algebra with numpy.matrix looks like a good way to go in a digital math class. >From Cut-the-Knot, this 9x9 invertible matrix: >>> import numpy as np A result of cutting and pasting: >>> m = """1 1 1 1 1 0 1 0 0 0 1 0 1 0 1 1 0 1 1 1 1 0 1 1 1 0 1 0 1 1 1 0 0 0 1 1 0 1 0 1 1 1 0 1 0 1 1 0 0 0 1 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 1 0 1 0 1 0 0 0 1 0 1 1 1 1 1""".split() Convert to integers: >>> mat = np.matrix(np.array([int(x) for x in m]).reshape(9,9)) >>> mat matrix([[1, 1, 1, 1, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1, 0, 1], [0, 1, 1, 1, 0, 0, 0, 1, 1], [0, 1, 0, 1, 1, 1, 0, 1, 0], [1, 1, 0, 0, 0, 1, 1, 1, 0], [1, 0, 0, 1, 1, 0, 1, 1, 1], [1, 0, 1, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 1, 1, 1, 1]]) Getting the inverse is now as simple as: >>> print np.round(mat.I, 2) # that's mat.I with I for Inverse [[-0.17 -0.23 0.48 -0.07 -0.12 0.11 0.32 0.27 -0.51] [ 0.07 -0.07 0.2 0.33 0.2 0.27 -0.2 -0.33 -0.27] [ 0.32 -0.12 -0.04 0.2 -0.24 -0.12 -0.36 0.2 0.32] [ 0.23 0.37 -0.32 -0.07 0.08 -0.29 0.12 0.27 -0.11] [ 0.08 -0.28 0.24 -0.2 0.44 -0.28 0.16 -0.2 0.08] [-0.27 0.27 0.2 -0.33 0.2 -0.07 -0.2 0.33 0.07] [ 0.48 0.32 -0.56 -0.2 -0.36 0.32 -0.04 -0.2 0.48] [-0.11 -0.29 -0.32 0.27 0.08 0.37 0.12 -0.07 0.23] [-0.51 0.11 0.48 0.27 -0.12 -0.23 0.32 -0.07 -0.17]] http://www.cut-the-knot.org/explain_game.shtml Connecting the dots twixt Pycuda and numpy: http://documen.tician.de/pycuda/array.html#pycuda.gpuarray.GPUArray Perry Greenfield has had much to do with getting Python going at the Space Telescope Science Institute (STScI). We invited him to give a lightning talk during my class, but he was stuck in Amsterdam owing to the volcanic ash problem in Iceland. http://www.scipy.org/wikis/topical_software/Tutorial http://stsdas.stsci.edu/perry/pydatatut.pdf (144 pages by Perry Greenfield and Robert Jedrzejewski -- about analyzing astronomical imagery in Python with numpy, pyfits, numdisplay etc.). Numpy has a lot in common with IDL, an inhouse analysis language for many on the Hubble project. In sharing research data with the wider public however, it's easier if the files might be worked on by free and open source software. IDL ain't cheap. http://www.cfa.harvard.edu/~jbattat/computer/python/science/idl-numpy.html Speaking of Cuda (used to code for the GPU vs. the CPU), there's a PyopenCL as well, also by Andreas Kl?ckner. http://developer.amd.com/GPU/ATISTREAMSDK/pages/TutorialOpenCL.aspx Kirby From juhasecke at googlemail.com Fri Apr 30 09:19:16 2010 From: juhasecke at googlemail.com (Jan Ulrich Hasecke) Date: Fri, 30 Apr 2010 09:19:16 +0200 Subject: [Edu-sig] The perfect IT environment in a school Message-ID: Hi, since three years I am guiding a Python voluntary workgroup in a school and we are suffering from a badly organized IT environment (a rigidly restricted Windows setting). Most of all we miss a decent VCS as Mercurial or Bazaar. In the official IT classes they never used a VCS so it was never installed. While thinking about this I discovered that some other things are missing. For eg. we cannot install a web framework due to the strange restrictions. They do not have Zotero installed. For students the FF-plugin Zotero would be a great tool to make bibliographies. Does anyone yet compiled a list of things which may not be missing in a perfect IT environment in a school? Perhaps I can lobby some teachers to improve their environment. juh