Matric exams start 16 Mar 2027 · 116 days left Notes →

Class 10 Computer · Chapter 4

Class 10 Computer Chapter 4 Notes – Control Structures in Python (New Syllabus 2026-27)

Free 10th class computer chapter 4 notes for Control Structures in Python, written for the new 2026-27 Punjab Board book. You get clear definitions, short Python programs you can run yourself, and simple explanations of decisions and loops. Read the overview below or download the full notes as a free PDF.

  • New syllabus 2026-27
  • Punjab Boards
  • 4 free PDFs · no sign-up
  • Updated · checked by Sir Bilal, MCS

Free PDFs

All Chapter 4 downloads

Every PDF for Chapter 4: notes, short questions, MCQs and exercise solutions. Free to read online or download, no sign-up.

Overview

What Chapter 4 Control Structures in Python is about

Class 10 Computer Chapter 4 Notes – Control Structures in Python

Chapter 4 shows how a Python program makes decisions and repeats work. With if, elif and else a program picks a path, for example printing a grade from a student's marks or checking whether a mobile balance is enough for a package. With for and while loops it repeats steps, such as printing a multiplication table or adding up a shopkeeper's daily sales. You will also use range(), stop or skip loop steps with break and continue, and place one structure inside another. Indentation matters a lot in this chapter.

Chapter 4 Control Structures in Python at a glance: control structures, if, elif and else, the for loop, the while loop, break and continue, and nested structures4.1Control structuresSequence, selection, repetition4.2if, elif and elseChoose a path with a condition4.3The for loopRepeat for each item4.4The while loopRepeat while a condition is True4.5break and continueStop a loop or skip a step4.6Nested structuresA loop or if inside another
Chapter 4 at a glance: the six topics in the order the notes teach them, with the one idea or formula to remember for each.

Topics covered in the notes

  • 4.1 Control structures: the three ways a program flows.
  • 4.2 if, elif and else: conditions, comparison and logical operators, indentation.
  • 4.3 The for loop: looping over lists, strings and range().
  • 4.4 The while loop: counters, stopping conditions and infinite loops.
  • 4.5 break and continue: leaving a loop early and skipping one pass.
  • 4.6 Nested structures: nested if statements and nested loops for patterns.

Key terms

  • Control structure is a statement that decides the order in which the lines of a program run: in sequence, by selection or by repetition.
  • Condition is an expression that gives True or False, such as marks >= 33. Python uses it to decide what to do next.
  • Loop is a block of code that runs again and again, either for each item in a sequence (for) or while a condition stays True (while).
  • range() is a built-in function that produces a sequence of whole numbers. range(1, 6) gives 1, 2, 3, 4, 5: the stop value is not included.
  • Infinite loop is a loop whose condition never becomes False, so it never ends. It usually happens when the counter is not updated.
  • Indentation is the space at the start of a line. In Python it shows which statements belong inside an if block or a loop.

Code examples

Grade from marks with if, elif and else
marks = 78
if marks >= 80:
    print("Grade A+")
elif marks >= 70:
    print("Grade A")
elif marks >= 60:
    print("Grade B")
else:
    print("Keep practising")
# Output: Grade A
Multiplication table with for and range()
n = 7
for i in range(1, 11):
    print(n, "x", i, "=", n * i)
# Output: 7 x 1 = 7 ... 7 x 10 = 70
while loop with continue and break
total = 0
num = 0
while True:
    num = num + 1
    if num > 10:
        break          # leave the loop
    if num % 2 == 0:
        continue       # skip even numbers
    total = total + num
print("Sum of odd numbers 1 to 10:", total)
# Output: Sum of odd numbers 1 to 10: 25
Nested loops: a star triangle
for row in range(1, 5):
    for star in range(row):
        print("*", end="")
    print()
# Output:
# *
# **
# ***
# ****

Questions students ask

What is the difference between a for loop and a while loop?

Use a for loop when you know how many times to repeat or want to go through each item of a list or string. Use a while loop when you repeat until a condition becomes False and you do not know the count in advance.

Why does range(1, 10) stop at 9?

In Python the stop value of range() is never included. range(1, 10) gives 1 to 9, so write range(1, 11) if you want 1 to 10.

What is the difference between break and continue?

break ends the whole loop at once and the program moves to the line after the loop. continue only skips the rest of the current pass and the loop carries on with the next value.

Why do I get an IndentationError?

Python uses spaces at the start of a line to know which statements are inside an if block or loop. Every line in the same block must have the same indentation, usually 4 spaces, and the line before the block must end with a colon.