© 2026 schoolict.net (Ruwan Mangala Suraweera)
1.4 Identifiers, Variables, Constants and Data Typesහඳුන්වන, විචල්ය, නියත සහ දත්ත වර්ග
G.C.E. O/L Grade 11 ICT · Lesson 1G.C.E. O/L ICT · 11 ශ්රේණිය · පාඩම 1
In this videoමේ වීඩියෝවේ
- A variable is a named memory place whose value can change.විචල්යය වෙනස් විය හැකි අගයක් ඇති නම් කළ මතක ස්ථානයකි.
- A constant’s value does not change.නියතයක අගය වෙනස් නොවේ.
- Identifiers start with a letter; no spaces.හඳුන්වන අකුරකින් ආරම්භ වේ; හිස්තැන් නැත.
- Reserved words like begin, if cannot be names.begin, if වැනි වෙන් කළ වචන නම් ලෙස භාවිත කළ නොහැක.
- Data types: integer, real, char, string, Boolean.දත්ත වර්ග: integer, real, char, string, Boolean.
Notesසටහන්
Syllabus 10.4. A program must remember data – a name, a mark, a price. It keeps each value in a named box in memory. If the value can change, the box is a variable; if it never changes, it is a constant. The name of the box is an identifier, and the kind of value it holds is its data type. Some words are reserved and cannot be used as names.විෂය නිර්දේශය 10.4. වැඩසටහනකට දත්ත මතක තබා ගත යුතුය – නමක්, ලකුණක්, මිලක්. එය එක් එක් අගය මතකයේ නමක් ඇති පෙට්ටියක තබා ගනී. අගය වෙනස් විය හැකි නම් එම පෙට්ටිය විචල්යයකි (variable); කිසි විටෙක වෙනස් නොවේ නම් එය නියතයකි (constant). පෙට්ටියේ නම හඳුන්වනයයි (identifier), එහි ඇති අගයේ වර්ගය එහි දත්ත වර්ගයයි (data type). සමහර වචන වෙන් කර ඇති (reserved) නිසා නම් ලෙස භාවිත කළ නොහැක.
1. Variables1. විචල්ය (Variables)
A variable is a named memory location whose value can change while the program runs. Think of a labelled box: the label is “Marks”, and inside today is 65; later we can put 80 in the same box. The old value is replaced.විචල්යයක් යනු වැඩසටහන ධාවනය වන අතරතුර අගය වෙනස් විය හැකි, නමක් ඇති මතක ස්ථානයකි. ලේබලයක් ඇති පෙට්ටියක් ගැන සිතන්න: ලේබලය “Marks”, අද ඇතුළත 65; පසුව එම පෙට්ටියටම 80 දැමිය හැක. පැරණි අගය ප්රතිස්ථාපනය වේ.
| Stepපියවර | Pseudocodeව්යාජ කේතය | Value in MarksMarks හි අගය |
|---|---|---|
| 11 | Marks = 65Marks = 65 | 6565 |
| 22 | Marks = 80Marks = 80 | 8080 |
| 33 | Marks = Marks + 5Marks = Marks + 5 | 8585 |
2. Constants2. නියත (Constants)
A constant is a named value that does not change while the program runs, such as π = 3.14 or the pass mark 35. Using a constant makes the program easy to read and easy to change – if the pass mark changes, you change it in one place only. In Pascal we write it under const. Python has no real constants, so by custom we write the name in CAPITALS.නියතයක් යනු π = 3.14 හෝ සමත් ලකුණ 35 වැනි, වැඩසටහන ධාවනයේදී වෙනස් නොවන නමක් ඇති අගයකි. නියතයක් භාවිතයෙන් වැඩසටහන කියවීමට පහසු සහ වෙනස් කිරීමට පහසු වේ – සමත් ලකුණ වෙනස් වුවහොත් එක් තැනක පමණක් වෙනස් කළ යුතුය. Pascal හි එය const යටතේ ලියමු. Python හි සැබෑ නියත නැති නිසා සම්ප්රදායිකව නම ලොකු අකුරින් ලියමු.
📝 Pseudocodeව්යාජ කේතය (Pseudocode)
BEGIN CONSTANT PI = 3.14 INPUT Radius Area = PI * Radius * Radius DISPLAY Area END
program CircleArea; const PI = 3.14; var radius, area: real; begin write('Enter radius: '); readln(radius); area := PI * radius * radius; writeln('Area = ', area:0:2); end.
PI = 3.14 # a constant (capital letters by custom) radius = float(input("Enter radius: ")) area = PI * radius * radius print(f"Area = {area:.2f}")
▶ Sample runනියැදි ධාවනය · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)
Enter radius: 7 Area = 153.86
3. Data types3. දත්ත වර්ග
The data type tells the computer what kind of value a variable holds and how much memory it needs. The O/L syllabus uses four basic types:දත්ත වර්ගය මගින් විචල්යයක ඇති අගයේ වර්ගය සහ එයට අවශ්ය මතක ප්රමාණය පරිගණකයට කියයි. O/L විෂය නිර්දේශය මූලික වර්ග හතරක් භාවිත කරයි:
| Data typeදත්ත වර්ගය | Holdsදරන්නේ | Examplesඋදාහරණ | PascalPascal | PythonPython |
|---|---|---|---|---|
| Integerපූර්ණ සංඛ්යා | Whole numbersපූර්ණ සංඛ්යා | 16, −5, 202616, −5, 2026 | integerinteger | intint |
| Floating point (real)දශම සංඛ්යා (real) | Numbers with a decimal pointදශම තිතක් ඇති සංඛ්යා | 1.62, 3.14, 71.671.62, 3.14, 71.67 | realreal | floatfloat |
| Characterඅක්ෂර | One letter, digit or symbolඑක් අකුරක්, ඉලක්කමක් හෝ සංකේතයක් | ‘A’, ‘7’, ‘#’‘A’, ‘7’, ‘#’ | charchar | str of length 1දිග 1 වන str |
| Logical (Boolean)තාර්කික (Boolean) | Only True or Falseසත්ය හෝ අසත්ය පමණි | True, FalseTrue, False | booleanboolean | boolbool |
| String (extra)String (අමතර) | Text – many charactersපාඨය – අක්ෂර බොහොමයක් | ‘Nimal’, ‘Kandy’‘Nimal’, ‘Kandy’ | stringstring | strstr |
program DataTypes; var name: string; age: integer; height: real; grade: char; isPrefect: boolean; begin name := 'Nimal'; age := 16; height := 1.62; grade := 'A'; isPrefect := true; writeln('Name: ', name); writeln('Age: ', age); writeln('Height: ', height:0:2); writeln('Grade: ', grade); if isPrefect then writeln('Prefect: Yes') else writeln('Prefect: No'); end.
name = "Nimal" # string age = 16 # integer height = 1.62 # floating point (real) grade = "A" # character is_prefect = True # logical (Boolean) print("Name:", name) print("Age:", age) print(f"Height: {height:.2f}") print("Grade:", grade) if is_prefect: print("Prefect: Yes") else: print("Prefect: No")
▶ Sample runනියැදි ධාවනය · same output in Pascal and PythonPascal සහ Python දෙකෙහිම එකම ප්රතිදානය
Name: Nimal Age: 16 Height: 1.62 Grade: A Prefect: Yes
4. Identifiers and naming rules4. හඳුන්වන සහ නම් කිරීමේ නීති
An identifier is the name we give to a variable, constant, program or sub-program. Rules (Pascal and Python):හඳුන්වනයක් යනු විචල්යයකට, නියතයකට, වැඩසටහනකට හෝ උප වැඩසටහනකට දෙන නමයි. නීති (Pascal සහ Python):
- Use letters, digits and the underscore _ only.අකුරු, ඉලක්කම් සහ යටි ඉර _ පමණක් භාවිත කරන්න.
- It must start with a letter (or _), never a digit.එය අකුරකින් (හෝ _) ආරම්භ විය යුතුය, කිසි විටෙක ඉලක්කමකින් නොවේ.
- No spaces and no symbols such as -, %, @.හිස්තැන් නැත, -, %, @ වැනි සංකේත නැත.
- It must not be a reserved word.එය වෙන් කළ වචනයක් නොවිය යුතුය.
- Python is case-sensitive (Total and total are different). Pascal is not (Total and TOTAL are the same name).Python අකුරු වර්ගයට සංවේදීය (Total සහ total වෙනස්). Pascal සංවේදී නොවේ (Total සහ TOTAL එකම නමකි).
| Identifierහඳුන්වනය | Valid?වලංගුද? | Reasonහේතුව |
|---|---|---|
| total_markstotal_marks | Yesඔව් | Letters and _අකුරු සහ _ |
| Mark2Mark2 | Yesඔව් | Digit not at the startඉලක්කම මුලින් නොවේ |
| 2ndMark2ndMark | Noනැත | Starts with a digitඉලක්කමකින් ආරම්භ වේ |
| total markstotal marks | Noනැත | Has a spaceහිස්තැනක් ඇත |
| pass%pass% | Noනැත | Has a symbolසංකේතයක් ඇත |
| begin / ifbegin / if | Noනැත | Reserved wordවෙන් කළ වචනයකි |
5. Reserved words (keywords)5. වෙන් කළ වචන (keywords)
Reserved words are words that already have a special meaning in the language, so they cannot be used as identifiers. Pascal: program, var, const, begin, end, if, then, else, for, while, repeat, until, and, or, not, div, mod. Python: if, else, elif, for, while, def, return, True, False, and, or, not, import.වෙන් කළ වචන යනු භාෂාවේ දැනටමත් විශේෂ අර්ථයක් ඇති වචන වන නිසා ඒවා හඳුන්වන ලෙස භාවිත කළ නොහැක. Pascal: program, var, const, begin, end, if, then, else, for, while, repeat, until, and, or, not, div, mod. Python: if, else, elif, for, while, def, return, True, False, and, or, not, import.
6. Meaningful names6. අර්ථවත් නම්
Choose names that tell you what the value is. Compare x = a * b with total = price * quantity. The second is much easier to understand and to fix later. Good: studentName, totalMarks, unit_price. Poor: a, x1, abc.අගය කුමක්දැයි කියන නම් තෝරන්න. x = a * b සහ total = price * quantity සසඳන්න. දෙවැන්න තේරුම් ගැනීමට සහ පසුව නිවැරදි කිරීමට බෙහෙවින් පහසුය. හොඳ: studentName, totalMarks, unit_price. දුර්වල: a, x1, abc.
Key Wordsප්රධාන පද
Sample Q&Aආදර්ශ ප්රශ්න සහ පිළිතුරු
1What is the difference between a variable and a constant?විචල්යයක් සහ නියතයක් අතර වෙනස කුමක්ද?
2Name the four basic data types in the syllabus.විෂය නිර්දේශයේ මූලික දත්ත වර්ග හතර නම් කරන්න.
3Is 2ndMark a valid identifier? Why?2ndMark වලංගු හඳුන්වනයක්ද? ඇයි?
4Give the data type for: 16, 1.62, ‘A’, True.16, 1.62, ‘A’, True සඳහා දත්ත වර්ගය දෙන්න.
5Why should we use meaningful names?අර්ථවත් නම් භාවිත කළ යුත්තේ ඇයි?
6What is a reserved word? Give two examples.වෙන් කළ වචනයක් යනු කුමක්ද? උදාහරණ දෙකක් දෙන්න.
MCQබහුවරණ ප්රශ්න
Choose the correct answer for each question.සෑම ප්රශ්නයකටම නිවැරදි පිළිතුර තෝරන්න.
1A named memory location whose value can change is a…අගය වෙනස් විය හැකි නමක් ඇති මතක ස්ථානයක්…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Variable.විචල්යය.
2The value 3.14 used for π, which never changes, is best stored as a…කිසි විටෙක වෙනස් නොවන π සඳහා 3.14 ගබඩා කිරීමට වඩාත් සුදුසු…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
Fixed value = constant.ස්ථාවර අගය = නියතය.
3Which is a valid identifier?වලංගු හඳුන්වනයක් කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
Letters and underscore only.අකුරු සහ යටි ඉර පමණි.
4Which is NOT a valid identifier?වලංගු හඳුන්වනයක් නොවන්නේ කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
begin is reserved in Pascal.begin Pascal හි වෙන් කළ වචනයකි.
5The data type of 1.62 is…1.62 හි දත්ත වර්ගය…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
Has a decimal point.දශම තිතක් ඇත.
6The data type of ‘A’ is…‘A’ හි දත්ත වර්ගය…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
Single letter.තනි අකුර.
7A logical (Boolean) variable can hold…තාර්කික (Boolean) විචල්යයකට දැරිය හැක්කේ…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
Two values only.අගයන් දෙකක් පමණි.
8The number of students in a class is best stored as…පන්තියක සිසුන් ගණන ගබඩා කිරීමට වඩාත් සුදුසු…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Whole number.පූර්ණ සංඛ්යාව.
9In Pascal, the type for a floating point number is…Pascal හි දශම සංඛ්යාවක් සඳහා වර්ගය…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
Pascal uses real.Pascal real භාවිත කරයි.
10In Python, the type for a whole number is…Python හි පූර්ණ සංඛ්යාවක් සඳහා වර්ගය…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
Python uses int.Python int භාවිත කරයි.
11Which language is case-sensitive (Total ≠ total)?අකුරු වර්ගයට සංවේදී (Total ≠ total) භාෂාව කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: D
Python is case-sensitive; Pascal is not.Python සංවේදීයි; Pascal නොවේ.
12Which is the most meaningful name for the price of one item?එක් භාණ්ඩයක මිල සඳහා වඩාත්ම අර්ථවත් නම කුමක්ද?
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: C
Tells what it is.එය කුමක්දැයි කියයි.
13After Marks = 65, Marks = 80, Marks = Marks + 5, the value of Marks is…Marks = 65, Marks = 80, Marks = Marks + 5 ට පසු Marks හි අගය…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: A
80 + 5.80 + 5.
14In Pascal, variables are declared under the word…Pascal හි විචල්ය ප්රකාශ කරන්නේ … වචනය යටතේය
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
var section.var කොටස.
15For radius 7 and PI = 3.14, the circle program shows…අරය 7 සහ PI = 3.14 සඳහා වෘත්ත වැඩසටහන පෙන්වන්නේ…
✔ Correct!නිවැරදියි!✘ Not quite.වැරදියි. Correct answerනිවැරදි පිළිතුර: B
3.14 × 7 × 7 = 153.86.3.14 × 7 × 7 = 153.86.
MCQ answer keyMCQ පිළිතුරු
- A – Variable.විචල්යය.
- B – Fixed value = constant.ස්ථාවර අගය = නියතය.
- C – Letters and underscore only.අකුරු සහ යටි ඉර පමණි.
- C – begin is reserved in Pascal.begin Pascal හි වෙන් කළ වචනයකි.
- D – Has a decimal point.දශම තිතක් ඇත.
- C – Single letter.තනි අකුර.
- D – Two values only.අගයන් දෙකක් පමණි.
- A – Whole number.පූර්ණ සංඛ්යාව.
- B – Pascal uses real.Pascal real භාවිත කරයි.
- A – Python uses int.Python int භාවිත කරයි.
- D – Python is case-sensitive; Pascal is not.Python සංවේදීයි; Pascal නොවේ.
- C – Tells what it is.එය කුමක්දැයි කියයි.
- A – 80 + 5.80 + 5.
- B – var section.var කොටස.
- B – 3.14 × 7 × 7 = 153.86.3.14 × 7 × 7 = 153.86.
Structured Questionsව්යුහගත ප්රශ්න
1(i) Define a variable and a constant. (2 marks)
(ii) Give one example of each from a school-fees program. (2 marks)(i) විචල්යයක් සහ නියතයක් අර්ථ දක්වන්න. (ලකුණු 2)
(ii) පාසල් ගාස්තු වැඩසටහනකින් එක් එකකට උදාහරණයක් දෙන්න. (ලකුණු 2) (4 marksලකුණු 4)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
2Give the most suitable data type for: (a) a student’s age (b) height in metres (c) a grade letter (d) whether a student is a prefect. (4 marks)පහත සඳහා වඩාත් සුදුසු දත්ත වර්ගය දෙන්න: (a) සිසුවෙකුගේ වයස (b) මීටර්වලින් උස (c) ශ්රේණි අකුර (d) සිසුවා ශිෂ්ය නායකයෙක්ද යන්න. (ලකුණු 4) (4 marksලකුණු 4)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
3State whether each identifier is valid and give a reason: total, 3sum, my mark, if, Avg_1. (5 marks)එක් එක් හඳුන්වනය වලංගුද යන්න හේතුව සමඟ සඳහන් කරන්න: total, 3sum, my mark, if, Avg_1. (ලකුණු 5) (5 marksලකුණු 5)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
4Explain two advantages of using a constant such as PASSMARK = 35 instead of typing 35 everywhere. (2 marks)සෑම තැනම 35 ටයිප් කිරීම වෙනුවට PASSMARK = 35 වැනි නියතයක් භාවිතයේ වාසි දෙකක් පහදන්න. (ලකුණු 2) (2 marksලකුණු 2)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
5A Pascal program called Discount has a variable discount. Why does it not compile? How can you fix it? (2 marks)Discount නම් Pascal වැඩසටහනක discount නම් විචල්යයක් ඇත. එය compile නොවන්නේ ඇයි? නිවැරදි කරන්නේ කෙසේද? (ලකුණු 2) (2 marksලකුණු 2)
Show model answerආදර්ශ පිළිතුර පෙන්වන්න
🎮 Game🎮 ක්රීඩා
Summary & Downloadsසාරාංශය සහ බාගත කිරීම්
Key pointsප්රධාන කරුණු
- Variable: value can change.විචල්යය: අගය වෙනස් විය හැක.
- Constant: value stays fixed.නියතය: අගය ස්ථාවරයි.
- Identifier = a name; start with a letter, no spaces.හඳුන්වනය = නමක්; අකුරකින් ආරම්භය, හිස්තැන් නැත.
- Reserved words cannot be names.වෙන් කළ වචන නම් ලෙස භාවිත කළ නොහැක.
- Integer, floating point, character, logical.පූර්ණ, දශම, අක්ෂර, තාර්කික.
- Pascal: integer, real, char, boolean.Pascal: integer, real, char, boolean.
- Python: int, float, str, bool; case-sensitive.Python: int, float, str, bool; අකුරු සංවේදී.
- Use meaningful names like totalMarks.totalMarks වැනි අර්ථවත් නම් භාවිත කරන්න.
