-
Notifications
You must be signed in to change notification settings - Fork 0
/
turtle tutorial.py
115 lines (98 loc) · 1.81 KB
/
turtle tutorial.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import turtle
from turtle import *
#to create simple robot
t = turtle.Turtle()
t.speed(0)
wn = turtle.Screen()
wn.bgcolor('black')
t.color('blue')
t.goto(0, 0)
t.speed(3)
# for calling rest of the function
def body():
head()
chest()
arms()
inner()
leg()
# for drawing the head
def head():
t.begin_fill()
t.fillcolor('yellow')
t.circle(30)
t.end_fill()
t.begin_fill()
t.fillcolor('silver')
t.circle(24)
t.end_fill()
# for drawing the body of the robot
def chest():
t.begin_fill()
t.fillcolor('yellow')
t.forward(60)
t.right(90)
t.forward(120)
t.right(90)
t.forward(120)
t.right(90)
t.forward(120)
t.right(90)
t.forward(60)
t.end_fill()
# for drawing the arms of the robot
def arms():
t.up()
t.goto(60, -35)
t.down()
t.pensize(2)
t.right(45)
t.forward(60)
t.right(20)
t.forward(50)
t.penup()
t.goto(-60, -35)
t.pendown()
t.right(65)
t.forward(60)
t.left(20)
t.forward(50)
def inner():
t.right(70)
t.right(180)
t.penup()
t.goto(0, -20)
t.pendown()
t.begin_fill()
t.fillcolor('silver')
t.forward(40)
t.right(90)
t.forward(80)
t.right(90)
t.forward(80)
t.right(90)
t.forward(80)
t.right(90)
t.forward(40)
t.end_fill()
# for drawing the legs of the robot
def leg():
t.penup()
t.goto(0, 0)
t.goto(30, -120)
t.pendown()
t.width(4)
t.right(60)
t.forward(70)
t.right(20)
t.forward(60)
t.penup()
t.goto(-30, -120)
t.pendown()
t.right(40)
t.forward(70)
t.left(20)
t.forward(60)
t.hideturtle()
if __name__ == '__main__':
body()
mainloop()