recursive_tree_numworks.py

Created by vnap0v

Created on July 25, 2025

2.38 KB

recursive_tree_numworks.py

This script draws recursively generated trees.

The function

def branch(length, depth, width):

recursively calls itself, when recursion limit is not yet reached

it draws a branch and calls itself twice after changing the heading

when recursion limit is reached it draws a leaf

A lot of the tree’s parameters have random variation.

The code uses Turtle graphics for drawing, the timer function to wait after each tree and random to introduce random variations.


During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.