✅ Step-by-step Explanation:
n = 12
-
A variable n is assigned the value 12.
if n > 5:
-
This checks if n is greater than 5.
-
Since 12 > 5, the condition is True, so the code inside this block runs.
✅ Output:
if n < 15:
-
This is a nested if — it only runs if the outer if was True (which it is).
-
It checks if n < 15, and 12 < 15 is True.
✅ Output:
else:
-
This else belongs to the first if (if n > 5).
-
Since the first if is True, this else block is skipped.
❌ So "Bye" is not printed.
✅ Final Output:
Summary:
if statements can be nested.
-
Only the relevant blocks are executed depending on whether conditions are True or False.


0 Comments:
Post a Comment