Sub-programs: Functions and Procedures – Grade 11 ICT Notes 1.10

© 2026 schoolict.net (Ruwan Mangala Suraweera)

1.10 Sub-programs: Functions and Proceduresඋප වැඩසටහන්: ශ්‍රිත සහ ක්‍රියා පටිපාටි

G.C.E. O/L Grade 11 ICT · Lesson 1G.C.E. O/L ICT · 11 ශ්‍රේණිය · පාඩම 1

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මේ වීඩියෝවේ

  • A sub-program does one named job.උප වැඩසටහනක් නමක් ඇති එක් කාර්යයක් කරයි.
  • Benefits: reusability, readability, maintainability.වාසි: නැවත භාවිතය, කියවීමේ පහසුව, නඩත්තුව.
  • Function returns a value.ශ්‍රිතය අගයක් ආපසු දෙයි.
  • Procedure returns no value.ක්‍රියා පටිපාටිය අගයක් ආපසු නොදෙයි.
  • Parameters receive arguments.පරාමිති තර්ක ලබා ගනී.
Sub-programFunctionProcedureParameterArgumentReturn valueReusability

Notesසටහන්

Syllabus 10.10. A sub-program is a small, named part of a program that does one job. We write it once and call (use) it whenever we need it – like a recipe for pol sambol that you can follow every day without rewriting it. Big programs are built from many small sub-programs.විෂය නිර්දේශය 10.10. උප වැඩසටහනක් යනු එක් කාර්යයක් කරන, නමක් ඇති වැඩසටහනක කුඩා කොටසකි. අප එය එක් වරක් ලියා අවශ්‍ය සෑම විටම කැඳවමු (භාවිත කරමු) – නැවත නොලියා දිනපතා අනුගමනය කළ හැකි පොල් සම්බෝල වට්ටෝරුවක් මෙන්. විශාල වැඩසටහන් කුඩා උප වැඩසටහන් බොහොමයකින් සාදා ඇත.

1. Why use sub-programs?1. උප වැඩසටහන් භාවිත කරන්නේ ඇයි?

1
Reusabilityනැවත භාවිතය
Write once, call many times. No need to copy the same code again.එක් වරක් ලියා බොහෝ වර කැඳවන්න. එකම කේතය නැවත පිටපත් කිරීම අවශ්‍ය නැත.
2
Readabilityකියවීමේ පහසුව
Names like PrintLine and GetGrade make the main program easy to understand.PrintLine, GetGrade වැනි නම් ප්‍රධාන වැඩසටහන තේරුම් ගැනීමට පහසු කරයි.
3
Maintainabilityනඩත්තුවේ පහසුව
To fix or change a job, change it in one place only.කාර්යයක් නිවැරදි කිරීමට හෝ වෙනස් කිරීමට එක් තැනක පමණක් වෙනස් කරන්න.
4
Teamwork and testingකණ්ඩායම් වැඩ සහ පරීක්ෂාව
Different people can write and test different sub-programs.විවිධ අයට විවිධ උප වැඩසටහන් ලියා පරීක්ෂා කළ හැක.

2. Two kinds of sub-programs2. උප වැඩසටහන් වර්ග දෙක

Value-returningඅගයක් ආපසු දෙනNon-value-returningඅගයක් ආපසු නොදෙන
Pascal namePascal නමfunctionfunctionprocedureprocedure
PythonPythondef … with return valuereturn අගයක් සහිත defdef … without return valuereturn අගයක් නැති def
Gives backආපසු දෙන්නේone value (e.g. a grade)එක් අගයක් (උදා ශ්‍රේණියක්)nothing – it just does a jobකිසිවක් නැත – කාර්යයක් පමණක් කරයි
ExampleඋදාහරණයGetGrade(82) → ‘A’GetGrade(82) → ‘A’PrintLinePrintLine

3. Parameters and arguments3. පරාමිති සහ තර්ක

Values we send into a sub-program are parameters. In area(length, width), length and width are parameters. When we call area(5, 4), the values 5 and 4 are the arguments.උප වැඩසටහනකට යවන අගයන් පරාමිති (parameters) වේ. area(length, width) හි length සහ width පරාමිති වේ. area(5, 4) කැඳවන විට 5 සහ 4 අගයන් තර්ක (arguments) වේ.

4. A value-returning function4. අගයක් ආපසු දෙන ශ්‍රිතයක්

GetGrade receives a mark and returns a grade letter, using the O/L grade limits (A 75, B 65, C 50, S 35).GetGrade ලකුණක් ලබාගෙන O/L ශ්‍රේණි සීමා (A 75, B 65, C 50, S 35) භාවිතයෙන් ශ්‍රේණි අකුරක් ආපසු දෙයි.

📝 Pseudocodeව්‍යාජ කේතය (Pseudocode)

FUNCTION GetGrade(Marks)
  IF Marks >= 75 THEN RETURN "A"
  ELSE IF Marks >= 65 THEN RETURN "B"
  ELSE IF Marks >= 50 THEN RETURN "C"
  ELSE IF Marks >= 35 THEN RETURN "S"
  ELSE RETURN "W"
  ENDIF
ENDFUNCTION

BEGIN
  FOR k = 1 TO 3
    INPUT M
    DISPLAY GetGrade(M)
  ENDFOR
END
💻 Value-returning sub-program (function): GetGradeඅගයක් ආපසු දෙන උප ක්‍රමලේඛය (function): GetGrade
program GradeFunction;
var
  k, m: integer;

function GetGrade(marks: integer): char;
begin
  if marks >= 75 then
    GetGrade := 'A'
  else if marks >= 65 then
    GetGrade := 'B'
  else if marks >= 50 then
    GetGrade := 'C'
  else if marks >= 35 then
    GetGrade := 'S'
  else
    GetGrade := 'W';
end;

begin
  for k := 1 to 3 do
  begin
    write('Enter mark: ');
    readln(m);
    writeln('Grade: ', GetGrade(m));
  end;
end.
def get_grade(marks):
    if marks >= 75:
        return "A"
    elif marks >= 65:
        return "B"
    elif marks >= 50:
        return "C"
    elif marks >= 35:
        return "S"
    else:
        return "W"

for k in range(3):
    m = int(input("Enter mark: "))
    print("Grade:", get_grade(m))

▶ Sample runනියැදි ධාවනය · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)

Enter mark: 82
Grade: A
Enter mark: 47
Grade: S
Enter mark: 66
Grade: B
💡 In Pascal, the result is given by assigning to the function name: GetGrade := ‘A’. In Python we write return “A”.Pascal හි ප්‍රතිඵලය ලබා දෙන්නේ ශ්‍රිත නමට පැවරීමෙනි: GetGrade := ‘A’. Python හි return “A” ලෙස ලියමු.

5. Procedures (non-value-returning)5. ක්‍රියා පටිපාටි (අගයක් ආපසු නොදෙන)

A shop bill uses PrintLine three times and ShowItem for each item. PrintLine has no parameters; ShowItem has three.සාප්පු බිල්පතක PrintLine තුන් වරක් ද එක් එක් අයිතමය සඳහා ShowItem ද භාවිත කරයි. PrintLine ට පරාමිති නැත; ShowItem ට තුනක් ඇත.

💻 Non-value-returning sub-programs (procedures): a shop billඅගයක් ආපසු නොදෙන උප ක්‍රමලේඛ (procedures): කඩ බිලක්
program BillProcedures;

procedure PrintLine;
begin
  writeln('------------------------');
end;

procedure ShowItem(item: string; price, qty: integer);
begin
  writeln(item, ': Rs. ', price * qty);
end;

begin
  PrintLine;
  writeln('SAMPLE SHOP BILL');
  PrintLine;
  ShowItem('Bread', 120, 2);
  ShowItem('Milk packet', 280, 1);
  ShowItem('Eggs', 55, 6);
  PrintLine;
end.
def print_line():
    print("-" * 24)

def show_item(item, price, qty):
    print(item + ": Rs.", price * qty)

print_line()
print("SAMPLE SHOP BILL")
print_line()
show_item("Bread", 120, 2)
show_item("Milk packet", 280, 1)
show_item("Eggs", 55, 6)
print_line()

▶ Sample runනියැදි ධාවනය · same output in Pascal and PythonPascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය

------------------------
SAMPLE SHOP BILL
------------------------
Bread: Rs. 240
Milk packet: Rs. 280
Eggs: Rs. 330
------------------------

6. Calling a function many times6. ශ්‍රිතයක් බොහෝ වර කැඳවීම

A function can be used inside an expression, just like a number.ශ්‍රිතයක් සංඛ්‍යාවක් මෙන්ම ප්‍රකාශනයක් තුළ භාවිත කළ හැක.

💻 A function with two parameters: area of a rectangleපරාමිති දෙකක් සහිත function: සෘජුකෝණාස්‍රයක වර්ගඵලය
program RectArea;

function Area(length, width: integer): integer;
begin
  Area := length * width;
end;

begin
  writeln('Room 1 = ', Area(5, 4));
  writeln('Room 2 = ', Area(6, 3));
  writeln('Both = ', Area(5, 4) + Area(6, 3));
end.
def area(length, width):
    return length * width

print("Room 1 =", area(5, 4))
print("Room 2 =", area(6, 3))
print("Both =", area(5, 4) + area(6, 3))

▶ Sample runනියැදි ධාවනය · same output in Pascal and PythonPascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය

Room 1 = 20
Room 2 = 18
Both = 38
💡 Built-in sub-programs you already use: writeln, readln, sqrt (Pascal); print, input, len, round (Python).ඔබ දැනටමත් භාවිත කරන ගොඩනැගූ උප වැඩසටහන්: writeln, readln, sqrt (Pascal); print, input, len, round (Python).

Key Wordsප්‍රධාන පද

Sub-programඋප වැඩසටහන
A named part of a program that does one job.එක් කාර්යයක් කරන, නමක් ඇති වැඩසටහන් කොටසක්.
Functionශ්‍රිතය
A sub-program that returns a value.අගයක් ආපසු දෙන උප වැඩසටහනක්.
Procedureක්‍රියා පටිපාටිය
A sub-program that does a job but returns no value.කාර්යයක් කරන නමුත් අගයක් ආපසු නොදෙන උප වැඩසටහනක්.
Callකැඳවීම
Using a sub-program by writing its name.නම ලිවීමෙන් උප වැඩසටහනක් භාවිත කිරීම.
Parameterපරාමිතිය
A variable that receives a value sent into a sub-program.උප වැඩසටහනකට යවන අගයක් ලබාගන්නා විචල්‍යය.
Argumentතර්කය
The actual value sent when calling, e.g. 5 in area(5, 4).කැඳවන විට යවන සත්‍ය අගය, උදා area(5, 4) හි 5.
Return valueආපසු අගය
The result a function gives back.ශ්‍රිතයක් ආපසු දෙන ප්‍රතිඵලය.
Reusabilityනැවත භාවිතය
Writing code once and using it many times.කේතය එක් වරක් ලියා බොහෝ වර භාවිතය.
Readabilityකියවීමේ පහසුව
How easy code is to read and understand.කේතය කියවීමට හා තේරුම් ගැනීමට ඇති පහසුව.
Maintainabilityනඩත්තුවේ පහසුව
How easy code is to fix and change.කේතය නිවැරදි කිරීමට හා වෙනස් කිරීමට ඇති පහසුව.
defdef
Python keyword to define a sub-program.උප වැඩසටහනක් නිර්වචනය කිරීමට Python මූල පදය.
Built-in functionගොඩනැගූ ශ්‍රිතය
A function already provided by the language, e.g. len.භාෂාව විසින්ම සපයන ශ්‍රිතයක්, උදා len.

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

1What is a sub-program?උප වැඩසටහනක් යනු කුමක්ද?

Answerපිළිතුර: A named part of a program that does one job and can be called when needed.එක් කාර්යයක් කරන, අවශ්‍ය විට කැඳවිය හැකි නමක් ඇති වැඩසටහන් කොටසකි.

2Give three advantages of sub-programs.උප වැඩසටහන්වල වාසි තුනක් දෙන්න.

Answerපිළිතුර: Reusability, readability and maintainability.නැවත භාවිතය, කියවීමේ පහසුව සහ නඩත්තුවේ පහසුව.

3Difference between a function and a procedure?ශ්‍රිතයක් සහ ක්‍රියා පටිපාටියක් අතර වෙනස?

Answerපිළිතුර: A function returns a value; a procedure does not.ශ්‍රිතයක් අගයක් ආපසු දෙයි; ක්‍රියා පටිපාටියක් එසේ නොකරයි.

4What is GetGrade(66)?GetGrade(66) කුමක්ද?

Answerපිළිතුර: B.B.

5What does area(6, 3) return?area(6, 3) ආපසු දෙන්නේ කුමක්ද?

Answerපිළිතුර: 18.18.

6In area(5, 4), what are 5 and 4?area(5, 4) හි 5 සහ 4 යනු මොනවාද?

Answerපිළිතුර: Arguments (values for the parameters length and width).තර්ක (length සහ width පරාමිති සඳහා අගයන්).

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

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

Scoreලකුණු: 0 / 15

1A named part of a program that does one job is a…එක් කාර්යයක් කරන නමක් ඇති වැඩසටහන් කොටසක්…

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

Sub-program.උප වැඩසටහන.

2A sub-program that returns a value is a…අගයක් ආපසු දෙන උප වැඩසටහනක්…

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

Function.ශ්‍රිතය.

3In Pascal, a sub-program that returns no value is a…Pascal හි අගයක් ආපසු නොදෙන උප වැඩසටහනක්…

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

Procedure.Procedure.

4“Write once, use many times” describes…“එක් වරක් ලියන්න, බොහෝ වර භාවිත කරන්න” විස්තර කරන්නේ…

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

Reusability.නැවත භාවිතය.

5Fixing a job in one place only shows…කාර්යයක් එක් තැනක පමණක් නිවැරදි කිරීම පෙන්වන්නේ…

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

Maintainability.නඩත්තුව.

6Clear names such as PrintLine improve…PrintLine වැනි පැහැදිලි නම් වැඩි දියුණු කරන්නේ…

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

Readability.කියවීමේ පහසුව.

7GetGrade(82) returns…GetGrade(82) ආපසු දෙන්නේ…

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

82 ≥ 75.82 ≥ 75.

8GetGrade(47) returns…GetGrade(47) ආපසු දෙන්නේ…

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

35 ≤ 47 < 50.35 ≤ 47 < 50.

9area(5, 4) + area(6, 3) equals…area(5, 4) + area(6, 3) සමාන වන්නේ…

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

20 + 18.20 + 18.

10In def area(length, width):, length and width are…def area(length, width): හි length සහ width…

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

Parameters.පරාමිති.

11The Python keyword that defines a sub-program is…උප වැඩසටහනක් නිර්වචනය කරන Python මූල පදය…

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

def.def.

12In Python, a function gives back its result with…Python හි ශ්‍රිතයක් ප්‍රතිඵලය ආපසු දෙන්නේ…

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

return.return.

13In Pascal, a function returns a value by…Pascal හි ශ්‍රිතයක් අගයක් ආපසු දෙන්නේ…

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

GetGrade := ‘A’.GetGrade := ‘A’.

14ShowItem(‘Eggs’, 55, 6) displays…ShowItem(‘Eggs’, 55, 6) පෙන්වන්නේ…

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

55 × 6.55 × 6.

15Which is a built-in Python function?ගොඩනැගූ Python ශ්‍රිතයක් කුමක්ද?

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

Built-in.ගොඩනැගූ.

MCQ answer keyMCQ පිළිතුරු

  1. D – Sub-program.උප වැඩසටහන.
  2. A – Function.ශ්‍රිතය.
  3. C – Procedure.Procedure.
  4. C – Reusability.නැවත භාවිතය.
  5. A – Maintainability.නඩත්තුව.
  6. A – Readability.කියවීමේ පහසුව.
  7. D – 82 ≥ 75.82 ≥ 75.
  8. B – 35 ≤ 47 < 50.35 ≤ 47 < 50.
  9. D – 20 + 18.20 + 18.
  10. B – Parameters.පරාමිති.
  11. C – def.def.
  12. B – return.return.
  13. A – GetGrade := ‘A’.GetGrade := ‘A’.
  14. B – 55 × 6.55 × 6.
  15. C – Built-in.ගොඩනැගූ.

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

1State three advantages of using sub-programs. (3 marks)උප වැඩසටහන් භාවිතයේ වාසි තුනක් සඳහන් කරන්න. (ලකුණු 3) (3 marksලකුණු 3)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
Reusability – write once, call many times; readability – easy to understand; maintainability – change in one place (1 each).නැවත භාවිතය – එක් වරක් ලියා බොහෝ වර කැඳවීම; කියවීමේ පහසුව – තේරුම් ගැනීමට පහසු; නඩත්තුව – එක් තැනක වෙනස් කිරීම (එකට 1).

2Distinguish between a value-returning and a non-value-returning sub-program with an example of each. (4 marks)අගයක් ආපසු දෙන සහ ආපසු නොදෙන උප වැඩසටහන් එක් එකකට උදාහරණයක් සමඟ වෙන්කර දක්වන්න. (ලකුණු 4) (4 marksලකුණු 4)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
Value-returning (function) gives back a value, e.g. GetGrade (2); non-value-returning (procedure) only does a task, e.g. PrintLine (2).අගයක් ආපසු දෙන (ශ්‍රිතය) අගයක් ලබා දෙයි, උදා GetGrade (2); ආපසු නොදෙන (ක්‍රියා පටිපාටිය) කාර්යයක් පමණක් කරයි, උදා PrintLine (2).

3Write a function (Pascal or Python) that receives a mark and returns the O/L grade A, B, C, S or W. (5 marks)ලකුණක් ලබාගෙන O/L ශ්‍රේණිය A, B, C, S හෝ W ආපසු දෙන ශ්‍රිතයක් (Pascal හෝ Python) ලියන්න. (ලකුණු 5) (5 marksලකුණු 5)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
Function heading with parameter (1); IF ≥ 75 A (1); ELSE IF ≥ 65 B, ≥ 50 C (1); ≥ 35 S else W (1); return / assign result (1).පරාමිතිය සහිත ශ්‍රිත ශීර්ෂය (1); IF ≥ 75 A (1); ELSE IF ≥ 65 B, ≥ 50 C (1); ≥ 35 S නැතහොත් W (1); ප්‍රතිඵලය return / පැවරීම (1).
💻 Value-returning sub-program (function): GetGradeඅගයක් ආපසු දෙන උප ක්‍රමලේඛය (function): GetGrade
program GradeFunction;
var
  k, m: integer;

function GetGrade(marks: integer): char;
begin
  if marks >= 75 then
    GetGrade := 'A'
  else if marks >= 65 then
    GetGrade := 'B'
  else if marks >= 50 then
    GetGrade := 'C'
  else if marks >= 35 then
    GetGrade := 'S'
  else
    GetGrade := 'W';
end;

begin
  for k := 1 to 3 do
  begin
    write('Enter mark: ');
    readln(m);
    writeln('Grade: ', GetGrade(m));
  end;
end.
def get_grade(marks):
    if marks >= 75:
        return "A"
    elif marks >= 65:
        return "B"
    elif marks >= 50:
        return "C"
    elif marks >= 35:
        return "S"
    else:
        return "W"

for k in range(3):
    m = int(input("Enter mark: "))
    print("Grade:", get_grade(m))

▶ Sample runනියැදි ධාවනය · same output in Pascal and Python (typed input in yellow)Pascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය (ටයිප් කළ ආදානය කහ පාටින්)

Enter mark: 82
Grade: A
Enter mark: 47
Grade: S
Enter mark: 66
Grade: B

4def area(length, width): return length * width
What is displayed by print(area(5, 4) + area(6, 3))? Name the parameters and arguments. (3 marks)
def area(length, width): return length * width
print(area(5, 4) + area(6, 3)) මගින් පෙන්වන්නේ කුමක්ද? පරාමිති සහ තර්ක නම් කරන්න. (ලකුණු 3)
(3 marksලකුණු 3)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
38 (1); parameters: length, width (1); arguments: 5, 4, 6, 3 (1).38 (1); පරාමිති: length, width (1); තර්ක: 5, 4, 6, 3 (1).

5Write a procedure ShowItem that receives an item name, price and quantity and displays the item total. Show one call. (4 marks)අයිතම නමක්, මිලක් සහ ප්‍රමාණයක් ලබාගෙන අයිතම මුළු මුදල පෙන්වන ShowItem ක්‍රියා පටිපාටියක් ලියන්න. එක් කැඳවීමක් පෙන්වන්න. (ලකුණු 4) (4 marksලකුණු 4)

Show model answerආදර්ශ පිළිතුර පෙන්වන්න
Procedure heading with three parameters (1); calculate price × qty (1); display (1); call e.g. ShowItem(‘Bread’, 120, 2) (1).පරාමිති තුනක් සහිත ශීර්ෂය (1); price × qty ගණනය (1); පෙන්වීම (1); කැඳවීම උදා ShowItem(‘Bread’, 120, 2) (1).
💻 Non-value-returning sub-programs (procedures): a shop billඅගයක් ආපසු නොදෙන උප ක්‍රමලේඛ (procedures): කඩ බිලක්
program BillProcedures;

procedure PrintLine;
begin
  writeln('------------------------');
end;

procedure ShowItem(item: string; price, qty: integer);
begin
  writeln(item, ': Rs. ', price * qty);
end;

begin
  PrintLine;
  writeln('SAMPLE SHOP BILL');
  PrintLine;
  ShowItem('Bread', 120, 2);
  ShowItem('Milk packet', 280, 1);
  ShowItem('Eggs', 55, 6);
  PrintLine;
end.
def print_line():
    print("-" * 24)

def show_item(item, price, qty):
    print(item + ": Rs.", price * qty)

print_line()
print("SAMPLE SHOP BILL")
print_line()
show_item("Bread", 120, 2)
show_item("Milk packet", 280, 1)
show_item("Eggs", 55, 6)
print_line()

▶ Sample runනියැදි ධාවනය · same output in Pascal and PythonPascal සහ Python දෙකෙහිම එකම ප්‍රතිදානය

------------------------
SAMPLE SHOP BILL
------------------------
Bread: Rs. 240
Milk packet: Rs. 280
Eggs: Rs. 330
------------------------

🎮 Game🎮 ක්‍රීඩා

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

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

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

  • Sub-program = named part doing one job.උප වැඩසටහන = එක් කාර්යයක් කරන නමක් ඇති කොටස.
  • Benefits: reusability, readability, maintainability.වාසි: නැවත භාවිතය, කියවීමේ පහසුව, නඩත්තුව.
  • Function returns a value.ශ්‍රිතය අගයක් ආපසු දෙයි.
  • Procedure returns no value.ක්‍රියා පටිපාටිය අගයක් ආපසු නොදෙයි.
  • Parameters receive; arguments are sent.පරාමිති ලබා ගනී; තර්ක යවයි.
  • Python: def … return.Python: def … return.
  • Pascal: FunctionName := value.Pascal: FunctionName := value.
  • Built-ins: print, len, writeln, sqrt.ගොඩනැගූ: print, len, writeln, sqrt.

Downloadsබාගත කිරීම්

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

Next noteඊළඟ සටහන 1.11 →

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