This is the longest topic in the specification and the one that carries most of the Paper 1 marks. It covers the statements every program is built from, the operators that do the work, the structures that hold data, and the discipline that makes code safe to rely on. Two of the specification's supported languages are Python and C#, so the examples here use Python-style syntax with the AQA pseudo-code where the specification demands it. Learn this as something you write, not something you memorise.
What you need to know
Getting data in
Be able to obtain user input from the keyboard. This is the program asking the person using it for data, and it is the point where most real-world errors come from, because the user might type letters into a box that expects a number. The fix is validation, which is covered in 3.2.11.
Key fact: Input is data obtained from the user at the keyboard.
Getting data out
Be able to output data and information from a program to the computer display. Output is how the program reports what it has done — a total, a message, a table of results. A well-written program outputs enough for the user to understand the result without exposing the program's internal workings.
Key fact: Output is data and information displayed to the user.
What input actually gives you
Whatever you ask for at the keyboard arrives as a string, even if the user types 42. That is why a program that wants to do arithmetic on input must convert it first, using the string conversion operations in 3.2.8. Getting this wrong is the classic beginner bug where '5' + '5' produces 55 instead of 10.
Key fact: Keyboard input arrives as a string, so convert it before doing arithmetic.
Prompting
Good programs tell the user what they want before they read it. A prompt such as 'Enter your age:' makes the difference between a program that is usable and one that is not, and it is a small thing that the mark schemes notice. Prompts also make it obvious which value the program is asking for, which helps when you are tracing somebody else's code.
Key fact: Prompt before input so the user knows what is wanted.
The shape of a program
Input, processing, output is the same three-part split you used in 3.1.1, and it is how the specification organises whole algorithms. Recognising the three parts in a piece of unfamiliar code tells you what the program is for, and it tells you where to look for the bug when it does not work.
Key fact: Input, processing and output is the same split the specification uses for algorithms.
Where they are examined
Paper 1 asks you to trace and write code, so you will be reading input and output statements in almost every question. In Python, input() reads a line from the keyboard and print() displays to the screen. Know what each statement produces — particularly that input() always returns a string — because that is often the point of the question.
Key fact: input() returns a string; print() displays to the screen.
Flashcards
How do you obtain user input in a program?
By reading from the keyboard.
How do you output information from a program?
By displaying it on the computer screen.
What data type does keyboard input arrive as?
A string, even when the user types digits.
What happens if you add two pieces of keyboard input as strings?
The strings are joined, so '5' + '5' gives '55' rather than 10.
Why do programs prompt before reading input?
So the user knows what the program wants, which makes the program usable and the data easier to check.
What are the three parts of a program?
Input, processing and output.
Exam questions
Written in the style of AQA Computer Science, with a mark scheme for each one. No question here is a real past paper question.
mcq1 mark
A user types 20 into a program and the program adds it to 5, but the answer shown is 205. What has gone wrong?
The input was read as a string, so it was joined to the 5 rather than added
The output statement is in the wrong place
The program needs a nested loop
The variable is a constant rather than a variable
Mark scheme: 1 mark for identifying that the input was not converted to an integer, so '20' and 5 were concatenated to give '205' instead of being added to give 25.
short3 marks
Explain in English why a program that reads a number from the keyboard must convert it before doing arithmetic, and what the result would be otherwise.
Mark scheme: 1 mark for stating that keyboard input arrives as a string. 1 mark for explaining that adding a string to a number concatenates it rather than adding it. 1 mark for giving the example, that '5' + 5 gives '55' or 505 rather than 10 or 10.
six6 marks
Explain in English the role of input and output in a program, and what a good program does about them.
Mark scheme: Level 1 (1-2 marks): A short answer saying input reads from the keyboard and output displays on the screen. Level 2 (3-4 marks): A structured answer covering the data types involved, prompting and the conversion problem. Level 3 (5-6 marks): A detailed answer explaining that input and output are two of the three parts of every algorithm, that input always arrives as a string and must be converted before arithmetic, explaining why prompting is good practice and helps the user and the reader, explaining that output should present a meaningful result, and connecting this to the reliability issues covered by validation and robustness in the programming topic.