PYTHON
ADVANCED
SNAKE
As Artie Max draws, follow along
onscreen. Watch what each coded
command produces on the page.
WATCH & LEARN
DOWNLOAD
You can also download the
complete code for this project.
Just find the “
SNAKE
”
project from the file menu.
SAVE
SAVE AS...
NEW PROGRAM
DELETE PROGRAM
DOWNLOAD
CURRENT PROGRAM
UPLOAD PROGRAM
DEMO:
• SNAKE
from
artie
import
Artie
import
math
artie
=
Artie()
def
draw_arc(direction,fraction,radius):
L
=
78
PI
=
3.141592
distance
=
PI
*
2
*
radius
*
fraction
angle = atan(L
/
radius) *
180
/
PI
if direction
==
'left'
:
angle
= -
angle
artie.movearc(distance,angle)
artie.penup()
artie.left(
20
)
artie.pendown(
2
)
draw_arc(
'left'
,(
93.0
/
360.0
),
38
)
artie.left(
15
)
artie.forward(
19
)
artie.right(
59
)
artie.forward(
36
)
artie.right(
64
)
artie.forward(
15
)
artie.right(
73
)
artie.forward(
35
)
artie.right(
53
)
artie.forward(
18
)
artie.left(
48
)
draw_arc(
'right'
,(
86.0
/
360.0
),
57
)
draw_arc(
'left'
,(
93.0
/
360.0
),
38
)
artie.right(
11
)
draw_arc(
'right'
,(
112.0
/
360.0
),
43
)
artie.right(
155
)
draw_arc(
'left'
,(
85.0
/
360.0
),
43
)
artie.left(
6
)
draw_arc(
'right'
,(
88.0
/
360.0
),
57
)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
PROGRAM
Copy the text that you see below:
RUN
Center
Artie Max
on the
paper.
Always test your code
in the Simulator first.