thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

DevOps & Automation · Foundational

Python Function

A reusable block of Python code defined with def that takes parameters and optionally returns a value.

Definition

Functions support positional, keyword, default, *args, and **kwargs parameters. Variables follow LEGB scope rules. Functions are first-class objects and can be passed as arguments.

Example

def get_vlans(host, *, timeout=10): ...

Exam tip

A function without a return statement returns None.

Related terms