Executing code repeatedly with a recursion

Опубликовано: 26 Апрель 2026
на канале: Alexander Hess - Pythonista
603
14

In this video, I introduce two strategies to implement an iteration logic. In general, iteration it the repeated execution of a block of code. We can achieve that with either a recursion or a looping strategy. In a recursion, we define a function that calls itself from within its body, and has a "way out". Looping strategies are implemented with either a for- or a while-loop. As an example, we create a function that models a simple countdown until a party begins (e.g., "3 2 1 Happy New Year!"). We do so with both a recursive and a looping approach. Then, we compare the two implementations with Python Tutor and see how in the recursive case the same function is being executed several times in parallel, which is not the case for the looping version.

PYTHON BOOK
The lecture is based on the free book "Introduction to Python & Programming".
Get it on GitHub: https://github.com/webartifex/intro-t...

SUBSCRIBE
If you like the way I teach and talk about programming and data science, subscribe to this channel.
The videos focus on coding courses and tutorials aimed at managers and students of business administration, enabling them to make better decisions with analyses done in code.

INSTRUCTOR
Alexander Hess, PhD Student
WHU - Otto Beisheim School of Management, Vallendar, Germany

CONTACT
GitHub: https://github.com/webartifex
LinkedIn:   / webartifex  
XING: https://xing.to/webartifex
Facebook:   / webartifex  
Instagram:   / webartifex  
Website: http://www.webartifex.biz
YouTube:    / webartifex  

wa-vid-046