© 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
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.ව්යුහ කූඩු කළ හැක.
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. ව්යුහ තුන
🐍 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
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 ලූපය අනුරේඛනය
| n % 10n % 10 | digit_sumdigit_sum | n after // 10// 10 පසු n |
|---|---|---|
| 22 | 22 | 4747 |
| 77 | 99 | 44 |
| 44 | 1313 | 00 |
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 මුද්රණය කරයි.
Key Wordsප්රධාන පද
Sample Q&Aආදර්ශ ප්රශ්න සහ පිළිතුරු
1Three control structures?පාලන ව්යුහ තුන?
2Iteration vs looping?Iteration සහ looping?
3What does range(1, 4) give?range(1, 4)?
4Digit sum of 472?472 ඉලක්කම් එකතුව?
5Last row of the 3 × 3 table?3 × 3 අවසන් පේළිය?
6What causes an infinite loop?අනන්ත ලූපය?
MCQබහුවරණ ප්රශ්න
Choose the correct answer for each question.සෑම ප්රශ්නයකටම නිවැරදි පිළිතුර තෝරන්න.
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 පිළිතුරු
- D – Selection.වරණය.
- A – Iteration.Iteration.
- D – 67 ≥ 65.67 ≥ 65.
- E – Stop excluded.4 ඇතුළත් නොවේ.
- E – 4 + 7 + 2.4 + 7 + 2.
- D – Three digits.ඉලක්කම් 3.
- B – Nested.කූඩු.
- D – 2 × 1..3.2 × 1..3.
- C – Control structure – Way of controlling the order in which statements run.පාලන ව්යුහය – ප්රකාශ ධාවනය වන පිළිවෙළ පාලනය කරන ක්රමය.
- B – Sequence – Statements executed one after another.අනුක්රමය – එකින් එක ධාවනය වන ප්රකාශ.
- C – Selection – Choosing a path depending on a condition.වරණය – කොන්දේසියක් අනුව මාර්ගයක් තේරීම.
- A – Repetition – Running a block of statements more than once.පුනරාවර්තනය – ප්රකාශ කොටසක් වරකට වඩා ධාවනය.
- B – Iteration – Count-controlled repetition such as a for loop.Iteration – for වැනි ගණන් පාලිත පුනරාවර්තනය.
- A – Looping – Condition-controlled repetition such as a while loop.Looping – while වැනි කොන්දේසි පාලිත පුනරාවර්තනය.
- C – if statement – Runs a block only when its condition is True.if ප්රකාශය – කොන්දේසිය සත්ය නම් පමණක් ධාවනය.
- E – elif – Further condition tested when earlier ones are False.elif – පෙර ඒවා අසත්ය වූ විට පරීක්ෂා කරන තවත් කොන්දේසිය.
- C – for loop – Repeats for each value in a range or sequence.for ලූපය – පරාසයක සෑම අගයකටම පුනරාවර්තනය.
- B – while loop – Repeats while a condition stays True.while ලූපය – කොන්දේසිය සත්ය තුරු පුනරාවර්තනය.
- A – Nested structure – A control structure placed inside another.කූඩු ව්යුහය – තවත් එකක් තුළ ඇති පාලන ව්යුහය.
- 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ආදර්ශ පිළිතුර පෙන්වන්න
2Write a program that prints A, B, C or F for a mark.ශ්රේණි වැඩසටහන. (4 marksලකුණු 4)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
3Trace the digit-sum loop for 472.අනුරේඛනය. (4 marksලකුණු 4)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
4Compare for and while loops.for සහ while. (3 marksලකුණු 3)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
5Write nested loops to print a 3 × 3 multiplication table.කූඩු ලූප. (4 marksලකුණු 4)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
🎮 Game🎮 ක්රීඩා
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බාගත කිරීම්
Resource Book Lesson Note Download Questions Syllabus Sinhala LMS Simulator Tool
