All exams← All GCSE Computer Science (AQA) notes

Programming fundamentals: GCSE Computer Science (AQA) revision notes

Revision notes

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.

Key facts

Flashcards

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
Practice questions

Programming fundamentals: 5 practice questions

Q1. Which of the following best describes 'sequence' as a programming construct?
  • A.  Instructions repeat until a condition is met
  • B.  Instructions are executed one after another in the order they are written
  • C.  Data is stored in a named location in memory
  • D.  A decision is made and one of two paths is followed
Show answer & explanation
✓ Answer: B. Instructions are executed one after another in the order they are written
Sequence is one of the three basic programming constructs and simply means statements execute in the order they appear, top to bottom. Iteration (repeating) and selection (branching) are the other two constructs, so those options describe different ideas.
Q2. What is 'iteration' in programming?
  • A.  Storing a value under a variable name
  • B.  Combining two strings into one
  • C.  Converting data from one type to another
  • D.  Repeating a block of code, either a fixed number of times or until a condition is met
Show answer & explanation
✓ Answer: D. Repeating a block of code, either a fixed number of times or until a condition is met
Iteration means repeating a set of instructions, using loops such as FOR, WHILE or DO UNTIL. Storing a value is assignment, and combining strings is concatenation, so those don't describe repetition.
Q3. What is the key difference between a count-controlled loop and a condition-controlled loop?
  • A.  A count-controlled loop uses IF statements internally, while a condition-controlled loop does not
  • B.  A count-controlled loop repeats a known, fixed number of times, while a condition-controlled loop repeats until a stated condition changes
  • C.  There is no real difference; the terms are interchangeable in AQA pseudocode
  • D.  A count-controlled loop can never be skipped, but a condition-controlled loop always runs at least once
Show answer & explanation
✓ Answer: B. A count-controlled loop repeats a known, fixed number of times, while a condition-controlled loop repeats until a stated condition changes
A count-controlled loop (FOR) runs a set number of times decided in advance, whereas a condition-controlled loop (WHILE or DO UNTIL) keeps running until a Boolean condition becomes true or false. Whether it runs at least once depends on WHILE vs DO UNTIL specifically, not on the count/condition distinction in general.
Q4. A program needs to print the numbers 1 to 10. Which type of loop is most appropriate?
  • A.  A WHILE loop, because the condition might never become true
  • B.  A FOR loop, because the number of repetitions is known in advance
  • C.  No loop is needed; this must use selection
  • D.  A DO UNTIL loop, because it must run at least once
Show answer & explanation
✓ Answer: B. A FOR loop, because the number of repetitions is known in advance
Since exactly 10 repetitions are needed and this is known before the loop starts, a FOR (count-controlled) loop is the natural choice. WHILE and DO UNTIL are better suited to situations where the number of repeats depends on a changing condition.
Q5. In AQA pseudocode, a WHILE loop checks its condition:
  • A.  Only on the first pass through the program
  • B.  After the loop body has executed at least once
  • C.  Before each execution of the loop body, so the body may never run
  • D.  Only when an error occurs
Show answer & explanation
✓ Answer: C. Before each execution of the loop body, so the body may never run
A WHILE loop is a pre-condition loop: it tests the condition before running the body, so if the condition is false immediately, the body never executes at all. This contrasts with DO UNTIL, which always executes the body at least once before testing.
Test yourself
See the GCSE Computer Science (AQA) page

More GCSE Computer Science (AQA) topics