Skip to content
VirtusAcademy

Input and Output

FoundationHigherAQA

Every interactive program takes input from the keyboard and displays output on screen. These worksheets cover the USERINPUT and OUTPUT keywords, storing input in a variable, writing clear prompts, and the mistake that catches most students out: input is always stored as text, so it must be converted before it can be used in a calculation.

Free downloads

These worksheets and mark schemes are original, written for Virtus Academy and checked against the current AQA specification. Every worksheet comes with a full mark scheme.

Topic overview

Input brings data into a program and output sends results back to the user. Together they are how a program communicates.

Input normally arrives from the keyboard, but may come from a file, a sensor or a network. A crucial detail is that keyboard input arrives as a string, whatever it looks like — so a number typed by the user must be converted before arithmetic, or the plus operator will concatenate rather than add.

Output should be clear and meaningful. Displaying the bare number 47 tells the user nothing; "Your total score is 47" does. Concatenating a label with the value is how this is done, and it usually requires converting the number back to a string first.

Revision notes

Input

Input normally comes from the keyboard, but may also come from a file, a sensor or a network.

Keyboard input always arrives as a string. A number must be converted to an integer or real before it can be used in arithmetic, or the plus operator will concatenate instead of adding.

Output

Output should be meaningful rather than a bare value.

"Your total score is 47" tells the user what the number means; 47 alone does not. Building the message requires concatenating a label with the value.

Prompting the user

An input should always be preceded by a prompt saying what is expected.

A program that waits silently leaves the user guessing. OUTPUT "Enter your age: " followed by age ← USERINPUT is the standard pattern.

Key points

  • Input brings data into a program.
  • Output sends results to the user.
  • Keyboard input arrives as a string.
  • Numbers must be converted before arithmetic.
  • Output should be meaningful, not a bare value.
  • Always prompt before requesting input.

Worked examples

Example 1

Write pseudocode that prompts for a name and greets the user. [3 marks]

Working

OUTPUT 'Enter your name: 'prompt the user before the input
name ← USERINPUTread the value from the keyboard
OUTPUT 'Hello ' + nameconcatenate the greeting with the name

Example 2

Explain why a number entered by the user must be converted before arithmetic. [2 marks]

Working

Keyboard input arrives as a string regardless of what was typedstate the reason
so the plus operator would concatenate the values rather than adding them numericallyexplain the consequence

Example 3

Explain why a program should prompt before requesting input. [2 marks]

Working

Without a prompt the program appears to have stopped, giving the user no indication of what is expectedstate the problem
so a prompt tells the user exactly what to enter and in what formexplain the benefit

Common mistakes

  • Forgetting to convert input before arithmetic.

    It arrives as a string and would be concatenated.

  • Outputting a bare number.

    Include a label so the user knows what it means.

  • Not prompting before input.

    The program appears to have stopped.

  • Assuming input only comes from a keyboard.

    Files, sensors and networks are also input sources.

Exam tips

  • Always prompt before an input statement.
  • Convert input to a number before calculating.
  • Concatenate a label with output values.
  • Remember input can come from several sources.

Key terms

Input
Data brought into a program.
Output
Results sent from a program to the user.
Prompt
A message telling the user what to enter.
Concatenation
Joining a label to a value for output.

Written and reviewed against the current AQA specification. Spotted an error? Let us know.