O'Reilly logo

Introduction to Programming in Python: An Interdisciplinary Approach by Robert Sedgewick, Kevin Wayne, Robert Dondero

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter Two. Functions and Modules

This chapter is centered on a construct that has as profound an impact on control flow as do conditionals and loops: the function, which allows us to transfer control back and forth between different pieces of code. Functions are important because they allow us to clearly separate tasks within a program and because they provide a general mechanism that enables us to reuse code. Using and defining functions is a central component of Python programming.

When we have a number of functions to work with, we group them together in modules. With the use of modules, we can break a computational task into subtasks of a reasonable ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required