Control Structures: Sequence, Selection and Repetition – Grade 13 A/L ICT Notes 9.8

© 2026 schoolict.net (Ruwan Mangala Suraweera)

9.8 Control Structures: Sequence, Selection and Repetitionපාලන ව්‍යුහ: අනුක්‍රමය, වරණය සහ පුනරාවර්තනය

Grade 13 A/L ICT · Lesson 913 ශ්‍රේණිය A/L ICT · පාඩම 9

Prints all tabs in the language you are reading. Use “Save as PDF” in the print window to keep a copy.ඔබ කියවන භාෂාවෙන් සියලු tabs මුද්‍රණය වේ. පිටපතක් තියාගන්න print window එකේ “Save as PDF” තෝරන්න.
🎬Video coming soon in this language. Switch language to watch the other video.මේ භාෂාවෙන් වීඩියෝව ඉක්මනින් එනවා. අනෙක් වීඩියෝව බලන්න භාෂාව මාරු කරන්න.

In this videoමේ වීඩියෝවේ

  • Sequence, selection and repetition build every algorithm.අනුක්‍රමය, වරණය, පුනරාවර්තනය.
  • if/elif/else tests conditions in order.if/elif/else පිළිවෙළට පරීක්ෂා කරයි.
  • for = iteration with a known count.for = දන්නා වාර.
  • while = looping until a condition is False.while = කොන්දේසිය අසත්‍ය තුරු.
  • Structures can be nested.ව්‍යුහ කූඩු කළ හැක.
Control structureSequenceSelectionRepetitionIterationLoopingif statement

Notesසටහන්

Syllabus 9.8. Every algorithm is built from three control structures: sequence (steps in order), selection (if / elif / else) and repetition – iteration with a known count (for) and looping while a condition is true (while). Structures can be nested inside each other.විෂය නිර්දේශය 9.8. සෑම ඇල්ගොරිතමයක්ම පාලන ව්‍යුහ තුනකින් ගොඩනැගේ: අනුක්‍රමය (පිළිවෙළට පියවර), වරණය (if / elif / else) සහ පුනරාවර්තනය – දන්නා වාර ගණනක් සඳහා iteration (for) සහ කොන්දේසියක් සත්‍ය වන තුරු looping (while). ව්‍යුහ එකක් තුළ තවත් එකක් කූඩු කළ හැක.

1. The three structures1. ව්‍යුහ තුන

1
Sequenceඅනුක්‍රමය
Statements run one after another.ප්‍රකාශ එකින් එක ධාවනය වේ.
2
Selectionවරණය
if, elif, else choose a path using a condition.කොන්දේසියක් මගින් මාර්ගය තෝරයි.
3
Repetitionපුනරාවර්තනය
for repeats a set number of times; while repeats while a condition is True.for නියමිත වාර ගණනක්; while කොන්දේසිය සත්‍ය තුරු.

🐍 Sequence, selection and repetitionඅනුක්‍රමය, වරණය සහ පුනරාවර්තනය

mark = 67
if mark >= 75:
    print("A")
elif mark >= 65:
    print("B")
elif mark >= 50:
    print("C")
else:
    print("F")

for i in range(1, 4):        # iteration (count-controlled)
    print(i, end=" ")
print()

n = 472                      # looping (condition-controlled)
digit_sum = 0
while n > 0:
    digit_sum += n % 10
    n = n // 10
print("Digit sum:", digit_sum)

for r in range(1, 4):        # nested loops
    for c in range(1, 4):
        print(r * c, end=" ")
    print()

▶ Outputප්‍රතිදානය

B
1 2 3 
Digit sum: 13
1 2 3 
2 4 6 
3 6 9 
🧮 Worked exampleවිසඳූ උදාහරණය Why does mark 67 print B?ලකුණ 67 B මුද්‍රණය කරන්නේ ඇයි?
Conditions are tested in order: 67 ≥ 75 is False, 67 ≥ 65 is True, so B is printed and the rest are skipped.කොන්දේසි පිළිවෙළට: 67 ≥ 75 False, 67 ≥ 65 True, එබැවින් B; ඉතිරිය මඟ හැරේ.

2. Tracing the while loop2. while ලූපය අනුරේඛනය

Startn = 472, digit_sum = 0n > 0?Yesdigit_sum = digit_sum + n % 10n = n // 10NoOUTPUT digit_sumStop
Flowchart: sum of digits of 472ගැලීම් සටහන: 472 හි ඉලක්කම් එකතුව
n % 10n % 10digit_sumdigit_sumn after // 10// 10 පසු n
22224747
779944
44131300
🧮 Worked exampleවිසඳූ උදාහරණය Trace the digit-sum loop for 472.472 සඳහා අනුරේඛනය.
The loop runs 3 times: 2 → sum 2, 7 → sum 9, 4 → sum 13. n becomes 0, the condition is False and it prints Digit sum: 13.ලූපය 3 වරක් ධාවනය වේ; n 0 වූ විට නවතී; 13 මුද්‍රණය කරයි.
💡 Use for when you know how many times; use while when you stop on a condition. Indentation shows what is inside.වාර ගණන දන්නේ නම් for; කොන්දේසියකින් නවතින්නේ නම් while. indent කිරීම ඇතුළත ඇති දේ පෙන්වයි.
🚀 Beyond the syllabus (2026 update)🚀 විෂය නිර්දේශයෙන් ඔබ්බට (2026 යාවත්කාලීනය) Not required for the exam – read for interest.විභාගයට අවශ්‍ය නැත – දැනුම සඳහා කියවන්න. Python 3.10+ adds match-case, a neat multi-way selection that many 2026 programs use instead of long elif chains.Python 3.10+ match-case එක් කරයි; දිගු elif දාම වෙනුවට 2026 බොහෝ වැඩසටහන් භාවිත කරයි.

Key Wordsප්‍රධාන පද

Control structureපාලන ව්‍යුහය
Way of controlling the order in which statements run.ප්‍රකාශ ධාවනය වන පිළිවෙළ පාලනය කරන ක්‍රමය.
Sequenceඅනුක්‍රමය
Statements executed one after another.එකින් එක ධාවනය වන ප්‍රකාශ.
Selectionවරණය
Choosing a path depending on a condition.කොන්දේසියක් අනුව මාර්ගයක් තේරීම.
Repetitionපුනරාවර්තනය
Running a block of statements more than once.ප්‍රකාශ කොටසක් වරකට වඩා ධාවනය.
IterationIteration
Count-controlled repetition such as a for loop.for වැනි ගණන් පාලිත පුනරාවර්තනය.
LoopingLooping
Condition-controlled repetition such as a while loop.while වැනි කොන්දේසි පාලිත පුනරාවර්තනය.
if statementif ප්‍රකාශය
Runs a block only when its condition is True.කොන්දේසිය සත්‍ය නම් පමණක් ධාවනය.
elifelif
Further condition tested when earlier ones are False.පෙර ඒවා අසත්‍ය වූ විට පරීක්ෂා කරන තවත් කොන්දේසිය.
for loopfor ලූපය
Repeats for each value in a range or sequence.පරාසයක සෑම අගයකටම පුනරාවර්තනය.
while loopwhile ලූපය
Repeats while a condition stays True.කොන්දේසිය සත්‍ය තුරු පුනරාවර්තනය.
Nested structureකූඩු ව්‍යුහය
A control structure placed inside another.තවත් එකක් තුළ ඇති පාලන ව්‍යුහය.
Infinite loopඅනන්ත ලූපය
Loop whose condition never becomes False.කොන්දේසිය කිසි විටෙක අසත්‍ය නොවන ලූපය.

Sample Q&Aආදර්ශ ප්‍රශ්න සහ පිළිතුරු

1Three control structures?පාලන ව්‍යුහ තුන?

Answerපිළිතුර: Sequence, selection, repetition.අනුක්‍රමය, වරණය, පුනරාවර්තනය.

2Iteration vs looping?Iteration සහ looping?

Answerපිළිතුර: Iteration is count-controlled (for); looping is condition-controlled (while).for; while.

3What does range(1, 4) give?range(1, 4)?

Answerපිළිතුර: 1, 2, 3.1, 2, 3.

4Digit sum of 472?472 ඉලක්කම් එකතුව?

Answerපිළිතුර: 13.13.

5Last row of the 3 × 3 table?3 × 3 අවසන් පේළිය?

Answerපිළිතුර: 3 6 9.3 6 9.

6What causes an infinite loop?අනන්ත ලූපය?

Answerපිළිතුර: A condition that never becomes False, e.g. forgetting n = n // 10.කොන්දේසිය අසත්‍ය නොවීම.

MCQබහුවරණ ප්‍රශ්න

Choose the correct answer for each question.සෑම ප්‍රශ්නයකටම නිවැරදි පිළිතුර තෝරන්න.

Scoreලකුණු: 0 / 20

1if / elif / else is an example ofif

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D

Selection.වරණය.

2A for loop over range(1, 4) isfor

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A

Iteration.Iteration.

3Mark 67 in the program prints67

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D

67 ≥ 65.67 ≥ 65.

4range(1, 4) producesrange(1, 4)

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: E

Stop excluded.4 ඇතුළත් නොවේ.

5The digit sum of 472 printed is472

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: E

4 + 7 + 2.4 + 7 + 2.

6The while loop body runs for 472වාර

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D

Three digits.ඉලක්කම් 3.

7Placing a loop inside another loop isකූඩු

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B

Nested.කූඩු.

8The middle row of the nested 3 × 3 table isමැද පේළිය

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D

2 × 1..3.2 × 1..3.

9Which term means: “Way of controlling the order in which statements run”?“ප්‍රකාශ ධාවනය වන පිළිවෙළ පාලනය කරන ක්‍රමය” යන්නෙන් අදහස් වන පදය කුමක්ද?

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C

Control structure – Way of controlling the order in which statements run.පාලන ව්‍යුහය – ප්‍රකාශ ධාවනය වන පිළිවෙළ පාලනය කරන ක්‍රමය.

10Which term means: “Statements executed one after another”?“එකින් එක ධාවනය වන ප්‍රකාශ” යන්නෙන් අදහස් වන පදය කුමක්ද?

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B

Sequence – Statements executed one after another.අනුක්‍රමය – එකින් එක ධාවනය වන ප්‍රකාශ.

11Which term means: “Choosing a path depending on a condition”?“කොන්දේසියක් අනුව මාර්ගයක් තේරීම” යන්නෙන් අදහස් වන පදය කුමක්ද?

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C

Selection – Choosing a path depending on a condition.වරණය – කොන්දේසියක් අනුව මාර්ගයක් තේරීම.

12Which term means: “Running a block of statements more than once”?“ප්‍රකාශ කොටසක් වරකට වඩා ධාවනය” යන්නෙන් අදහස් වන පදය කුමක්ද?

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A

Repetition – Running a block of statements more than once.පුනරාවර්තනය – ප්‍රකාශ කොටසක් වරකට වඩා ධාවනය.

13Which term means: “Count-controlled repetition such as a for loop”?“for වැනි ගණන් පාලිත පුනරාවර්තනය” යන්නෙන් අදහස් වන පදය කුමක්ද?

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B

Iteration – Count-controlled repetition such as a for loop.Iteration – for වැනි ගණන් පාලිත පුනරාවර්තනය.

14Which term means: “Condition-controlled repetition such as a while loop”?“while වැනි කොන්දේසි පාලිත පුනරාවර්තනය” යන්නෙන් අදහස් වන පදය කුමක්ද?

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A

Looping – Condition-controlled repetition such as a while loop.Looping – while වැනි කොන්දේසි පාලිත පුනරාවර්තනය.

15Which term means: “Runs a block only when its condition is True”?“කොන්දේසිය සත්‍ය නම් පමණක් ධාවනය” යන්නෙන් අදහස් වන පදය කුමක්ද?

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C

if statement – Runs a block only when its condition is True.if ප්‍රකාශය – කොන්දේසිය සත්‍ය නම් පමණක් ධාවනය.

16Which term means: “Further condition tested when earlier ones are False”?“පෙර ඒවා අසත්‍ය වූ විට පරීක්ෂා කරන තවත් කොන්දේසිය” යන්නෙන් අදහස් වන පදය කුමක්ද?

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: E

elif – Further condition tested when earlier ones are False.elif – පෙර ඒවා අසත්‍ය වූ විට පරීක්ෂා කරන තවත් කොන්දේසිය.

17Which term means: “Repeats for each value in a range or sequence”?“පරාසයක සෑම අගයකටම පුනරාවර්තනය” යන්නෙන් අදහස් වන පදය කුමක්ද?

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C

for loop – Repeats for each value in a range or sequence.for ලූපය – පරාසයක සෑම අගයකටම පුනරාවර්තනය.

18Which term means: “Repeats while a condition stays True”?“කොන්දේසිය සත්‍ය තුරු පුනරාවර්තනය” යන්නෙන් අදහස් වන පදය කුමක්ද?

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B

while loop – Repeats while a condition stays True.while ලූපය – කොන්දේසිය සත්‍ය තුරු පුනරාවර්තනය.

19Which term means: “A control structure placed inside another”?“තවත් එකක් තුළ ඇති පාලන ව්‍යුහය” යන්නෙන් අදහස් වන පදය කුමක්ද?

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A

Nested structure – A control structure placed inside another.කූඩු ව්‍යුහය – තවත් එකක් තුළ ඇති පාලන ව්‍යුහය.

20Which term means: “Loop whose condition never becomes False”?“කොන්දේසිය කිසි විටෙක අසත්‍ය නොවන ලූපය” යන්නෙන් අදහස් වන පදය කුමක්ද?

✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: E

Infinite loop – Loop whose condition never becomes False.අනන්ත ලූපය – කොන්දේසිය කිසි විටෙක අසත්‍ය නොවන ලූපය.

MCQ answer keyMCQ පිළිතුරු

  1. D – Selection.වරණය.
  2. A – Iteration.Iteration.
  3. D – 67 ≥ 65.67 ≥ 65.
  4. E – Stop excluded.4 ඇතුළත් නොවේ.
  5. E – 4 + 7 + 2.4 + 7 + 2.
  6. D – Three digits.ඉලක්කම් 3.
  7. B – Nested.කූඩු.
  8. D – 2 × 1..3.2 × 1..3.
  9. C – Control structure – Way of controlling the order in which statements run.පාලන ව්‍යුහය – ප්‍රකාශ ධාවනය වන පිළිවෙළ පාලනය කරන ක්‍රමය.
  10. B – Sequence – Statements executed one after another.අනුක්‍රමය – එකින් එක ධාවනය වන ප්‍රකාශ.
  11. C – Selection – Choosing a path depending on a condition.වරණය – කොන්දේසියක් අනුව මාර්ගයක් තේරීම.
  12. A – Repetition – Running a block of statements more than once.පුනරාවර්තනය – ප්‍රකාශ කොටසක් වරකට වඩා ධාවනය.
  13. B – Iteration – Count-controlled repetition such as a for loop.Iteration – for වැනි ගණන් පාලිත පුනරාවර්තනය.
  14. A – Looping – Condition-controlled repetition such as a while loop.Looping – while වැනි කොන්දේසි පාලිත පුනරාවර්තනය.
  15. C – if statement – Runs a block only when its condition is True.if ප්‍රකාශය – කොන්දේසිය සත්‍ය නම් පමණක් ධාවනය.
  16. E – elif – Further condition tested when earlier ones are False.elif – පෙර ඒවා අසත්‍ය වූ විට පරීක්ෂා කරන තවත් කොන්දේසිය.
  17. C – for loop – Repeats for each value in a range or sequence.for ලූපය – පරාසයක සෑම අගයකටම පුනරාවර්තනය.
  18. B – while loop – Repeats while a condition stays True.while ලූපය – කොන්දේසිය සත්‍ය තුරු පුනරාවර්තනය.
  19. A – Nested structure – A control structure placed inside another.කූඩු ව්‍යුහය – තවත් එකක් තුළ ඇති පාලන ව්‍යුහය.
  20. E – Infinite loop – Loop whose condition never becomes False.අනන්ත ලූපය – කොන්දේසිය කිසි විටෙක අසත්‍ය නොවන ලූපය.

Structured Questionsව්‍යුහගත ප්‍රශ්න

1Describe the three control structures with Python examples.ව්‍යුහ තුන. (3 marksලකුණු 3)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
Sequence statements; selection if/elif/else; repetition for/while.අනුක්‍රමය; වරණය; පුනරාවර්තනය.

2Write a program that prints A, B, C or F for a mark.ශ්‍රේණි වැඩසටහන. (4 marksලකුණු 4)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
if >= 75 A; elif >= 65 B; elif >= 50 C; else F.if; elif; else.

3Trace the digit-sum loop for 472.අනුරේඛනය. (4 marksලකුණු 4)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
2/2/47; 7/9/4; 4/13/0; output 13.පේළි 3; 13.

4Compare for and while loops.for සහ while. (3 marksලකුණු 3)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
for known count; while condition; both repeat a block.ගණන; කොන්දේසිය.

5Write nested loops to print a 3 × 3 multiplication table.කූඩු ලූප. (4 marksලකුණු 4)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
for r in range(1, 4); for c in range(1, 4); print(r * c, end); print().for; for; print.

🎮 Game🎮 ක්‍රීඩා

Pick a game. Each one uses words from this lesson.ක්‍රීඩාවක් තෝරන්න. හැම එකක්ම මේ පාඩමේ වචන පාවිච්චි කරනවා.

Summary & Downloadsසාරාංශය සහ බාගත කිරීම්

Key pointsප්‍රධාන කරුණු

  • Sequence, selection and repetition build every algorithm.අනුක්‍රමය, වරණය, පුනරාවර්තනය.
  • if/elif/else tests conditions in order.if/elif/else පිළිවෙළට පරීක්ෂා කරයි.
  • for = iteration with a known count.for = දන්නා වාර.
  • while = looping until a condition is False.while = කොන්දේසිය අසත්‍ය තුරු.
  • Structures can be nested.ව්‍යුහ කූඩු කළ හැක.

Downloadsබාගත කිරීම්

Full Lesson 9 PDFසම්පූර්ණ පාඩම 9 PDF: English · සිංහල

Next noteඊළඟ සටහන 9.9 →

© 2026 schoolict.net (Ruwan Mangala Suraweera). All rights reserved.සියලු හිමිකම් ඇවිරිණි.

Resource Book Lesson Note Download Questions Syllabus Sinhala LMS Simulator Tool