School Revise · Class 11 Informatics Practices · Chapter 3
Code 065, Class 11. Programs make choices and repeat work. Here we use if for decisions and for and while loops for repetition.
|
|
By default Python runs top to bottom. if makes decisions and loops repeat work. This is the flow of control.
An if runs a block when a condition is True; elif checks another; else runs when none are. Indent the block by four spaces.
|
n = 8 if n % 2 == 0: print(“even”) else: print(“odd”) Output: even |
for repeats over a range. range(1, 6) gives 1, 2, 3, 4, 5.
while repeats while a condition is True. Change something inside so it can end. break stops a loop, continue skips to the next round.
Explore the idea by tapping. The interactive opens right here in the lesson.
Write and run real Python right here in the lesson, then work through the practice problems with answers.
Type each one into the code lab above, then open the card to see the worked solution and its output.
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
SOLUTION
OUTPUT
while.
1, 2, 3, 4, 5.
else.
break.
|
if (with elif and else) makes decisions; a for loop repeats over a range (range(1, n) stops before n); a while loop repeats while a condition is True. break stops a loop and continue skips a round. Indent blocks by four spaces. |
| Open the Virtual Lab |
These free Class 11 Informatics Practices notes explain control flow, if elif and else, for and while loops, range, break and continue with worked examples and practice, for CBSE students across India and the Gulf including the UAE, Saudi Arabia, Qatar, Oman, Kuwait and Bahrain.
© 2026 School Revise. All rights reserved. Original content aligned to the CBSE and NCERT Class 11 Informatics Practices syllabus. Unauthorised copying is not permitted.