Between unintelligible algorithms and beautiful fractal artwork, recursion has an intimidating and even mystical reputation. But the underlying ideas behind it are simple. In this tutorial we get a solid foundation of recursive code, and run through several examples in the interactive shell. If you've ever said or thought the words "recursion is confusing", this tutorial is for you.
Recursion has an intimidating reputation for being the advanced skill of coding sorcerers. But in this tutorial we look behind the curtain of this formidable technique to discover the simple ideas under it.
If you've ever said or thought the words "recursion is confusing", this tutorial is for you.
Through hands-on exercises in the interactive shell, we'll answer the following questions:
We'll cover a number of common recursive algorithms:
This tutorial is for a wide range of developers. Beginners who only understand the basics of Python will be able to follow along. Experienced developers who have hoped no one would notice the recursive-coding gap in their knowledge will be able to breath with relief after taking this tutorial. All that is required is a willingness to learn, and a willingness to have the willingness to learn, and a willingness to have the willingness to have the willingness to learn, and... so on.
Al Sweigart is a professional software developer and tech book author who teaches programming to kids and adults. Sweigart has written several programming books for beginners, including Automate the Boring Stuff with Python, Invent Your Own Computer Games with Python, and Cracking Codes with Python. His books are freely available under a Creative Commons license at https://inventwithpython.com.