← IGCSE Computer Science Paper 2

OUTPUT command

Displays text or values on screen. Text goes in quotes. Items are separated by commas, e.g. OUTPUT "You have ", Lives, " lives left". Also used for user prompts.

Understanding OUTPUT command in IGCSE Computer Science Paper 2

What it does: Text in quotes is displayed exactly as written, so this shows the words Game over. A prompt is just OUTPUT with text, shown before the INPUT command so the user knows what to type. Text must go inside quotes. Without quotes, Welcome would be treated as a variable name. Several items in one OUTPUT command must be separated by commas. To show the value of a variable, leave out the quotes: OUTPUT Score.

Common mistakes: Items in an OUTPUT command must be separated by commas. The comma is missing between "You have " and Lives. It should be OUTPUT "You have ", Lives. Quotes make Score a piece of text, so this would display the word Score rather than 50. To display the value stored in the variable, write OUTPUT Score without quotes.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 27–36) and word search (Modules 27–46).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which line correctly displays the text Welcome on screen?
OUTPUT "Welcome"OUTPUT Welcome
Matches
OUTPUT "You have " Lives " lives left"
↓
The items are not separated by commas, so the command is invalid. Commas are needed between the text and the variable.
Applying
Meanings
Term
OUTPUT
Meaning
Displays text or values on screen. Text goes in quotes. Items are separated by commas, e.g. OUTPUT "You have ", Lives, " lives left". Also used for user prompts.
Practice
OUTPUT "Enter your name: "
Testing
Gaps
Score
Check Answer
Spots
2Lives ← 3
3OUTPUT "You have " Lives

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Tree Frog' badge — Leap of Logic, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which line correctly displays the text Welcome on screen?
A. OUTPUT "Welcome" ✓
B. OUTPUT Welcome
Text must go inside quotes. Without quotes, Welcome would be treated as a variable name.
2. Which line displays the value stored in the variable Score?
A. OUTPUT "Score"
B. OUTPUT Score ✓
A variable name has no quotes, so its value is shown. With quotes, the word Score itself is displayed instead.
3. Which line correctly outputs a message, the variable Lives, and another message in one command?
A. OUTPUT "You have ", Lives, " lives left" ✓
B. OUTPUT "You have " Lives " lives left"
Several items in one OUTPUT command must be separated by commas.
4. Lives is 3. What does OUTPUT "You have ", Lives, " lives left" display?
A. You have Lives lives left
B. You have 3 lives left ✓
Lives has no quotes, so its value 3 is displayed. Only the text in quotes is shown exactly as written.
5. Which statement is true about OUTPUT?
A. OUTPUT can show text and variable values together ✓
B. OUTPUT can only show one item at a time
Items separated by commas can all be shown in a single OUTPUT command.

Match the Pairs

OUTPUT Score → Displays the current value stored in the variable Score on the screen
OUTPUT "You have ", Lives, " lives left" → Displays text, then the value of Lives, then more text, all in one command
OUTPUT can show a plain message to the user in quote marks → OUTPUT "Game over"
OUTPUT can be used as a user prompt to tell the user what to enter before an INPUT → OUTPUT "Enter your age: "
OUTPUT "You have " Lives " lives left" → The items are not separated by commas, so the command is invalid. Commas are needed between the text and the variable.
OUTPUT "Score" → The variable name is in quotes, so it displays the word Score instead of the value stored in the variable.

Key Term

OUTPUT
Displays text or values on screen. Text goes in quotes. Items are separated by commas, e.g. OUTPUT "You have ", Lives, " lives left". Also used for user prompts.

Fill in the Blanks

1. Score ← 50 OUTPUT Score
Hint: Type the command that displays a value on the screen.
2. Lives ← 3 OUTPUT "You have ", Lives, " lives left"
Hint: Type the variable whose value is shown between the two pieces of text.
3. OUTPUT "Enter your name: " INPUT Name
Hint: Type the command that shows a prompt to the user before they enter data.
4. Name ← "Sam" Score ← 42 OUTPUT Name, " scored ", Score
Hint: Type the variable that holds the player's name, which is the first item displayed.
5. Name ← "Sam" OUTPUT "Hello ", Name, "!"
Hint: Type the command that displays several items in one statement, separated by commas.

Spot the Error

Question 1
A DECLARE Lives : INTEGER
B Lives ← 3
C OUTPUT "You have " Lives
Line C — Items in an OUTPUT command must be separated by commas. The comma is missing between "You have " and Lives. It should be OUTPUT "You have ", Lives.
Question 2
A Score ← 50
B OUTPUT "Score"
C OUTPUT "Well done"
Line B — Quotes make Score a piece of text, so this would display the word Score rather than 50. To display the value stored in the variable, write OUTPUT Score without quotes.
Question 3
A OUTPUT "Enter your name
B INPUT Name
C OUTPUT "Hello ", Name
Line A — The text in the user prompt is missing its closing quote mark. It should be OUTPUT "Enter your name".
Question 4
A Price ← 5
B Qty ← 3
C OUTPUT "Cost: "; Price * Qty
Line C — OUTPUT items are separated by commas, not semicolons. It should be OUTPUT "Cost: ", Price * Qty.
Question 5
A DECLARE Age : INTEGER
B OUTPUT "Enter your age"
C INPUT Age
D OUTPUT "Age: ", "Age"
Line D — Putting Age in quotes outputs the word Age instead of the number the user entered. The variable must not be in quotes: OUTPUT "Age: ", Age.

Student with a class code? Join your class →