Skip to content

Functions and Modules

Introduction

In computer programming, functions are a way to bundle multiple lines of code together to run as one block of code. Many functions accept input, called arguments, and produce output. Python has many built-in functions such as type(), len() and pow(). In this chapter you will learn how to create user-defined functions in Python.

By the end of this chapter you will be able to:

  • Call functions in Python

  • Import functions into Python scripts

  • Create user-defined functions

  • Create functions with default arguments

  • Utilize functions with positional and keyword arguments

  • Write reusable code for other problem solvers to use