Python Programming

Functions, Scope, and Testing

4:29

Plays from YouTube. Watch on YouTube

What makes one Python function more reliable and reusable than another?

Meet functions, scope, modules and testing: the fundamentals of building programs from clear behavioral contracts.

We trace argument evaluation, parameter binding and return values using a delivery-fee example.

From there, we distinguish printing from returning, compose smaller functions and explain when imports create namespaces.

Finally, we write precise specifications, exercise doctests and debug a boundary-case failure.

The big idea: dependable code starts with an interface whose promises you can test.

Python explained visually, one concept at a time.