This lesson introduces the concept of a function. Much like the equivalent in mathematics, a function takes input and generates output. By encapsulating algorithmic details in a function, you promote code reuse, increase efficiency by leveraging previous work, and reduce the likelihood for errors to occur.
By the end of this lesson, you will be be able to
You will also learn how to create unnamed functions, known as lambda functions, and how to provide default values for functions.
Approximately 2 hours.
Video: Watch the Python functions video, which will demonstrate how to write and use Python functions.
Notebook: Read and complete the practice exercises in the Python functions notebook.
© 2017: Robert J. Brunner at the University of Illinois.
This notebook is released under the Creative Commons license CC BY-NC-SA 4.0. Any reproduction, adaptation, distribution, dissemination or making available of this notebook for commercial use is not allowed unless authorized in writing by the copyright holder.