AQA GCSE Computer Science (8525) · Programming

Programming: free AQA GCSE Computer Science practice questions

Section 3.2 is examined on Paper 1, where you design, write, test and refine program code in the language you were taught: C#, Python 3 or VB.NET. The ideas below are the same in all three. The questions here check the ideas; Paper 1 also asks you to write the code.

Practice

Free practice questions

Programming

Which data type should be used to store whether a user is logged in?

Based on: AQA 8525 · 3.2.1

Programming

Which are the three basic programming constructs?

Based on: AQA 8525 · 3.2.2

Programming

What is the value of 17 DIV 5?

Based on: AQA 8525 · 3.2.3

Programming

An array is declared to hold 5 items and is indexed from 0. What is the index of the last item?

Based on: AQA 8525 · 3.2.6

Mistakes to avoid

  • Confusing validation with authentication. Validation checks that data entered by a user is sensible, for example that it lies within a range. Authentication checks who the user is, for example with a username and password.
  • Assuming arrays start at 1. In the languages used at GCSE they normally start at 0, so the last index of an array of n items is n minus 1.
  • Mixing up DIV and MOD. 17 DIV 5 is 3, which is how many whole times. 17 MOD 5 is 2, which is what is left over.
  • Calling a subroutine that returns a value a procedure. If it returns something it is a function.
  • Saying a logic error breaks the rules of the language. That is a syntax error. A logic error follows the rules but makes the program do the wrong thing, for example give the wrong answer.
  • Giving only normal test data. Test data should also include boundary data and erroneous data.

Data types and the two kinds of named store

The core data types are integer for a whole number, real or float for a number with a decimal part, Boolean for True or False, character for one symbol, and string for a sequence of characters. Whether a user is logged in is a Boolean. A height in metres is a real, because 1.72 has a decimal part and an integer would lose it. A variable is a named store whose value can change while the program runs. A constant is a named value that cannot change once set, which makes a program easier to read and to update.

Every program is built from three constructs

Sequence is one step after another. Selection chooses between paths with IF, ELSE IF and ELSE. Iteration repeats. Iteration comes in two kinds. Count-controlled loops, such as FOR, repeat a fixed number of times. Condition-controlled loops, such as WHILE and REPEAT UNTIL, repeat while or until a condition holds. Arithmetic operators include the usual four plus integer division, written DIV, and remainder, written MOD. MOD is the standard way to test whether a number is even or divisible by something. Relational operators compare two values and give a Boolean. Boolean operators combine conditions with AND, OR and NOT.

Arrays, records and subroutines

An array is a set of items of the same type stored under one name and reached by an index. Arrays are usually indexed from 0, so an array of 5 items has indexes 0 to 4. A two-dimensional array is an array of arrays, indexed with two values, typically row then column. A record stores several related values that may be of different types under one name, for example a name, an age and a member flag. A subroutine is a named block of code you can call. A procedure carries out a task. A function returns a value. Parameters pass data in and the return value passes a result back. Subroutines make programs shorter, easier to test and easier to reuse. A local variable is declared inside a subroutine. It usually exists only while the subroutine is running and can only be accessed within it, so it cannot be changed by accident elsewhere in the program.

Strings, validation and authentication

String handling covers finding the length of a string, finding the position of a character, extracting a substring, joining strings together, which is concatenation, converting between characters and character codes, and converting between strings and numbers. Validation checks that data entered by a user is sensible before it is used, for example that a string has a minimum length, that it is not empty, or that a value lies within a given range. Authentication checks who the user is, usually with a username and password. The two are different jobs.

Errors and testing

A syntax error breaks the rules of the programming language. A logic error follows the rules but makes the program do the wrong thing, for example produce the wrong result, which is why testing matters. Test data should cover normal (typical) data, boundary (extreme) data, which sits either side of the edge of what is allowed, for example 0, 1, 10 and 11 when the allowed range is 1 to 10, and erroneous data, which should be rejected.

Syntax errors and logic errors behave differently
Syntax errorLogic error
Breaks the rules of the programming language.Follows the rules of the language.
Example: a missing closing bracket.Example: using < where the algorithm needed <=, so the result is wrong.
Found by the translator before or during the run.Found by testing with normal, boundary and erroneous data.
FAQ

Frequently asked questions

What is the difference between DIV and MOD?

DIV is integer division and gives how many whole times one number goes into another. MOD gives the remainder. So 17 DIV 5 is 3 and 17 MOD 5 is 2. MOD is the usual way to test whether a number is even.

Do arrays start at 0 or 1?

In the languages used at GCSE they normally start at 0. An array of 5 items has indexes 0 to 4, and the last index of an array of n items is n minus 1.

What is the difference between a procedure and a function?

Both are subroutines, which are named blocks of code you can call. A procedure carries out a task. A function returns a value. If it returns something, it is a function.

What is the difference between validation and authentication?

Validation checks that data entered by a user is sensible before it is used, for example that a value lies within a given range or that a string is not empty. Authentication checks who the user is, for example with a username and password.

What test data should an answer include?

Normal data, boundary data and erroneous data. Normal data is a typical valid value. Boundary data sits either side of the edge of what is allowed, for example 0, 1, 10 and 11 when the allowed range is 1 to 10. Erroneous data should be rejected.

RiverMap Learning apps are independent study tools. They are not affiliated with, endorsed by, or connected to any government body or examination authority. Question content is original and based on publicly available official study materials.