from math import from tkinter import map int input split root Tk I1 J1

 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
from math import *
from tkinter import *
x, y, l, k = map(int, input().split())
root = Tk()
I1 = 0
J1 = 0
I2 = 500
J2 = 500
canv = Canvas(root, width = I2, height = J2, bg = 'lightblue')
xt, yt = x, y + l
print(xt,yt)
canv.create_line(x, y, xt, yt, width = 0.5)
def tree(x, y, l, k):
if k >= 1:
alpha = pi / 6
for i in range(k):
x1 = x + (0.4 * l) * sin(alpha * (i))
y1 = y - (0.4 * l) * cos(alpha * (i))
x2 = x - (0.4 * l) * sin(alpha * (i))
y2 = y - (0.4 * l) * cos(alpha * (i))
canv.create_line(x, y, x1, y1, width = 0.5)
canv.create_line(x, y, x2, y2, width = 0.5)
print(x1,y1,x2,y2)
tree(x1, y1, 0.4 * l, k - 1)
tree(x2, y2, 0.4 * l, k - 1)
tree(x, y, l, k)
canv.pack()
root.mainloop()