[Edu-sig] From trees to text
Edward Cherlin
echerlin at gmail.com
Wed Mar 25 18:45:56 CET 2009
Which Python are you using?
Idle/Python 2.5 say:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
shape("turtle")
NameError: name 'shape' is not defined
python orbit1.py
Traceback (most recent call last):
File "orbit1.py", line 6, in <module>
speed(0)
File "/usr/lib/python2.5/lib-tk/turtle.py", line 707, in speed
def speed(speed): return _getpen().speed(speed)
File "/usr/lib/python2.5/lib-tk/turtle.py", line 588, in speed
"one of %s" % (speed, speeds))
ValueError: 0 is not a valid speed. speed must be one of ['fastest',
'fast', 'normal', 'slow', 'slowest']
On Wed, Mar 25, 2009 at 9:47 AM, Gregor Lingl <gregor.lingl at aon.at> wrote:
>
>
> Edward Cherlin schrieb:
>>
>>
>> http://tonyforster.blogspot.com/2009/03/orbital-motion-in-python-and-turtleart.html
>> Orbital motion in Python and TurtleArt
>>
>
> I'd like to contribute to this topic just three scripts using Python's
> own turtle module (since 3.6) - for now without any further comment ( as
> I'm just preparing my journey to Chicago, leaving Vienna tommorow
> in the morning). Of course there are many ways of doing this,
> depending on your previous knowledge, approaches to math and physics,
> and to programming etc.
>
> Please run the example scripts (and compare and assess the code, if you
> like)
>
> # orbit1.py
>
> from turtle import *
>
> shape("turtle")
> speed(0)
> pu(); goto(200,0); pd()
>
> G = 800
> hspeed, vspeed = 0, 1
> t = 0
> while t < 1000:
> x, y = pos()
> goto(x+hspeed, y+vspeed)
> r = distance(0,0)
> x, y = pos()
> hacc = (-G/r**2)*(x/r)
> vacc = (-G/r**2)*(y/r)
> hspeed = hspeed + hacc
> vspeed = vspeed + vacc
> t = t + 1
--
Silent Thunder (默雷/धर्ममेघशब्दगर्ज/دھرممیگھشبدگر ج) is my name
And Children are my nation.
The Cosmos is my dwelling place, The Truth my destination.
http://earthtreasury.net/ (Edward Mokurai Cherlin)
More information about the Edu-sig
mailing list