Concept Flow - If–else execution flow
Start
Evaluate Condition
Execute If
End
The program checks a condition. If true, it runs the 'if' block; if false, it runs the 'else' block, then continues.
x = 10 if x > 5: print("x is greater than 5") else: print("x is 5 or less")
| Step | Condition (x > 5) | Result | Branch Taken | Output |
|---|---|---|---|---|
| 1 | 10 > 5 | True | If block | "x is greater than 5" printed |
| 2 | - | - | End | Execution stops after if block |
| Variable | Start | After Step 1 | Final |
|---|---|---|---|
| x | undefined | 10 | 10 |
if condition:
# run this if True
else:
# run this if False
The program checks the condition once.
Runs only one block based on True/False.
Then continues after the if-else.