Topic 0 · Programming Fundamentals (Python)
Computer Science · Cheatsheet

Topic 0 · Programming Fundamentals (Python)

Chapter 2 · Functions, parameters & scope

📋 Reference · always available
Function
`def avg(a,b,c): return (a+b+c)/3`. Define once, call many.
Parameter vs argument
Parameter = name in the def; argument = value passed in the call.
return
Sends a value back AND ends the function. `return` ≠ `print`.
Scope
A name made inside a function is local — gone when it ends.
Value vs reference
Reassigning an int doesn't affect the caller; *mutating* a list does.