Functions are one of the first "real" programming concepts you hit in Python, and they're also one of the most important.

Once you understand how to package logic into a function, you stop repeating yourself and start building code that's actually reusable and testable.

1. Defining and Calling Functions

A function is a named block of code that runs only when you call it. You define one with the def keyword:

def greet():