Back
Unit 9 / 14

A/L ICT Unit 9: Programming (Python)

කාලච්ඡේද 74ක් සහිත A/L ICT syllabus එකේ විශාලම unit එක මේකයි. ගැටලු විසඳන ක්‍රමය ඉගෙන ගෙන Python භාෂාවෙන් code ලියන්න පුහුණු වෙනවා.

Syllabus එකේ ඇති මාතෘකා

  • ගැටලු විසඳීම, top-down සහ stepwise refinement
  • Algorithms, pseudocode
  • Programming paradigms, translators, IDE
  • Control structures, sub-programs
  • Strings, lists, tuples, dictionaries
  • File handling, Python හරහා database භාවිතය
  • Sequential search සහ bubble sort

Bubble sort

def bubble_sort(a):
    n = len(a)
    for i in range(n - 1):
        for j in range(n - 1 - i):
            if a[j] > a[j + 1]:
                a[j], a[j + 1] = a[j + 1], a[j]
    return a

print(bubble_sort([5, 2, 9, 1]))  # [1, 2, 5, 9]

එක් එක් වටයේදී විශාලම අගය ලැයිස්තුවේ අගට යනවා, ඒ නිසා ඊළඟ වටයේ එක අගයක් අඩුවෙන් බැලුවාම හරි.

File එකකට ලිවීම

with open("marks.txt", "a") as f:
    f.write("Nimal,75\n")

"a" mode එක පවතින දත්ත නොමකා අගට එකතු කරනවා. "w" mode එක file එක අලුතින් ලියනවා.

විභාගයට: 2025 Paper II හි Python functions ලියන්න ආවා. කඩදාසියේ code ලියන්න පුරුදු වෙන්න, indentation නිවැරදිව තියාගන්න.

A/L ICT Units සියල්ල