Master Recursion in 5 Minutes! π
Learn how recursion works with simple Python examples to break down complex problems quickly and easily.

Bro Code
309.7K views β’ Dec 9, 2022

About this video
#python #tutorial #course
# recursion = a function that calls itself from within
# helps to visualize a complex problem into basic steps
# problems can be solved more easily iteratively or recursively
# iterative = faster, complex
# recursive = slower, simpler
# ----- EXAMPLE 1 -----
# ITERATIVE
def walk(steps):
for step in range(1, steps+1):
print(f"You take step #{step}")
# RECURSIVE
def walk(steps):
if steps == 0:
return
walk(steps - 1)
print(f"You take step #{steps}")
walk(100)
# recursion = a function that calls itself from within
# helps to visualize a complex problem into basic steps
# problems can be solved more easily iteratively or recursively
# iterative = faster, complex
# recursive = slower, simpler
# ----- EXAMPLE 1 -----
# ITERATIVE
def walk(steps):
for step in range(1, steps+1):
print(f"You take step #{step}")
# RECURSIVE
def walk(steps):
if steps == 0:
return
walk(steps - 1)
print(f"You take step #{steps}")
walk(100)
Tags and Topics
Browse our collection to discover more content in these categories.
Video Information
Views
309.7K
Likes
9.1K
Duration
5:59
Published
Dec 9, 2022
User Reviews
4.7
(61) Related Trending Topics
LIVE TRENDSRelated trending topics. Click any trend to explore more videos.
No specific trending topics match this video yet.
Explore All Trends