🧩 Functions
Unit 2 · Programming building blocks · 9 min
A function is a named, reusable block of code. It takes inputs (parameters) and returns an output. Python: def area(w, h): return w * h. Calling area(3, 4) gives 12. A good function does one thing.
Words in this lesson
- 函数 (hán shù) — function
- 参数 (cān shù) — parameter
Project: Write bmi(weight, height) and test it on your own numbers.