Function Definition Property
if the following are true:
- the line at time t = i
- the tab at time t = j
- statement at line i, tab j = function definition where name: name and parameters: params
then there is a function named name with parameters params at line line
If the current statement is a function definition, LW Python will remember the name of the function, parameters required by the function, and the location (line number). For example,
if the following are true:
- the line at time 0 = 1
- the tab at time 0 = 0
- statement at line 1, tab 0 =
def add_three(x):
then there is a function named "add_three" with parameters [ x, [ ] ] at line 1
Code Editor
LW Python State
Current Line | 1 | Current Tab | 0 | Time | 0 |
LW Python Simulator
Try stepping through the simulator to see the "add_three" function location added to the "Functions" table.
Quiz (1 point)
In the example above, what is the name of the function defined in line 1?
Quiz (1 point)
In the example above, how many parameters does the "add_three" function require?
Comments
Please log in to add comments