Link Search Menu Expand Document

Functions

Table of contents

  1. Description
  2. Types
  3. Instructional Videos

Description

A function is a prewritten block of code with a name. A function is invoked by calling its name. Functions are used to eliminate repition in code. They optionally include/require:

  • arguments: the function’s input; data given to the function enclosed within the parenthesis.
  • return: the function’s output; data passed back to the line of code that called it.

Types

  1. Built-in Functions: These functions come pre-installed with Python. Common examples are print(), input(), len(), etc.
  2. User-defined functions: These are custom functions defined by a programmer. After the programmer defines a custom function, the function can be invoked by its name.
  3. Imported functions: These functions are written in a module (aka python file) other than the file you are creating. An import statement at the top of your program allows you to use all the functions in that file (module).

Instructional Videos