Checkpoint 8.9.1.
- 1, 2, 3, 5, 6, 7 9, 10, 11
- The statements inside functions are not executed until the function is called.
- 9, 10, 11, 1, 2, 3, 5, 6, 7
- The function headers (lines 1 and 5) are executed first, that is how Python knows that the functions exist when they are called later.
- 9, 10, 11, 5, 6, 7, 1, 2, 3,
- The function headers (lines 1 and 5) are executed first, that is how Python knows that the functions exist when they are called later.
- 1, 5, 9, 10, 5, 6, 1, 2, 3, 6, 7, 10, 11
- Yes, the lines that have function calls in them appear twice, we get to the line, call the function and then return to that statement (this is when we assign return values - after we come back from the function that was called).
- 1, 5, 9, 10, 5, 6, 7, 1, 2, 3, 11
- Notice that the pow function is called while in the middle of executing the square function, not after the square function is done.
Consider the following Python code. Note that line numbers are included on the left.
def pow(b, p):
y = b ** p
return y
def square(x):
a = pow(x, 2)
return a
n = 5
result = square(n)
print(result)
Refering to the line numbers, in what order are the statements excuted?