We use cookies including Google AdSense cookies. Opt out at Google Ads Settings. See our Privacy Policy.

🐍
A/L ICT Stream · Sri Lanka · Grades 12 & 13

Programming
with Python

Develop algorithms and encode them in Python — from problem-solving and flowcharts through control structures, functions, data structures (lists, tuples, dictionaries), file handling, SQL integration and bubble sort. The most practical unit in the syllabus — 74 periods covering all 13 competency levels.

74
Periods
13
Sub-levels
12
Downloads
Free
Forever

Advertisement
📢 Google AdSense — 728×90 Leaderboard  |  Slot: 1111111111
← Previous Unit 09 of 13
Unit 09
🐍 74 Periods · Most Practical

Programming
with Python

The most hands-on unit in the ICT syllabus. Learn to think algorithmically, draw flowcharts, write pseudo code and then encode solutions in Python — covering variables, operators, control structures, user-defined functions, lists, tuples, dictionaries, file handling, database connectivity and sorting. Covers competency levels 9.1–9.13 from the NIE ICT syllabus.

🔍 Problem Solving Process
📐 Top-Down Design
📊 Structure Charts
🔄 Flowcharts
📝 Pseudo Code
✋ Hand Traces
🔢 Programming Paradigms
⚙️ Translators — Compilers / Interpreters
🖥️ IDE & Debugging
📦 Variables & Constants
🔣 Primitive Data Types
➕ Operators & Precedence
📥 Input / Output
🔀 Selection (if/elif/else)
🔁 Loops (for / while)
🧩 Nested Control Structures
🔧 Built-in & User Functions
📌 Parameters & Return Values
🌐 Scope of Variables
📋 Strings & Lists
📦 Tuples & Dictionaries
📁 File Handling
🗄️ Database Connectivity
🔍 Sequential Search
🔃 Bubble Sort
🔢 Programming Paradigms
📋
Imperative
Tells computer HOW to do tasks step-by-step. Python, C, Pascal.
🧠
Declarative
Tells computer WHAT to achieve, not how. SQL, Prolog, HTML.
🏗️
Object-Oriented
Models data as objects with properties and methods. Python, Java, C++.
🔧
Compiler
Translates entire source → object code before execution. C, C++.
▶️
Interpreter
Executes source code line-by-line at runtime. Python, JavaScript.
🐍 Python Code Examples — Quick Reference
Control Structures
# Selection
if score >= 75:
    print("Distinction")
elif score >= 55:
    print("Merit")
else:
    print("Pass")

# For loop
for i in range(1, 6):
    print(i)

# While loop
count = 0
while count < 5:
    print(count)
    count += 1
Functions
# User-defined function
def calculate_area(length, width):
    area = length * width
    return area

result = calculate_area(5, 3)
print(result)  # 15

# Default parameter
def greet(name="Student"):
    print(f"Hello, {name}!")

greet()          # Hello, Student!
greet("Kasun") # Hello, Kasun!
Data Structures
# List — mutable
marks = [85, 90, 78, 92]
marks.append(88)
print(marks[0])  # 85

# Tuple — immutable
colours = ("red", "green", "blue")
print(colours[1])  # green

# Dictionary — key:value
student = {
    "name": "Amali",
    "age": 17,
    "grade": "A"
}
print(student["name"])  # Amali
File Handling & Bubble Sort
# File operations
f = open("data.txt", "w")
f.write("Hello, ICT!")
f.close()

with open("data.txt", "r") as f:
    content = f.read()

# Bubble Sort
def bubble_sort(arr):
    n = len(arr)
    for i in range(n):
        for j in range(0, n-i-1):
            if arr[j] > arr[j+1]:
                arr[j], arr[j+1] = \
                arr[j+1], arr[j]
📋 Python Data Structures — Comparison
Type Mutable? Ordered? Duplicates? Example
String No Yes Yes "Hello"
List Yes ✅ Yes Yes [1, 2, 3]
Tuple No 🔒 Yes Yes (1, 2, 3)
Dictionary Yes ✅ Yes (3.7+) Keys: No {"k": "v"}
📚 Competency Levels — Unit 09
COMPETENCY 9.1 · 2 PERIODS
Problem-Solving Process
Understanding the problem, defining it and its boundaries, planning a solution and implementing it. Steps of the problem-solving process.
COMPETENCY 9.2 · 4 PERIODS
Top-Down Design & Structure Charts
Modularisation, top-down design and stepwise refinement methodology. Drawing structure charts to illustrate a solution for a system.
COMPETENCY 9.3 · 6 PERIODS
Algorithmic Approach
Algorithms using flowcharts (standard symbols), pseudo code and hand traces. Drawing flowcharts and writing pseudo code for given problems. Verifying solutions using hand traces.
COMPETENCY 9.4 · 2 PERIODS
Programming Paradigms
Evolution of programming languages (generations 1G–5G). Comparison of imperative, declarative and object-oriented languages.
COMPETENCY 9.5 · 2 PERIODS
Program Translation
Need for translation. Source vs. object program. Interpreters, compilers, hybrid approach. Role of linkers in program execution.
COMPETENCY 9.6 · 4 PERIODS
IDE & Debugging
Basic features of IDE. Opening, saving, compiling and executing programs. Using debugging facilities to identify and fix errors in code.
COMPETENCY 9.7 · 10 PERIODS
Python Basics
Program structure, comments, constants and variables. Primitive data types. Arithmetic, relational, logical and bitwise operators with precedence. Input from keyboard and output to standard devices.
COMPETENCY 9.8 · 12 PERIODS
Control Structures
Sequence, selection (if/elif/else) and repetition (for/while loops). Iteration vs. looping. Applying nested control structures in programs.
COMPETENCY 9.9 · 10 PERIODS
Sub-programs (Functions)
Built-in and user-defined functions. Function structure, parameter passing, return values and default values. Scope of variables — local vs. global. Variable lifetime.
COMPETENCY 9.10 · 8 PERIODS
Data Structures
Strings, lists, tuples and dictionaries. Properties of each. Using relevant data structures in Python programs.
COMPETENCY 9.11 · 6 PERIODS
File Handling
Basic file operations: open, close, read, write and append. Using file modes ('r', 'w', 'a') in Python programs.
COMPETENCY 9.12 · 4 PERIODS
Database Connectivity
Connecting Python to a database. Embedding SQL statements to retrieve, add, modify and delete data programmatically.
COMPETENCY 9.13 · 4 PERIODS
Searching & Sorting
Sequential search technique — implementation and use cases. Bubble sort technique — algorithm steps, implementation and tracing through iterations.
📥 Unit 09 — Available Downloads
📄
Full Notes — Programming (Python)
PDF · 5.3 MB · 72 pages
⬇ Download PDF
📄
Lesson 09 Notes — Programming
PDF · 0.8 MB · 6 pages
⬇ Download PDF
📄
Lesson 09 Notes — Programming
PDF · 1.4 MB · 16 pages
⬇ Download PDF
📄
Lesson 09 Notes — Programming
PDF · 1.0 MB · 12 pages
⬇ Download PDF
📄
Lesson 09 Notes — Programming
PDF · 0.9 MB · 10 pages
⬇ Download PDF
📄
Lesson 09 Notes — Programming
PDF · 1.1 MB · 14 pages
⬇ Download PDF
Advertisement
📢 Google AdSense — In-Article (Fluid)  |  Slot: 3333333333
Other Units
View All →
Section A — Hardware & Fundamentals
Section B — Communication & Systems
Section C — Data & Programming
Section D — Web & Emerging Tech
Section E — Business & Future
Advertisement
📢 Google AdSense — Bottom Responsive Banner  |  Slot: 4444444444
Download starting…
Preparing your file