While Test False Property

If there is a "while" statement at the current line and tab and the "while" test evaluated to False at time t, then at time t + 1, the tab number remains the same. 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 = False

then the tab at time (t + 1) = j

When the "while" statement test is False, Python skips the "while" statement body. This is done by incrementing the line number but keeping the tab number the same.

For example, if the following are true:

  • the line at time 62 = 2
  • the tab at time 62 = 0
  • statement at line 2, tab 0 = while __lt__(a, 2):
  • expression state at time 62 = "end_expr"
  • Return Value at time 62 = False

then the tab at time (62 + 1) = 0

Try stepping through the simulator. Initially, the condition "a < 2" is True, so the tab goes from 0 to 1. But in each iteration, the value of "a" increments by 1. When "a" is 2, the condition "a < 2" is False, and the "Current Tab" will remain at 0, and line 3 will be skipped.

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments