Functions in Python

Functions allow you to encapsulate reusable logic and improve code modularity.

Snippet:

def greet(name):\n    return f"Hello, {name}!"\nprint(greet("Alice"))

Example:

def add(a, b):\n    return a + b\nprint(add(3, 5))