-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmypolygon.py
More file actions
59 lines (41 loc) · 899 Bytes
/
mypolygon.py
File metadata and controls
59 lines (41 loc) · 899 Bytes
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
import turtle
bob = turtle.Turtle()
alice = turtle.Turtle()
def rectangle(t,length,width):
for i in range(2):
t.fd(length)
t.lt(90)
t.fd(width)
t.lt(90)
print(bob)
turtle.mainloop()
def mypolygon(t,sides,length):
angle = 360 /sides
t.fd(length/8)
for i in range(sides):
t.fd(length)
t.lt(angle)
print(alice)
turtle.mainloop()
def mycircle(t,radius,sides):
t.fd(radius)
for i in range(sides):
t.fd(radius*3/2)
t.lt(360/sides)
print(alice)
turtle.mainloop()
import math
def polygon(t, n, length):
angle = 360 / n
for i in range(n):
t.fd(length)
t.lt(angle)
def circle(t,r):
circumference = 2*math.pi*r
n=50
length = circumference/n
polygon(t,n,length)
#rectangle(bob,100,25)
#mycircle(alice,10,30)
#polygon(bob,7,70)
circle(bob,40)