© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
K. WilsonThe Absolute Beginner's Guide to Python Programminghttps://doi.org/10.1007/978-1-4842-8716-3_6

6. Using Functions

Kevin Wilson1  
(1)
London, UK
 

Functions help break a program into smaller pieces. This avoids repetition of code, making larger programs more efficient and easier to maintain.

A function is a block of code that is only executed when called within a program.

You can pass data to the function. This data is known as a parameter or argument.

Arguments or parameters are specified inside parentheses after the function name, for example:
functionName(parameters)

A function can return data as a result.

Declaring Functions

You can declare a new function ...

Get The Absolute Beginner's Guide to Python Programming: A Step-by-Step Guide with Examples and Lab Exercises now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.