Think Python¶
(1-3 hours)
Chapter 3 of Think Python until the end of the second exercisetriangle. We will cover the rest in the class.
At the end of the reading you try to explain the following concepts and why they are important for Python programming. If you have doubts, note them and write them in Discussions, and move on. We will focus on these points in the next lecture.
Functions
definition syntax
header vs body
parameter
calling functions
useful for avoiding repeated code
repetition (iteration)
structure
for,range
Visibility of variables and parameters
NameError
Stack diagram
Usefulness for function calls
Traceback
When do we get a traceback?
Relation between a traceback and stack diagram
Four motivations for functions
Debugging
Like experiments: You set a hypothesis, then try it in code.
Tip: Write only small amount and try immediately.