While Test True Tab Property
If there is a while statement at the current line and tab and the "while" test evaluated to True at time t, then at time t + 1, the tab number is incremented by 1. More formally,
if the following are true:
- the line at time t = i
- the tab at time t = j
- statement at line i, tab j = "while" statement with condition (function call with name: name and arguments: args)
- expression state at time t = "end_expr"
- Return Value at time t = True
then the tab at time (t + 1) = j + 1
When the "while" statement test is True, Python starts executing the "while" statement body. This is done by incrementing both the line and tab numbers by 1.
For example,
if the following are true:
- the line at time 11 = 2
- the tab at time 11 = 0
- statement at line 2, tab 0 =
while __lt__(a, 2):
- expression state at time 11 = "end_expr"
- Return Value at time 11 = True
then the tab at time (11 + 1) = 0 + 1
Try stepping through the simulator to see LW Python change the "Current Tab" from 0 to 1.
Code Editor
LW Python State
Current Line | 1 | Current Tab | 0 | Time | 0 |
LW Python Simulator
Comments
Please log in to add comments