Skip to content

Chapter 5: Functions

Functions are blocks of code that perform a specific task. They help to break down programs into smaller, manageable parts.

Defining a Function

Python
def greet(name):
    print(f"Hello, {name}!")

This function takes a name as an argument and prints a greeting.