Learn › Class 12 › Computer Science / Informatics Practices › Python revision, functions, exceptions
Functions in Python
Remember
- def name(params): ... return value; no return gives None.
- Positional, default (placed last) and keyword arguments.
- Local variables live inside a function; use global to change a global one.
Quick self-check
What is the difference between a parameter and an argument?
Check
A parameter is the name in the def line; an argument is the actual value passed in the call.
Can a function return more than one value?
Check
Yes, as a tuple: return a, b.