Python Learning Guide for Cambridge International AS & A Level
Computer Science 9618 (Paper 4)
1. Python Basics (Essential)
Variables and Data Types
o int, float, str, bool
o Type casting: int(), str(), float()
Input and Output
o input(), print()
o String formatting using f"..."
Operators
o Arithmetic: +, -, *, /, //, %, **
o Comparison: ==, !=, >, <, >=, <=
o Logical: and, or, not
2. Control Structures
Conditional Statements
if condition:
...
elif condition:
...
else:
...
Loops
o for loop: iterating over a range or list
o while loop: condition-based iteration
o break and continue
3. Lists and Strings
List creation and manipulation
o Append, insert, remove, index, pop
o Looping through lists
o Nested lists (2D lists)
String manipulation
o Slicing: s[0:3], s[::-1]
o Built-in functions: .lower(), .upper(), .strip(), .find(),
.replace()
4. Functions and Procedures
Defining and calling functions
def my_function(param1, param2):
return result
Parameters and Return values
Global vs Local variables
Use of None for procedures (functions without return)
5. File Handling
Reading from a text file
with open("file.txt", "r") as f:
lines = f.readlines()
Writing to a text file
with open("file.txt", "w") as f:
f.write("Hello\n")
Appending to a file: mode = 'a'
6. Basic Algorithms
Linear Search
Binary Search (on sorted lists)
Bubble Sort
Count occurrences
Finding min/max
Average calculation
7. 2D Lists
Creating and accessing 2D lists:
matrix = [[1, 2], [3, 4]]
value = matrix[1][0] # 3
Looping through rows and columns
8. Trace Tables and Dry Run
Practice manually tracing the output of code
Understand variable state changes
9. Problem-Solving Techniques
Breaking tasks into small subroutines
Writing pseudocode and converting to Python
Testing with sample data
10. Sample Topics from Past Papers
Student records (files with names and scores)
Simple quiz system
Basic user authentication system
Leaderboard or scoreboard handling
Product or stock inventory management
11. Good Coding Practices
Use clear variable names
Comment your code
Keep functions short and specific
Indentation and structure are important
12. Optional (but helpful)
Using try...except for error handling
Understanding and writing simple classes (if A2 required)
Start practicing past papers from 2021 onward. Make sure you can:
Understand the problem statement
Plan using pseudocode or flowcharts
Translate into Python
Test and debug your code