Why Python is the Centerpiece of A/L ICT Programming
Python was introduced into the Sri Lankan G.C.E. A/L ICT syllabus because of its clean, readable syntax and widespread industry usage. In the examination, Python programming questions appear heavily in both Paper 1 (MCQs predicting outputs and tracing variables) and Paper 2 (writing complete scripts or function definitions).
1. Core Python Data Types and Variables
Python is dynamically typed, meaning variable types are inferred automatically during runtime:
- int: Whole numbers (e.g., count = 42)
- float: Real decimal numbers (e.g., average = 87.5)
- str: Text enclosed in single or double quotes (e.g., name = "ICTF")
- bool: Logical values (True or False)
2. Control Structures: Decisions and Iteration
Conditional Statements (if, elif, else)
Indentation is mandatory in Python. Code blocks are grouped by consistent 4-space indentation:
score = 75 if score >= 75: grade = "A" elif score >= 65: grade = "B" elif score >= 55: grade = "C" elif score >= 35: grade = "S" else: grade = "F" print("Grade:", grade)Loops (for and while)
The for loop iterates over sequences, often combined with range():
# Calculate sum of first 10 natural numbers total = 0 for i in range(1, 11): total += i print("Sum is:", total)3. Essential Built-in Data Structures
Lists (Ordered and Mutable)
Lists are widely tested in past papers for operations like appending, searching, and calculating statistics:
marks = [65, 82, 90, 74, 88] marks.append(95) print("Highest mark:", max(marks)) print("Lowest mark:", min(marks)) print("Average mark:", sum(marks) / len(marks))Dictionaries (Key-Value Pairs)
Dictionaries allow fast lookup by unique keys:
student = {"id": "S101", "name": "Vithu", "stream": "ICT"} print(student["name"]) student["city"] = "Jaffna"4. Working with Text Files (File I/O)
A frequent Part B essay question asks candidates to read from or write to a text file. Always ensure files are opened safely using context managers:
# Reading student data from a file with open("students.txt", "r") as file: for line in file: data = line.strip().split(",") print("Student:", data[0], "Score:", data[1])Key Exam Tips for Python Questions
- Watch Indentation: On handwritten exam papers, ensure your indentation is unambiguous and consistent.
- Variable Tracing: In MCQ questions with nested loops, draw a small trace table on rough paper tracking each variable's value on every iteration.
- Off-by-One Errors: Remember that range(1, 5) generates 1, 2, 3, and 4 (excluding 5).
.webp)



