# Python Fractal Structure, Pythagorean Tree Question.

Asked 2 weeks ago, Updated 2 weeks ago, 3 views

``````from turtle import*

def pract(a,d):
if d<=20: return
for i in range(4):
fd(d)
lt(a)
lt(a)
fd(d)
rt(a/2)
pract(a,d*(2**(1/2)/2))

setup(800, 800)
up(); goto(0, -300); down()
speed(5)

pract(90,100)
done()
``````

It's a Python Fractal problem. I made it on one side I'm asking you a question because I couldn't add it.

python3 turtle

2022-09-20 14:44

``````from turtle import *

def pract(d):
"""
x

x_________
|         |
|         |
|         |
._________|

. Start at a point and draw a square
Draw a small square at point x.
Finish the work and return to the initial starting point
The direction is also returned to the original direction.

"""
if d <= 20:
return

dd = d * (2 ** (1 / 2) / 2)
for _ in range(4):
fd(d)
lt(90)
lt(90)
fd(d)
rt(45)
# Draw a small rectangle from the initial direction to lt 45 degrees at the first x point
pract(dd)
up()
fd(dd)
rt(90)
down()
# Draw a small rectangle from the initial direction to rt 45 degrees at the second x-point
pract(dd)
up()
rt(90)
fd(dd)
lt(45)
fd(d)
lt(90)
down()
# The position and orientation at the end shall be the position and orientation at the start.

setup(800, 800)
up()
goto(0, -300)
down()
speed(5)

pract(100)
done()
``````

2022-09-20 14:44

## If you have any answers or tips

Popular Tags
python x 4520
android x 1589
java x 1455
javascript x 1363
c x 881
php x 682
html x 629
swift x 586
ios x 538
mysql x 397