-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfoursquare.py
58 lines (48 loc) · 1.09 KB
/
foursquare.py
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import turtle
def drawSquareFromCenter(turtle,x):
turtle.penup()
turtle.forward(-x/2)
turtle.right(90)
turtle.forward(x/2)
turtle.left(90)
turtle.pendown()
turtle.forward(x)
turtle.left(90)
turtle.forward(x)
turtle.left(90)
turtle.forward(x)
turtle.left(90)
turtle.forward(x)
turtle.left(90)
turtle.penup()
turtle.forward(x/2)
turtle.left(90)
turtle.forward(x/2)
turtle.right(90)
def main():
#create turtle
bob = turtle.Turtle()
#draw graphics
#draw first square
drawSquareFromCenter(bob,160)
#move to next spot
bob.right(180)
bob.forward(20)
bob.right(90)
bob.forward(-140)
#draw second square
drawSquareFromCenter(bob,120)
#move to next spot
bob.forward(20)
bob.left(90)
bob.forward(100)
#draw third square
drawSquareFromCenter(bob,80)
#move to last spot
bob.right(180)
bob.forward(20)
bob.left(90)
bob.forward(60)
#draw last square
drawSquareFromCenter(bob,40)
main()