0
Functions1 / 4

CRASH COURSE

Functions

A function is a named recipe. Define it once with def, then call it as many times as you like.

  • Parameters are the inputs. return sends a value back to whoever called the function.
  • Functions keep code organized: each one does one job, and you can test it on its own.
def greet(name):
    return f"Hello, {name}!"

def area(width, height):
    return width * height

print(greet("Ada"))
print(f"Area: {area(5, 3)}")