-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatch_turtle.py
More file actions
44 lines (35 loc) · 1.11 KB
/
match_turtle.py
File metadata and controls
44 lines (35 loc) · 1.11 KB
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
35
36
37
38
39
40
41
42
43
44
from turtle import Turtle
turtle = Turtle()
turtle.shape("turtle")
turtle.speed(3)
turtle.color("blue", "yellow")
turtle.penup()
while True:
command = input(">").strip().split()
match command:
case ["move", *points]:
match points:
case [x, y]:
turtle.goto(float(x), float(y))
case [steps]:
turtle.forward(float(steps))
case ["turn", *options]:
match options:
case [angle]:
turtle.right(float(angle))
case _:
turtle.right(90)
case ["draw", shape, size]:
turtle.pendown
match shape:
case "circle":
turtle.circle(float(size))
case "line":
turtle.forward(float(size))
turtle.penup()
case ["write", *text]:
turtle.write(" ".join(text), None, "center", "16pt 20")
case ["exit", "stop", "quit"]:
break
case _:
print("Invalid command")