What programming fundamentals covers
This topic is about how programs actually work under the hood: sequence, selection and iteration, the three core data types, arrays, string handling, file handling, SQL basics, and validation. AQA expects you to trace code by hand and to write short programs in pseudocode or your chosen language (Python is most common).
The three constructs
- Sequence: instructions run in order, one after another.
- Selection: IF, ELSE IF, ELSE (and CASE/switch) branch the flow based on a condition.
- Iteration: count-controlled loops (FOR) run a set number of times; condition-controlled loops (WHILE, DO UNTIL/REPEAT) run until a condition is met. WHILE checks before the loop body runs; DO UNTIL checks after, so it always runs at least once.
Data types and casting
- Integer: whole numbers. Real/float: numbers with a decimal point. Boolean: True or False only. Character: a single symbol. String: a sequence of characters.
- Casting converts one type to another, eg str(), int(), float() in Python. A common exam mistake is forgetting that input() always returns a string, so numbers typed in must be cast before doing maths on them.
- Concatenation joins strings with +; you cannot concatenate a string and an integer directly without casting first.
Arrays
- An array holds multiple values of the same type under one identifier. 1D arrays are lists; 2D arrays are grids (rows and columns), accessed with two indices like array[row][column].
- Indexing starts at 0 in most exam pseudocode and in Python, so an array of 5 items runs from index 0 to 4.
String handling operations
- Know length (len), substring/slicing, concatenation, converting case (upper/lower), and converting between string and number types. These crop up constantly in exam trace tables.
File handling
- Standard operations are open, read, write and close a file. Always close a file after use to save changes and free the resource.
SQL basics
- SELECT chooses columns, FROM names the table, WHERE filters rows. Example: SELECT name FROM students WHERE grade = 9.
- Also know INSERT INTO (add a record), UPDATE (change a record), DELETE FROM (remove records).
Validation vs authentication
- Validation checks data is sensible (eg range check, length check, type check, presence check). It does not check the data is true, only that it is usable.
- Authentication checks a user's identity, eg a username and password.
Common mistakes
- Mixing up validation (checking format) with verification (checking accuracy, eg double-entry or proofreading).
- Off-by-one errors when looping through arrays because indexing starts at 0.
- Forgetting WHILE loops can run zero times if the condition is false immediately.
What are the three basic programming constructs?
Sequence, selection, iteration.
tap to reveal
What is the difference between a WHILE loop and a DO UNTIL loop?
WHILE checks the condition first and may run zero times; DO UNTIL checks after, so it always runs at least once.
tap to reveal
What does casting mean?
Converting a value from one data type to another, eg int(), float(), str().
tap to reveal
Why must input() results be cast before doing maths on them?
Because input() always returns a string in Python, even if the user typed a number.
tap to reveal
What index does the first element of an array have?
Index 0.
tap to reveal
How do you access an element in a 2D array?
Using two indices: array[row][column].
tap to reveal
Name the four types of validation check.
Range check, length check, type check, presence check.
tap to reveal
What is the difference between validation and verification?
Validation checks data is sensible/in the right format; verification checks data is accurate, eg by double-entry or proofreading.
tap to reveal
What are the four basic file handling operations?
Open, read, write, close.
tap to reveal
Write the basic structure of an SQL SELECT statement.
SELECT column(s) FROM table WHERE condition.
tap to reveal
What values can a Boolean data type hold?
True or False only.
tap to reveal
What is string concatenation?
Joining two or more strings together, usually with the + operator.
tap to reveal
What SQL command adds a new record to a table?
INSERT INTO.
tap to reveal
What SQL command removes records from a table?
DELETE FROM.
tap to reveal
What is a count-controlled loop, and what construct is used for it?
A loop that runs a set number of times, using a FOR loop.
tap to reveal