-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonTurtle.py
More file actions
64 lines (45 loc) · 1.22 KB
/
PythonTurtle.py
File metadata and controls
64 lines (45 loc) · 1.22 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import turtle
s = turtle.getscreen()
t = turtle.Turtle()
class shape:
def __init__(self, sides = 0, length = 0) :
self.sides = sides
self.length = length
class polygon(shape):
def info(self):
print("In geometry, a polygon can be defined as a flat or plane, two-dimensional with straight sides.")
class square(polygon):
def show(self):
t.fd(self.length)
t.rt(90)
t.fd(self.length)
t.rt(90)
t.fd(self.length)
t.rt(90)
t.fd(self.length)
t.rt(90)
class pentagon(polygon):
def show(self):
for i in range(5):
t.forward(self.length)
t.right(72)
class hexagon(polygon):
def show(self):
for i in range(6):
t.forward(self.length)
t.right(60)
class octagon(polygon):
def show(self):
for i in range(6):
t.forward(self.length)
t.right(45)
class triangle(polygon):
def show(self):
t.forward(self.length)
t.left(120)
t.forward(self.length)
t.left(120)
t.forward(self.length)
hex1 = hexagon(6, 100)
hex1.info()
hex1.show()