school course
Grade 12 Science: Computer science
4 units across the school year. Each has a worked example, an activity and a standard to meet.
about this course
What you will be able to do
- Apply Write and test functions and handle files.
- Apply Implement stacks and queues.
- Understand Describe network layers and security.
- Apply Connect Python with a database and query it.
Task, condition and standard
Task
Meet the outcome of every unit in Grade 12 Science Computer science, and keep one piece of evidence for each.
Condition
A 36-week school year, 4 units, a teacher or guide, a learning book or device, and local examples in the local language first with English support.
Standard
Each unit: at least 70 percent on an exam-style task, with the method shown. Course pass: no unit at 'Not yet' after one retry, and a pass in SA1 and SA2.
Assessment plan
Formative checks FA1 to FA4 around weeks 6, 12, 24 and 30; summative checks SA1 in week 18 and SA2 in week 36.
unit by unit
4 units with worked examples
Unit 1 Python functions, files and exceptions Weeks 1 to 9Apply
In this unit, 'Python functions, files and exceptions', you learn to write and test functions and handle files. You work with exam-style questions and written reasoning. You see it, say it, then do it alone.
- See it: watch or try the skill in 'Python functions, files and exceptions' on a teacher screen or a safe device.
- Name the parts: write the key words and what each part does.
- Use it: write and test functions and handle files. Save your work in a named file or folder.
- Test and fix: run it, find one fault, correct it, and note what you changed.
Step by step.
- Step 1, A function with exception handling: def safe_div(a, b): try: return a / b except ZeroDivisionError: return None. safe_div(10, 2) returns 5.0 and safe_div(5, 0) returns None instead of crashing the program.
- Step 2, Test with assert: assert safe_div(10, 2) == 5.0 passes silently. assert safe_div(5, 0) is None also passes. If a test fails, Python raises AssertionError with the line number, so the bug is found quickly.
- Step 3, Prepare a file: nums.txt contains three lines: 4, then x, then 6. The goal is to total the valid numbers. The expected answer is 4 plus 6, which is 10, and x should be skipped and reported.
- Step 4, Read with handling: def read_total(path): total = 0, then with open(path) as f: for line in f: try: total += int(line) except ValueError: print('skip', line.strip()), then return total. Each int() is guarded by its own try block.
- Step 5, Run and check: read_total('nums.txt') prints skip x and returns 10. Because int('4\n') and int('6\n') accept surrounding whitespace, they convert, but int('x') raises ValueError, which is caught, so the loop continues.
- Step 6, Missing file: read_total('none.txt') raises FileNotFoundError because open fails. A caller wraps it in try and except FileNotFoundError and prints 'No such file'. Different errors need different handlers, and a bare except would hide mistakes.
- Your turn: Write average(nums) that returns 0 for an empty list, and test it. Model answer: if not nums: return 0, otherwise return sum(nums) / len(nums); assert average([2, 4, 6]) == 4 and assert average([]) == 0.
Activity. About 40 to 50 minutes of class work, then one short practice task for home. Keep evidence: a timed paper and an error log.
Standard to meet. Write and test functions and handle files: at least 70 percent on an exam-style task, with the method shown.
Unit 2 Data structures: stacks and queues Weeks 10 to 18Apply
In this unit, 'Data structures: stacks and queues', you learn to implement stacks and queues. You work with exam-style questions and written reasoning. You see it, say it, then do it alone.
- See it: watch or try the skill in 'Data structures: stacks and queues' on a teacher screen or a safe device.
- Name the parts: write the key words and what each part does.
- Use it: implement stacks and queues. Save your work in a named file or folder.
- Test and fix: run it, find one fault, correct it, and note what you changed.
Step by step.
- Step 1, Stack with a list: stack = [], then stack.append(5), stack.append(8), stack.append(2). The stack is [5, 8, 2] with 2 on top. print(stack.pop()) prints 2, then print(stack[-1]) prints 8, the new top, and print(stack) shows [5, 8].
- Step 2, Last in, first out: The last item added, 2, was the first removed. Calling pop() on an empty list raises IndexError, so check if stack: before popping. A stack suits undo history and bracket checking.
- Step 3, Queue with deque: from collections import deque, then q = deque(), q.append('A'), q.append('B'), q.append('C'). print(q.popleft()) prints A, and print(list(q)) shows ['B', 'C']. First in, first out, like a print queue.
- Step 4, Why deque: Removing from the front of a plain list with pop(0) shifts every other item, while deque.popleft() is fast. Use a list for stacks and a deque for queues.
- Step 5, Balanced brackets: def balanced(s): st = [], for ch in s: if ch == '(': st.append(ch) elif ch == ')': if not st: return False, then st.pop(); finally return len(st) == 0. balanced('((a+b)*c)') is True.
- Step 6, Trace the failures: balanced('(a+b))') pushes once, pops once, then meets a second ) with an empty stack and returns False. balanced('(a+b') ends with one item left, so len(st) is 1 and it returns False.
- Your turn: Reverse 'abc' with a stack. Model answer: push a, b, c to make [a, b, c]; pop gives c, then b, then a; joining them gives 'cba'. The last character comes out first.
Activity. About 40 to 50 minutes of class work, then one short practice task for home. Keep evidence: a timed paper and an error log.
Standard to meet. Implement stacks and queues: at least 70 percent on an exam-style task, with the method shown.
Unit 3 Computer networks and security Weeks 19 to 27Understand
In this unit, 'Computer networks and security', you learn to describe network layers and security. You work with exam-style questions and written reasoning. You see it, say it, then do it alone.
- See it: watch or try the skill in 'Computer networks and security' on a teacher screen or a safe device.
- Name the parts: write the key words and what each part does.
- Use it: describe network layers and security. Save your work in a named file or folder.
- Test and fix: run it, find one fault, correct it, and note what you changed.
Step by step.
- Step 1, The layers: A browser request passes through four layers. Application: HTTP data. Transport: TCP splits it into segments with port numbers, such as 443 for secure web traffic. Network: IP adds source and destination addresses. Link: frames move it over one hop.
- Step 2, Follow one request: A student opens a page. The browser makes an HTTP request, TCP adds the destination port 443, IP adds the server's address, and the link layer sends the frame to the router. The server reverses the process, so the reply climbs the layers.
- Step 3, Subnet: 192.168.1.0/24 has a prefix of 24 bits, leaving 8 host bits. 2 to the power 8 is 256 addresses, and two are reserved, the network and the broadcast, so 254 hosts can be used. The mask is 255.255.255.0.
- Step 4, Split into smaller subnets: With /26 there are 6 host bits, so 2 to the power 6 gives 64 addresses and 62 usable hosts. The first subnet is 192.168.1.0 to 192.168.1.63, with hosts .1 to .62, and the next starts at .64. The mask is 255.255.255.192.
- Step 5, Encryption example: A Caesar cipher with shift 3 changes CAT to FDW, because C moves to F, A to D and T to W. It is easy to break, so real systems use strong, well-tested algorithms. Never design your own for real data.
- Step 6, Password strength: An 8-letter lowercase password has 26 to the power 8, about 208.8 billion possibilities. With 62 characters, upper and lower case letters and digits, 62 to the power 8 is about 218 trillion. Longer, varied passwords are much harder to guess.
- Your turn: How many usable hosts in a /28 subnet? Model answer: 32 minus 28 is 4 host bits; 2 to the power 4 is 16 addresses; minus the network and broadcast addresses gives 14 usable hosts.
Activity. About 40 to 50 minutes of class work, then one short practice task for home. Keep evidence: a timed paper and an error log.
Standard to meet. Describe network layers and security: at least 70 percent on an exam-style task, with the method shown.
Unit 4 Databases and SQL with Python Weeks 28 to 36Apply
In this unit, 'Databases and SQL with Python', you learn to connect Python with a database and query it. You work with exam-style questions and written reasoning. You see it, say it, then do it alone.
- See it: watch or try the skill in 'Databases and SQL with Python' on a teacher screen or a safe device.
- Name the parts: write the key words and what each part does.
- Use it: connect Python with a database and query it. Save your work in a named file or folder.
- Test and fix: run it, find one fault, correct it, and note what you changed.
Step by step.
- Step 1, Connect and create: import sqlite3, con = sqlite3.connect('school.db'), cur = con.cursor(), then cur.execute('CREATE TABLE IF NOT EXISTS marks (name TEXT, score INTEGER)'). If school.db does not exist, the file is created with an empty marks table.
- Step 2, Insert safely: cur.executemany('INSERT INTO marks VALUES (?, ?)', [('Learner 1', 72), ('Learner 2', 91), ('Learner 3', 65), ('Learner 4', 88)]) then con.commit(). Without commit the rows are not saved. Running this twice would add 8 rows, so run it once.
- Step 3, Query: cur.execute('SELECT name, score FROM marks WHERE score >= 80 ORDER BY score DESC') then print(cur.fetchall()). Output: [('Learner 2', 91), ('Learner 4', 88)]. fetchall returns a list of tuples, one per row.
- Step 4, Aggregate: cur.execute('SELECT AVG(score) FROM marks') then print(cur.fetchone()[0]). The output is 79.0 because 72 plus 91 plus 65 plus 88 is 316, and 316 divided by 4 is 79. fetchone returns one tuple.
- Step 5, Parameters not string joining: user_name = 'Learner 1', cur.execute('SELECT score FROM marks WHERE name = ?', (user_name,)) returns [(72,)] with fetchall. The question mark keeps user input as data, which prevents SQL injection from input like x' OR '1'='1.
- Step 6, Close: con.close() releases the file. Wrapping work in try and finally ensures the connection closes even after an error. Reopening school.db and running COUNT(*) should still return 4 rows.
- Your turn: Create pets(name, age) with ('Cat', 3), ('Dog', 7), ('Bird', 1) and print pets older than 2. Model answer: executemany inserts, commit, SELECT name FROM pets WHERE age > 2 ORDER BY age gives [('Cat',), ('Dog',)].
Activity. About 40 to 50 minutes of class work, then one short practice task for home. Keep evidence: a timed paper and an error log.
Standard to meet. Connect Python with a database and query it: at least 70 percent on an exam-style task, with the method shown.
assessment
How you are checked
Evidence for each unit is marked with this rubric by a teacher, and by a peer where the unit allows. Pass: no criterion at 'Not yet' after one retry.
| Criterion | Not yet | Meets | Exceeds |
|---|---|---|---|
| It works | Does not run | Runs with help | Runs and handles odd input |
| Understanding of the parts | Cannot name | Names most | Names and explains |
| Planning | None | A list | A clear ordered plan |
| Safety and care | Needs reminding | Follows rules | Follows rules and helps others |
| Practice habit | Rarely | Weekly | Most days |
Ten-question check, with model answers
Q1. Unit 1 (Python functions, files and exceptions): Write average(nums) that returns 0 for an empty list, and test it.
Model answer: if not nums: return 0, otherwise return sum(nums) / len(nums); assert average([2, 4, 6]) == 4 and assert average([]) == 0. (Covered in unit 1: Python functions, files and exceptions.)
Q2. Unit 2 (Data structures: stacks and queues): Reverse 'abc' with a stack.
Model answer: push a, b, c to make [a, b, c]; pop gives c, then b, then a; joining them gives 'cba'. The last character comes out first. (Covered in unit 2: Data structures: stacks and queues.)
Q3. Unit 3 (Computer networks and security): How many usable hosts in a /28 subnet?
Model answer: 32 minus 28 is 4 host bits; 2 to the power 4 is 16 addresses; minus the network and broadcast addresses gives 14 usable hosts. (Covered in unit 3: Computer networks and security.)
Q4. Unit 4 (Databases and SQL with Python): Create pets(name, age) with ('Cat', 3), ('Dog', 7), ('Bird', 1) and print pets older than 2.
Model answer: executemany inserts, commit, SELECT name FROM pets WHERE age > 2 ORDER BY age gives [('Cat',), ('Dog',)]. (Covered in unit 4: Databases and SQL with Python.)
Q5. Unit 1 (Python functions, files and exceptions): Test with assert. Show how you do it and say what the result is.
Model answer: assert safe_div(10, 2) == 5.0 passes silently. assert safe_div(5, 0) is None also passes. If a test fails, Python raises AssertionError with the line number, so the bug is found quickly. (Covered in unit 1: Python functions, files and exceptions.)
Q6. Unit 2 (Data structures: stacks and queues): Last in, first out. Show how you do it and say what the result is.
Model answer: The last item added, 2, was the first removed. Calling pop() on an empty list raises IndexError, so check if stack: before popping. A stack suits undo history and bracket checking. (Covered in unit 2: Data structures: stacks and queues.)
Q7. Unit 3 (Computer networks and security): Follow one request. Show how you do it and say what the result is.
Model answer: A student opens a page. The browser makes an HTTP request, TCP adds the destination port 443, IP adds the server's address, and the link layer sends the frame to the router. The server reverses the process, so the reply climbs the layers. (Covered in unit 3: Computer networks and security.)
Q8. Unit 4 (Databases and SQL with Python): Insert safely. Show how you do it and say what the result is.
Model answer: cur.executemany('INSERT INTO marks VALUES (?, ?)', [('Learner 1', 72), ('Learner 2', 91), ('Learner 3', 65), ('Learner 4', 88)]) then con.commit(). Without commit the rows are not saved. Running this twice would add 8 rows, so run it once. (Covered in unit 4: Databases and SQL with Python.)
Q9. Unit 1 (Python functions, files and exceptions): Prepare a file. Show how you do it and say what the result is.
Model answer: nums.txt contains three lines: 4, then x, then 6. The goal is to total the valid numbers. The expected answer is 4 plus 6, which is 10, and x should be skipped and reported. (Covered in unit 1: Python functions, files and exceptions.)
Q10. Unit 2 (Data structures: stacks and queues): Queue with deque. Show how you do it and say what the result is.
Model answer: from collections import deque, then q = deque(), q.append('A'), q.append('B'), q.append('C'). print(q.popleft()) prints A, and print(list(q)) shows ['B', 'C']. First in, first out, like a print queue. (Covered in unit 2: Data structures: stacks and queues.)
levels L1 to L7
Where this course sits on the ladder
Seven slides, one for each level. Step in at your level and move up; credits stack. A level is reached when you can meet its standard, not by age.
Slide 1. L1 Basic: Computer science as problem solving
On the slide: L1 Basic · Computer science as problem solving
Notes: Name what makes a problem suitable for a computer, such as clear steps and repeated work. Notes: ask learners how they would find the tallest person in a room; they describe each step in words. No devices are needed, just a clear list.
Slide 2. L2 Awareness: Algorithms and flowcharts
On the slide: L2 Awareness · Algorithms and flowcharts
Notes: Describe an algorithm as a flowchart and trace it by hand. Notes: draw a flowchart that finds the larger of two numbers, then run it with 7 and 4 and with 5 and 5. Learners say what the chart does when numbers are equal. Work on paper first.
Slide 3. L3 Foundation: Functions and control flow
On the slide: L3 Foundation · Functions and control flow
Notes: Write a function with conditions and loops and test it with chosen inputs. Notes: write a factorial function; 5 factorial must give 120, and 0 factorial must give 1. Learners test one normal case, one edge case and one wrong input. Take screen breaks.
Slide 4. L4 Practitioner: Data structures and binary search
On the slide: L4 Practitioner · Data structures and binary search
Notes: Apply stacks, queues and sorted arrays to solve a task and predict the cost. Notes: a sorted list of 1,000 items needs at most 10 binary-search steps, since 2 to the 10 is 1,024. Learners trace a search for 37 in a list of 16 numbers and count the steps.
Slide 5. L5 Specialist: Recursion and analysis (this course)
On the slide: L5 Specialist · Recursion and analysis
Notes: Analyse a recursive function, count its calls and improve it with memoisation. Notes: a naive Fibonacci of 5 makes 15 calls. Learners draw the call tree, spot repeated work, add a cache and show the calls falling to 9. Test with small inputs before large ones.
This course: Grade 12 Science Computer science is at this level. Its units include Python functions, files and exceptions; Data structures: stacks and queues; Computer networks and security; Databases and SQL with Python.
Slide 6. L6 Advanced (degree level): Complexity and proofs
On the slide: L6 Advanced · Complexity and proofs
Notes: Evaluate algorithms by growth rate and prove a simple correctness claim. Notes: for n of 1,000,000, n squared is 10 to the 12, but n log2 n is about 2 times 10 to the 7. Learners prove a loop invariant for insertion sort and state the best and worst cases.
Slide 7. L7 Super expert (postgraduate/expert): Lower bounds and research design
On the slide: L7 Super expert · Lower bounds and research design
Notes: Evaluate limits of computation and design a rigorous experiment on algorithms. Notes: any comparison sort of 10 items needs at least the ceiling of log2 of 10 factorial, which is 22 comparisons. Learners plan benchmarks with controlled inputs, repeats, confidence intervals and a data-sharing statement.
Notes: a level is reached when you can meet its standard, not by age. Learners may move up or down a level by subject.
ten locations and global
Localised for your place
Teach in the local language first, with English support. Use local currency, units and examples in every worksheet. Local curriculum and ministry rules are checked before use in a school; Arabic, Islamic, Social and Moral content needs licensed educators and ministry review. Child-safety rules apply for every learner under 18.
India (Bengaluru)
Use INR in money problems; deliver in English, Hindi, Kannada; personal data rule: Digital Personal Data Protection Act 2023; guardian contact for every learner under 18.
Netherlands (Eindhoven area)
Use EUR in money problems; deliver in Dutch, English; personal data rule: EU GDPR (Dutch: AVG), supervised by the Autoriteit Persoonsgegevens; guardian contact for every learner under 18.
UAE (Dubai and Abu Dhabi)
Use AED in money problems; deliver in Arabic, English; personal data rule: Federal Decree-Law No. 45 of 2021 (personal data protection); guardian contact for every learner under 18.
Brazil (Sao Paulo)
Use BRL in money problems; deliver in Portuguese (Spanish and English support); personal data rule: LGPD (Lei Geral de Protecao de Dados); guardian contact for every learner under 18.
Canada (Toronto)
Use CAD in money problems; deliver in English, French; personal data rule: PIPEDA, with provincial rules where they apply; guardian contact for every learner under 18.
United States
Use USD in money problems; deliver in English, Spanish; personal data rule: state privacy laws (for example California), and COPPA for children under 13; guardian contact for every learner under 18.
Singapore
Use SGD in money problems; deliver in English, Mandarin, Malay, Tamil; personal data rule: Personal Data Protection Act (PDPA); guardian contact for every learner under 18.
Australia
Use AUD in money problems; deliver in English; personal data rule: the Privacy Act 1988 and the Australian Privacy Principles; guardian contact for every learner under 18.
Hong Kong (Eastern Asia)
Use HKD in money problems; deliver in Chinese (Cantonese, Mandarin), English; personal data rule: the Personal Data (Privacy) Ordinance; guardian contact for every learner under 18.
Georgia and Israel (Western Asia)
Use GEL or ILS in money problems; deliver in Georgian, Hebrew, Arabic, English; personal data rule: the personal data law of the country where the learner lives; guardian contact for every learner under 18.
Cayman Islands (Caribbean)
Use KYD in money problems; deliver in English; personal data rule: the Data Protection Act; guardian contact for every learner under 18.
Mexico
Use MXN in money problems; deliver in Spanish, English; personal data rule: the federal law on personal data held by private parties; guardian contact for every learner under 18.
where this leads
Next steps, study and work
Next course
Study and work this course supports
- Computing, data and office-technology routes.
- IT support, developer, data entry, web or network technician. These are examples, not promises of a job.
Pathways
next
Draft
Draft course in our own words. Needs review by a qualified teacher before classroom use. Not live.