© 2026 schoolict.net (Ruwan Mangala Suraweera)
1.11 Programming Languages, Translators and Debuggingක්රමලේඛන භාෂා, පරිවර්තක සහ දෝෂ නිරාකරණය
G.C.E. O/L Grade 11 ICT · Lesson 1G.C.E. O/L ICT · 11 ශ්රේණිය · පාඩම 1
In this videoමේ වීඩියෝවේ
- Low-level: machine and assembly.පහළ මට්ටම: යන්ත්ර සහ ඇසෙම්බ්ලි.
- High-level: Python, Pascal – need translators.ඉහළ මට්ටම: Python, Pascal – පරිවර්තක අවශ්යයි.
- Compiler: whole program; interpreter: line by line.සම්පාදකය: සම්පූර්ණයෙන්; අර්ථවිනයකය: පේළියෙන් පේළිය.
- Errors: syntax, runtime, logic.දෝෂ: වාක්ය රීති, ධාවන කාල, තාර්කික.
- Use IDEs and AI assistants responsibly.IDE සහ AI සහායක වගකීමෙන් භාවිත කරන්න.
Notesසටහන්
Syllabus 10.11. A computer only understands 0s and 1s. People prefer words like print and if. In this part we see the different kinds of programming languages, how a translator (interpreter or compiler) changes our code into machine code, and how to test and debug a program.විෂය නිර්දේශය 10.11. පරිගණකයක් තේරුම් ගන්නේ 0 සහ 1 පමණි. මිනිසුන් print, if වැනි වචන කැමතියි. මෙම කොටසේ විවිධ ක්රමලේඛන භාෂා වර්ග, පරිවර්තකයක් (අර්ථවිනයක හෝ සම්පාදකයක) අපගේ කේතය යන්ත්ර කේතයට හරවන ආකාරය සහ වැඩසටහනක් පරීක්ෂා කර දෝෂ නිරාකරණය කරන ආකාරය බලමු.
1. Low-level and high-level languages1. පහළ මට්ටමේ සහ ඉහළ මට්ටමේ භාෂා
| Typeවර්ගය | What it looks likeපෙනුම | Notesසටහන් |
|---|---|---|
| Machine languageයන්ත්ර භාෂාව | 10110000 0110000110110000 01100001 | Only 0s and 1s. The CPU runs it directly. Very hard for people.0 සහ 1 පමණි. CPU එක කෙළින්ම ධාවනය කරයි. මිනිසුන්ට ඉතා අපහසුයි. |
| Assembly languageඇසෙම්බ්ලි භාෂාව | MOV AL, 61hMOV AL, 61h | Short words (mnemonics). Needs an assembler. Depends on the CPU.කෙටි වචන (mnemonics). ඇසෙම්බ්ලරයක් අවශ්යයි. CPU එක මත රඳා පවතී. |
| High-level languageඉහළ මට්ටමේ භාෂාව | print(“Hello”)print(“Hello”) | English-like, easy to learn, runs on many computers. Needs a compiler or interpreter. E.g. Python, Pascal, Java, C.ඉංග්රීසි වැනි, ඉගෙනීමට පහසු, බොහෝ පරිගණකවල ධාවනය වේ. සම්පාදකයක් හෝ අර්ථවිනයකයක් අවශ්යයි. උදා Python, Pascal, Java, C. |
Machine and assembly languages are called low-level languages because they are close to the hardware.යන්ත්ර සහ ඇසෙම්බ්ලි භාෂා දෘඪාංගයට සමීප නිසා පහළ මට්ටමේ භාෂා ලෙස හැඳින්වේ.
2. Kinds of high-level languages2. ඉහළ මට්ටමේ භාෂා වර්ග
3. Programming and scripting languages3. ක්රමලේඛන සහ ස්ක්රිප්ටින් භාෂා
Scripting languages are usually interpreted and used to control other software or add actions to web pages – e.g. JavaScript (web pages), PHP (web servers), Python scripts. Programming languages such as C or Pascal are usually compiled into stand-alone programs.ස්ක්රිප්ටින් භාෂා සාමාන්යයෙන් අර්ථවිනයනය කරන අතර වෙනත් මෘදුකාංග පාලනයට හෝ වෙබ් පිටුවලට ක්රියා එක් කිරීමට භාවිත වේ – උදා JavaScript (වෙබ් පිටු), PHP (වෙබ් සේවාදායක), Python ස්ක්රිප්ට්. C හෝ Pascal වැනි ක්රමලේඛන භාෂා සාමාන්යයෙන් ස්වාධීන වැඩසටහන් ලෙස සම්පාදනය කෙරේ.
4. Translators: compiler and interpreter4. පරිවර්තක: සම්පාදකය සහ අර්ථවිනයකය
| Compilerසම්පාදකය | Interpreterඅර්ථවිනයකය | |
|---|---|---|
| How it translatesපරිවර්තනය කරන ආකාරය | the whole program at onceසම්පූර්ණ වැඩසටහනම එකවර | one line at a time, then runs itවරකට එක් පේළියක්, පසුව ධාවනය |
| Outputප්රතිදානය | an executable file (e.g. .exe)ක්රියාත්මක ගොනුවක් (උදා .exe) | no separate fileවෙනම ගොනුවක් නැත |
| Errorsදෝෂ | listed after compiling the whole programසම්පූර්ණ සම්පාදනයෙන් පසු ලැයිස්තුගත වේ | stops at the first line with an errorදෝෂයක් ඇති පළමු පේළියේ නතර වේ |
| Speed when runningධාවන වේගය | fasterවේගවත් | slowerමන්දගාමී |
| Exampleඋදාහරණය | Free Pascal (FPC), CFree Pascal (FPC), C | PythonPython |
The code we write is the source code. The translated result is machine code (object code). An assembler translates assembly language.අප ලියන කේතය මූලාශ්ර කේතයයි (source code). පරිවර්තිත ප්රතිඵලය යන්ත්ර කේතයයි (object code). ඇසෙම්බ්ලරයක් ඇසෙම්බ්ලි භාෂාව පරිවර්තනය කරයි.
5. Program errors5. වැඩසටහන් දෝෂ
| Errorදෝෂය | Meaningතේරුම | Exampleඋදාහරණය |
|---|---|---|
| Syntax errorවාක්ය රීති දෝෂය | Breaking the grammar rules of the language. The translator finds it.භාෂාවේ ව්යාකරණ රීති කැඩීම. පරිවර්තකය එය සොයා ගනී. | prnt(“Hi”) / missing ;prnt(“Hi”) / missing ; |
| Runtime errorධාවන කාල දෝෂය | The program stops while running.ධාවනය වන අතරතුර වැඩසටහන නතර වේ. | dividing by zeroබිංදුවෙන් බෙදීම |
| Logic errorතාර්කික දෝෂය | The program runs but gives a wrong answer.වැඩසටහන ධාවනය වේ නමුත් වැරදි පිළිතුරක් දෙයි. | total / 2 instead of total / 3total / 3 වෙනුවට total / 2 |
6. Testing and debugging6. පරීක්ෂාව සහ දෝෂ නිරාකරණය
Testing means running the program with chosen data and checking the output against the expected answer. Debugging means finding and fixing the errors (bugs). The program below should find the average of three marks, but it has a logic error.පරීක්ෂාව යනු තෝරාගත් දත්ත සමඟ වැඩසටහන ධාවනය කර ප්රතිදානය අපේක්ෂිත පිළිතුර සමඟ සැසඳීමයි. දෝෂ නිරාකරණය (debugging) යනු දෝෂ (bugs) සොයා නිවැරදි කිරීමයි. පහත වැඩසටහන ලකුණු තුනක සාමාන්යය සොයා ගත යුතු නමුත් එහි තාර්කික දෝෂයක් ඇත.
program AverageBug; var m1, m2, m3, total: integer; avg: real; begin write('Enter mark 1: '); readln(m1); write('Enter mark 2: '); readln(m2); write('Enter mark 3: '); readln(m3); total := m1 + m2 + m3; avg := total / 2; { BUG: should be / 3 } writeln('Average = ', avg:0:2); end.
m1 = int(input("Enter mark 1: ")) m2 = int(input("Enter mark 2: ")) m3 = int(input("Enter mark 3: ")) total = m1 + m2 + m3 avg = total / 2 # BUG: should be / 3 print(f"Average = {avg:.2f}")
▶ Sample runනියැදි ධාවනය · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)
Enter mark 1: 75 Enter mark 2: 68 Enter mark 3: 72 Average = 107.50
Ways to debug: read the error message, use a trace table (dry run), print variable values, and use the debugger in an IDE to run step by step.දෝෂ නිරාකරණ ක්රම: දෝෂ පණිවිඩය කියවන්න, අනුරේඛන වගුවක් (dry run) භාවිත කරන්න, විචල්ය අගයන් මුද්රණය කරන්න, සහ IDE එකක debugger එක භාවිතයෙන් පියවරෙන් පියවර ධාවනය කරන්න.
7. IDEs and tools in 20267. 2026 IDE සහ මෙවලම්
An IDE (Integrated Development Environment) gives an editor, translator and debugger in one program.IDE එකක් (ඒකාබද්ධ සංවර්ධන පරිසරය) සංස්කාරකයක්, පරිවර්තකයක් සහ debugger එකක් එක් වැඩසටහනක ලබා දෙයි.
- IDLE – comes free with Python; simple for beginners.IDLE – Python සමඟ නොමිලේ ලැබේ; ආරම්භකයින්ට සරලයි.
- Thonny – a beginner Python IDE that shows variables step by step.Thonny – විචල්ය පියවරෙන් පියවර පෙන්වන ආරම්භක Python IDE එකකි.
- VS Code – a popular free editor for Python, Pascal and many languages.VS Code – Python, Pascal සහ බොහෝ භාෂා සඳහා ජනප්රිය නොමිලේ සංස්කාරකයකි.
- Free Pascal / Lazarus – for Pascal; online compilers run code in a web browser.Free Pascal / Lazarus – Pascal සඳහා; ඔන්ලයින් සම්පාදක වෙබ් බ්රවුසරයක කේතය ධාවනය කරයි.
- Scratch – block coding: drag blocks instead of typing; a fun first step before Python.Scratch – බ්ලොක් කේතනය: ටයිප් කිරීම වෙනුවට බ්ලොක් ඇදගෙන යන්න; Python ට පෙර විනෝදජනක පළමු පියවරකි.
Key Wordsප්රධාන පද
Sample Q&Aආදර්ශ ප්රශ්න සහ පිළිතුරු
1Why do high-level programs need a translator?ඉහළ මට්ටමේ වැඩසටහන්වලට පරිවර්තකයක් අවශ්ය ඇයි?
2Give one difference between a compiler and an interpreter.සම්පාදකයක් සහ අර්ථවිනයකයක් අතර එක් වෙනසක් දෙන්න.
3Procedural vs declarative?ක්රියා පටිපාටික සහ ප්රකාශන?
4What kind of error is total / 2 instead of total / 3?total / 3 වෙනුවට total / 2 කුමන දෝෂයක්ද?
5Name two IDEs for Python.Python සඳහා IDE දෙකක් නම් කරන්න.
6Give one rule for using AI assistants responsibly.AI සහායක වගකීමෙන් භාවිතයට එක් රීතියක් දෙන්න.
MCQබහුවරණ ප්රශ්න
Choose the correct answer for each question.සෑම ප්රශ්නයකටම නිවැරදි පිළිතුර තෝරන්න.
1The language the CPU runs directly is…CPU එක කෙළින්ම ධාවනය කරන භාෂාව…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
0s and 1s.0 සහ 1.
2MOV AL, 61h is written in…MOV AL, 61h ලියා ඇත්තේ…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Mnemonics.Mnemonics.
3Assembly language is translated by an…ඇසෙම්බ්ලි භාෂාව පරිවර්තනය කරන්නේ…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
Assembler.ඇසෙම්බ්ලරය.
4Which is a high-level language?ඉහළ මට්ටමේ භාෂාවක් කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
English-like.ඉංග්රීසි වැනි.
5A compiler translates…සම්පාදකයක් පරිවර්තනය කරන්නේ…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
Compiler.සම්පාදකය.
6Python is usually run by an…Python සාමාන්යයෙන් ධාවනය කරන්නේ…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Interpreter.අර්ථවිනයකය.
7SQL, which says what data is wanted, is…අවශ්ය දත්ත මොනවාදැයි කියන SQL…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
What, not how.කෙසේද නොව කුමක්ද.
8A language built around objects that hold data and actions is…දත්ත සහ ක්රියා තබන වස්තු වටා ගොඩනැගූ භාෂාවක්…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
OOP.OOP.
9JavaScript, used to add actions to web pages, is a…වෙබ් පිටුවලට ක්රියා එක් කිරීමට භාවිත වන JavaScript…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
Scripting.ස්ක්රිප්ටින්.
10Writing prnt(“Hi”) in Python causes a…Python හි prnt(“Hi”) ලිවීමෙන් ඇති වන්නේ…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
Misspelt word.වැරදි අක්ෂර වින්යාසය.
11A program that runs but gives a wrong answer has a…ධාවනය වුවත් වැරදි පිළිතුරක් දෙන වැඩසටහනක ඇත්තේ…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
Logic.තාර්කික.
12Dividing by zero while running causes a…ධාවනයේදී බිංදුවෙන් බෙදීම නිසා ඇති වන්නේ…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Runtime.ධාවන කාල.
13Marks 75, 68, 72 with total / 2 give Average = …ලකුණු 75, 68, 72 total / 2 සමඟ Average = …
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
215 ÷ 2.215 ÷ 2.
14Finding and fixing errors in a program is…වැඩසටහනක දෝෂ සොයා නිවැරදි කිරීම…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
Debugging.දෝෂ නිරාකරණය.
15A responsible way to use an AI coding assistant is to…AI කේත සහායකයක් වගකීමෙන් භාවිත කිරීමේ ක්රමයක්…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
Responsible use.වගකීම් සහගත භාවිතය.
MCQ answer keyMCQ පිළිතුරු
- C – 0s and 1s.0 සහ 1.
- A – Mnemonics.Mnemonics.
- C – Assembler.ඇසෙම්බ්ලරය.
- A – English-like.ඉංග්රීසි වැනි.
- B – Compiler.සම්පාදකය.
- A – Interpreter.අර්ථවිනයකය.
- B – What, not how.කෙසේද නොව කුමක්ද.
- B – OOP.OOP.
- D – Scripting.ස්ක්රිප්ටින්.
- B – Misspelt word.වැරදි අක්ෂර වින්යාසය.
- D – Logic.තාර්කික.
- A – Runtime.ධාවන කාල.
- C – 215 ÷ 2.215 ÷ 2.
- D – Debugging.දෝෂ නිරාකරණය.
- C – Responsible use.වගකීම් සහගත භාවිතය.
Structured Questionsව්යුහගත ප්රශ්න
1(i) Name two low-level languages. (1 mark)
(ii) Give two advantages of high-level languages. (2 marks)(i) පහළ මට්ටමේ භාෂා දෙකක් නම් කරන්න. (ලකුණු 1)
(ii) ඉහළ මට්ටමේ භාෂාවල වාසි දෙකක් දෙන්න. (ලකුණු 2) (3 marksලකුණු 3)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
2Compare a compiler and an interpreter under three headings. (3 marks)සම්පාදකයක් සහ අර්ථවිනයකයක් ශීර්ෂ තුනක් යටතේ සසඳන්න. (ලකුණු 3) (3 marksලකුණු 3)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
3State the difference between (a) procedural and declarative languages (b) structured and object-oriented programming. (4 marks)(a) ක්රියා පටිපාටික සහ ප්රකාශන භාෂා (b) ව්යුහගත සහ වස්තු-නැඹුරු ක්රමලේඛනය අතර වෙනස සඳහන් කරන්න. (ලකුණු 4) (4 marksලකුණු 4)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
4A program to find the average of three marks displays 107.50 for 75, 68, 72.
(i) What type of error is this? (1 mark)
(ii) What is the correct answer and how do you fix it? (2 marks)
(iii) Give two other types of error with an example. (2 marks)ලකුණු තුනක සාමාන්යය සොයන වැඩසටහනක් 75, 68, 72 සඳහා 107.50 පෙන්වයි.
(i) මෙය කුමන දෝෂයක්ද? (ලකුණු 1)
(ii) නිවැරදි පිළිතුර කුමක්ද, එය නිවැරදි කරන්නේ කෙසේද? (ලකුණු 2)
(iii) වෙනත් දෝෂ වර්ග දෙකක් උදාහරණ සමඟ දෙන්න. (ලකුණු 2) (5 marksලකුණු 5)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
program AverageBug; var m1, m2, m3, total: integer; avg: real; begin write('Enter mark 1: '); readln(m1); write('Enter mark 2: '); readln(m2); write('Enter mark 3: '); readln(m3); total := m1 + m2 + m3; avg := total / 2; { BUG: should be / 3 } writeln('Average = ', avg:0:2); end.
m1 = int(input("Enter mark 1: ")) m2 = int(input("Enter mark 2: ")) m3 = int(input("Enter mark 3: ")) total = m1 + m2 + m3 avg = total / 2 # BUG: should be / 3 print(f"Average = {avg:.2f}")
▶ Sample runනියැදි ධාවනය · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)
Enter mark 1: 75 Enter mark 2: 68 Enter mark 3: 72 Average = 107.50
5What is an IDE? Name two IDEs used for Python and state two rules for using AI assistants responsibly. (4 marks)IDE එකක් යනු කුමක්ද? Python සඳහා භාවිත වන IDE දෙකක් නම් කර AI සහායක වගකීමෙන් භාවිතයට රීති දෙකක් සඳහන් කරන්න. (ලකුණු 4) (4 marksලකුණු 4)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
🎮 Game🎮 ක්රීඩා
Summary & Downloadsසාරාංශය සහ බාගත කිරීම්
Key pointsප්රධාන කරුණු
- Low-level: machine (0/1) and assembly.පහළ මට්ටම: යන්ත්ර (0/1) සහ ඇසෙම්බ්ලි.
- High-level: English-like – Python, Pascal.ඉහළ මට්ටම: ඉංග්රීසි වැනි – Python, Pascal.
- Procedural = how; declarative = what.ක්රියා පටිපාටික = කෙසේද; ප්රකාශන = කුමක්ද.
- Structured vs object-oriented.ව්යුහගත එදිරිව වස්තු-නැඹුරු.
- Compiler: whole program; interpreter: line by line.සම්පාදකය: සම්පූර්ණ වැඩසටහන; අර්ථවිනයකය: පේළියෙන් පේළිය.
- Errors: syntax, runtime, logic.දෝෂ: වාක්ය රීති, ධාවන කාල, තාර්කික.
- Test with normal, boundary, invalid data.සාමාන්ය, මායිම්, අවලංගු දත්ත සමඟ පරීක්ෂා කරන්න.
- IDEs: IDLE, Thonny, VS Code; use AI responsibly.IDE: IDLE, Thonny, VS Code; AI වගකීමෙන් භාවිත කරන්න.
Downloadsබාගත කිරීම්
Full Lesson 1 PDFසම්පූර්ණ පාඩම 1 PDF: English · සිංහල
Next: Lesson 1 O/L Exam Practiceඊළඟට: පාඩම 1 O/L විභාග පුහුණුව →
