Functions and Lambda

Lesson 6 of 20

Package logic into functions and lambdas — watch arguments flow in and return values travel back out.

The big picture

Package your logic

Functions let you name a chunk of work once and reuse it everywhere — with values flowing in and out.

def Defines It

def greet(name): stores the function — the body only runs when you call it.

Parameters In

Arguments like "Ada" land in the parameters, which are local to each call.

return Sends Back

return hands a value to the caller and ends the call immediately.

lambda = One-Liner

lambda n: n * 2 is a tiny nameless function built from a single expression.