October 2019
Beginner to intermediate
498 pages
14h 13m
English
In this chapter, we introduced recursion, a powerful programming technique that allows us to elegantly solve problems by taking advantage of “self-reference.” Fractals are graphically self-referential—that is, they contain smaller versions of themselves. We can implement recursion by simply letting a Python function call itself. Identification of the nonrecursive case, called the base case, is important to make sure that the recursive calls work correctly. Finally, we explored L-systems, which formally denote fractal behavior using a set of grammar rules. A string of symbols can be produced by repeatedly applying these rules. By interpreting this result string as a series of turtle commands, we can draw a fractal.
Read now
Unlock full access