from math import from tkinter import int input root Tk canv Canvas roo

 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
from math import *
from tkinter import *
k = int(input())
root = Tk()
canv = Canvas(root, width = 600,height = 600, bg = 'green')
x = 30;y = 570;x2 = 570;y2 = 570
points1 = [(x,y),(x2,y2)]
for i in range(k):
points2 = []
for j in range(len(points1)//2):
if j*2 == 0:
x = int(points1[j][0])
y = int(points1[j][1])
x2 = int(points1[j+1][0])
y2 = int(points1[j+1][1])
l = int(sqrt((x2-x)**2+(y2-y)**2))
p01 = x;p02 = y;p03 = x2;p04 = y2
p = x + int((x2-x)/3)
p2 = y + int((y2-y)/3)
p3 = x + int(2*(x2-x)/3)
p4 = y + int(2*(y2-y)/3)
p5 = int((x2+x)/2-(l/(2*sqrt(3)))*sin((y2-y)/l))
p6 = int((y2+y)/2-(l/(2*sqrt(3)))*cos((x2 - x)/l))
points2.append((p01,p02))
points2.append((p, p2))
points2.append((p, p2))
points2.append((p5, p6))
points2.append((p5, p6))
points2.append((p3, p4))
points2.append((p3, p4))
points2.append((p03, p04))
points1 = points2
print(points1)
canv.create_line(points1,width = 1,fill = 'yellow',smooth = 0)
canv.pack()
root.mainloop()