School Revise · Class 11 Computer Science · Chapter 6
Code 083, Class 11. Programs make choices and repeat work. Here we learn if statements for decisions and for and while loops for repetition.
|
|
By default Python runs lines top to bottom. To make decisions we use if statements, and to repeat work we use loops. This is called the flow of control.
An if statement runs a block only when a condition is True. elif checks another condition, and else runs when none are True. The block is indented by four spaces.
|
n = 8 if n % 2 == 0: print(“even”) else: print(“odd”) Output: even |
A for loop repeats over a range of values. range(1, 6) gives 1, 2, 3, 4, 5.
A while loop repeats as long as its condition stays True. Always change something inside so the loop can end. break stops a loop and continue skips to the next round.
Set a condition and a range, and watch which lines run. 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 loop.
1, 2, 3, 4, 5. The last number is not included.
else.
break.
|
Programs run top to bottom unless we change the flow. An if statement (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 to the next round. Indent blocks by four spaces. |
| Open the Virtual Lab |
These free Class 11 Computer Science notes explain flow of control, if elif and else decisions, for and while loops, range, break and continue with worked Python programs 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 Computer Science syllabus. Unauthorised copying is not permitted.