← Python Programming learning path
Python Programming · Module 8 of 10

Functions

Functions package reusable steps with def, parameters and return values.

📖 Key ideas

  1. def name(params): defines a function.
  2. Parameters receive values; return sends a result back.
  3. A function without return gives None.
  4. Default parameters: def greet(name="Guest").
  5. Variables inside a function are local to it.
💡 Real-life example: A function is a juice machine: put fruit in (arguments), get juice out (return value), use it as many times as you like.
defKeyword to define a function
returnSends a value back
ParameterName that receives an input value
NoneValue returned when nothing is returned