This week’s topics
Functions: reusable code
- Defining and calling a function
- Parameters and return values
What you will be able to do
- 3.1 Define and call functions to modularise code.
Activity
Rewrite an earlier program using functions.
Study materials
Further resources
- Introduction to Python Programming, ch. 6: Functions · PDF · OpenStax Introduction to Python Programming (2024), ch. 6: defining and calling functions, parameters and return values, pp. 137–163 · for registered students
- Think Python, ch. 3: Functions · PDF · Downey, Think Python 2e (Green Tea Press), ch. 3: defining functions, parameters and arguments, pp. 17–28 · for registered students
- Think Python, ch. 6: Fruitful functions · PDF · Downey, Think Python 2e (Green Tea Press), ch. 6: return values, pp. 51–62 · for registered students
- Understanding students' failure to use functions as a tool for abstraction (CS1 Python) · Open-access article · Haglund et al. (2021), Informatics in Education. Why Python beginners avoid writing their own functions, with examples. · for registered students
Materials marked “for registered students” open in the student portal, which is set up as soon as you receive final acceptance.