Create reusable functionality with functions in Python

Beginner
Developer
Visual Studio

Define functions to create encapsulated modular code that accept input and return results.

Learning objectives

In this module, you'll:

  • Define functions that encapsulate functionality.
  • Add input parameters to functions so they can be called using input arguments.
  • Return values from functions.
  • Create modules to host functions that can be imported into other code files.

Prerequisites

  • A local Python development environment set up to run Python 3 using a code editor like Visual Studio Code
  • Knowledge of how to run a code script using either a command line or your local Python development environment
  • Basic Python knowledge that includes an understanding of types, variables, value assignment, function calls, passing arguments, and module import