Exception handling, debugging, file processing + B2 Paper 2 checkpoint
Programming fundamentals turn algorithms into reliable executable procedures. Scope, data types, debugging and exceptions all affect correctness. File processing connects a program to persistent data and requires careful control of reading, writing and data validity.
What you need to be able to do
- DescribeHow programs use common exception handling techniques
- ConstructAnd use common debugging techniques
- ConstructCode to perform file-processing operations
- RetrieveReconnect today’s new material to previously taught content from this topic.
Rapid Recall Deck
Say the answer aloud before flipping. Mark secure knowledge quickly and spend time on the gaps.
- Which three potential program-failure points must you recognize?: Unexpected inputs, resource unavailability, and logic errors.
- What is the role of exception handling?: It allows a program to detect and respond to exceptional runtime conditions instead of failing unpredictably.
- What is the purpose of a finally block or equivalent cleanup step?: To run cleanup code that should occur whether or not an exception is raised, such as closing a resource.
- Which debugging techniques should you be able to use?: Trace tables, breakpoint debugging, print statements, and step-by-step code execution.
- What is the difference between breakpoint debugging and print debugging?: A breakpoint pauses execution so state can be inspected interactively; print debugging records selected values or execution points in output.
- What do read, write, and append modes do when opening a sequential text file?: Read accesses existing data; write creates/overwrites file content; append adds new content after the existing content.
- At the B2 checkpoint, how do local and global variable scopes differ?: A local variable is limited to the block/function/method where it is defined; a global variable is accessible from a wider program scope.
- Which five basic data types should still be secure at the B2 checkpoint?: Boolean value, char, decimal, integer, and string.
Core knowledge and application
How programs use common exception handling techniques
Programming fundamentals turn algorithms into reliable executable procedures. Scope, data types, debugging and exceptions all affect correctness.
Explain it without notes
Describe: How programs use common exception handling techniques in the context of a student-record processing program.
- Potential points of failure in a program must include unexpected inputs, resource unavailability, logic errors
- Role of exception handling in developing programs
- Exception handling constructs that effectively manage errors must include try/catch in Java, and try/ except in Python, along with the finally block
And use common debugging techniques
Programming fundamentals turn algorithms into reliable executable procedures. Scope, data types, debugging and exceptions all affect correctness.
Explain it without notes
Construct: And use common debugging techniques in the context of a student-record processing program.
- Debugging techniques may include trace tables, breakpoint debugging, print statements and step-by- step code execution
Core knowledge and application
Code to perform file-processing operations
File processing connects a program to persistent data and requires careful control of reading, writing and data validity.
Explain it without notes
Construct: Code to perform file-processing operations in the context of a program that reads and updates saved attendance records.
- Programs that manipulate text files
- Opening a sequential file in various modes (read, write, append)
- How to read from and write to files, append data to an existing file, and close a file once operations are completed
- Classes for Java users may include Scanner, FileWriter, BufferedReader
- Functions for Python users may include open(), read(), readline(), write(), close()
Programming checkpoint
try:
with open("scores.txt", "r") as f:
for line in f:
print(int(line.strip()))
except (OSError, ValueError) as error:
print("Data could not be processed")try (BufferedReader br = new BufferedReader(new FileReader("scores.txt"))) {
String line;
while ((line = br.readLine()) != null) {
System.out.println(Integer.parseInt(line.trim()));
}
} catch (IOException | NumberFormatException e) {
System.out.println("Data could not be processed");
}Modify it
Change one condition, input or operation so the program solves a slightly different problem. Predict the effect before editing.
Failures, exceptions and debugging
Potential failures
- Unexpected input: text entered where an integer is required.
- Resource unavailable: a file or network resource cannot be opened.
- Logic error: the program runs but produces the wrong result.
Debugging toolkit
- trace table for changing variable values;
- breakpoint debugging to pause at a chosen line;
- temporary print/log statements;
- step-by-step execution to inspect state after each statement.
f = None
try:
f = open("scores.txt", "r")
value = int(f.readline())
except (OSError, ValueError) as error:
print("Could not read a valid score")
finally:
if f is not None:
f.close()BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("scores.txt"));
int value = Integer.parseInt(br.readLine());
} catch (IOException | NumberFormatException e) {
System.out.println("Could not read a valid score");
} finally {
try { if (br != null) br.close(); } catch (IOException ignored) {}
}Transfer to a new scenario
- Potential points of failure in a program must include unexpected inputs, resource unavailability, logic errors
- Role of exception handling in developing programs
- Debugging techniques may include trace tables, breakpoint debugging, print statements and step-by- step code execution
- Programs that manipulate text files
- Opening a sequential file in various modes (read, write, append)
Paper 2 practice
- Describe: How programs use common exception handling techniques in the context of a student-record processing program.
- Construct: And use common debugging techniques in the context of a student-record processing program.
- Construct: Code to perform file-processing operations in the context of a student-record processing program.
2027 Case Study Launch
This is the first formal case-study checkpoint. The scenario is a creative design company evaluating generative AI for image creation. HL preparation will build around diffusion models, GANs, hybrid models, training data, computational demands and ethical/legal trade-offs.
Four HL research directions
- Iterative diffusion/denoising and computational demand.
- Training-data intellectual property, bias and mitigation.
- Generator–discriminator balance in GAN training.
- How hybrid models combine strengths and offset limitations across diffusion, GANs, VAEs and flow-based models.
First research checkpoint
Start a research note on diffusion models: identify why iterative denoising is computationally demanding.
Challenge focus: Explain how iterative denoising creates images and evaluate the computational demands of the process.
Finish the learning cycle
IA — main task
Continue Criterion D development. Keep code readable, record meaningful implementation decisions, and maintain testing/evidence notes as you work.
Syllabus — short
Complete one targeted Paper 2/Paper 1 retrieval task from today’s lesson.