Chapter 2 B1U4 Functions
This is supplementary material for the corresponding lesson from Python for Everybody.
2.1 Lecture on Functions
- Do not repeat yourself!
- Origins of duplications.
- Types of duplications:
- copy-paste or copy-paste-adapt of code,
- across representations.
- Strategies of avoiding duplications.
- Characteristics of well-defined functions.
- Iterative process of writing functions.
- Visibilites of variables: built-in, global and local.
- Lookup rule for variables.
- Exchanging data between scopes.
- Returning vs. printing value.
- Illustative examples for python tutor.
- Functions import
- Direct and indirect program interpretation.
- All-inclusive vs. modular solution.
- Distinction of direct and indirect running of a program.
- Different options for importing.
- Characteristics of good comments.
- In-code documentation with docstring.
Slides only: raising exceptions.
- The Pragmatic Programmer: your journey to mastery by David Thomas, Andrew Hunt
- Clean Code: A Handbook of Agile Software Craftsmanship by Robert C. Martin
20S198891 U04 functions 01 duplications
20S198891 U04 functions 02 functions
20S198891 U04 functions 03 scopes
20S198801 U04 L05 functions import
20S198891 U04 functions 04 comments
total duration: 59:30
2.2 Exercises on Functions
- Program / SQFeet’s video is silent on purpose, you should read the description instead of listening
- Exercises / Reuse is explained in the lecture video
- Best Practices / Docstring is explained in the lecture video
20S198891 U04 functions 10 demo tasks
198801 U06 Functions Programs SqFeet demo
total duration: 06:07
- the material is provided in OLAT