filmov
tv
Turtle graphics design 🖥️🥵 || Code with Ajit || #turtle #coding #python #programming

Показать описание
import turtle
# Setup the screen
screen = turtle.Screen()
# Create the turtle
t = turtle.Turtle()
# Recursive function to draw a fractal tree
def draw_tree(branch_length, t):
if branch_length 10:
return
else:
# Draw main branch
# Draw right sub-branch
draw_tree(branch_length - 15, t)
# Back to main branch
draw_tree(branch_length - 15, t)
# Return to original state
# Call the fractal tree function
draw_tree(100, t)
# Close the turtle window on click
# Setup the screen
screen = turtle.Screen()
# Create the turtle
t = turtle.Turtle()
# Recursive function to draw a fractal tree
def draw_tree(branch_length, t):
if branch_length 10:
return
else:
# Draw main branch
# Draw right sub-branch
draw_tree(branch_length - 15, t)
# Back to main branch
draw_tree(branch_length - 15, t)
# Return to original state
# Call the fractal tree function
draw_tree(100, t)
# Close the turtle window on click