TurtleArt in its current experimental fork,
TurtleArtPortfolio , allows students to use Python functions in a special block.
The intention of this feature is to provide a "
higher ceiling" for open ended learning. I decided to try this function to do an
analogue clock , a task that I had previously done in Gamemaker.
It turned out to be a trivial exercise for some learning goals because trigonometric functions of sin() cos() and pi() were not required, I could just use set heading.
I required the time library functions from Python which had not been imported, this meant I had to hack the TurtleArt source file talogo.py adding the line
from time import localtime
(as of V13, this is not required)The programmming in TA visual blocks is shown in the picture below.
The code to the right draws 12 hour marks from radius 200 to 220. The code to the left draws the second, minute and hour hand. The heading for the second hand, for example, is calculated as
seth=localtime().tm_sec * 6
for the minute and hour use tm_min and tm_hour respectively.
The output:
What I found hardThe time function that I required was not already imported into TurtleArt. Can you use the insert function block to import a library? Apparently not because import does not return a value. Could the block be reprogrammed so that it does not need to return a value? If all likely imports are already programmed in, does TurtleArt become clumsy, slow to load and a memory hog? If students can't access all functions they don't have a sufficiently high ceiling.
Finding the correct syntax for
time . There was a lack of documentation or programming examples that explained that localtime() returns a structure with elements including tm_hour. Also the correct syntax depending on whether one function or the whole library was imported. Specifically, it was hard to discover that the correct syntax could be:
import time
mytime=time.localtime()
myhour=mytime.tm_hour
or
from time import localtime
mytime=localtime()
myhour=mytime.tm_hour
and that the two lines of code above could be combined, eliminating the need for the temporary structure variable mytime
from time import localtime
myhour=localtime().tm_hour
It either needs better documentation, more code examples or both.
What didn't workThe block has insufficient space to type in long expressions, you can't edit an expression, you have to retype it, when dragging a block containing a long expression, it leaves bits of text on the canvas.
Labels: olpc, Python, Sugar, TurtleArt