Chapter 2 B1U4 Functions
This is supplementary material for the corresponding lesson from Python for Everybody.
2.1 Lecture on Functions
- Duplications
- Do not repeat yourself!
- Origins of duplications.
- Types of duplications:
- copy-paste or copy-paste-adapt of code,
- across representations.
- Strategies of avoiding duplicates.
- Functions
- Characteristics of well-defined functions.
- Iterative process of writing functions.
- Scopes
- Visibility of variables: built-in, global and local.
- Lookup rule for variables.
- Exchanging data between scopes.
- Returning vs. printing value.
- Illustrative 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.
- Comments
- Characteristics of good comments.
- In-code documentation with docstring.
Slides only: raising exceptions.
Books:
- 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
duration: 16:30
duration: 16:30
20S198891 U04 functions 02 functions
duration: 07:56
duration: 07:56
20S198891 U04 functions 03 scopes
duration: 16:22
duration: 16:22
20S198801 U04 L05 functions import
duration: 08:31
duration: 08:31
20S198891 U04 functions 04 comments
duration: 10:11
duration: 10:11
total duration: 59:30
Slides:
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
duration: 03:02
duration: 03:02
198801 U06 Functions Programs SqFeet demo
duration: 03:05
duration: 03:05
total duration: 06:07
Exercises:
- the material is provided in OLAT