← IGCSE Computer Science Paper 2

Outputting several values with commas

One OUTPUT command can display several values, separated by commas. Mix text in quotes with variables. Any spaces you want shown must be inside the quotes.

Understanding Outputting several values with commas in IGCSE Computer Science Paper 2

What it does: The space after the colon is inside the quotes, so it appears between Name: and the value of the variable. Text, a variable and more text are separated by commas, so all three parts are displayed by one command. Commas separate each value in one OUTPUT command. Without commas, the command is not valid. "Lives" in quotes is just text, so it would show the word Lives. Without quotes it shows the value 2.

Common mistakes: The values in an OUTPUT command must be separated by commas. A comma is missing between "Level " and 1. It should be OUTPUT "Level ", 1. Quotes around Lives make it text, so the word Lives is displayed instead of its value. A variable must be written without quotes: OUTPUT "You have ", Lives.

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 327–336) and word search (Modules 317–336).

Take this worksheet further — free with Cloodit

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

Learning
Duo
Which OUTPUT command displays: You have 3 lives left (Lives holds 3)?
OUTPUT "You have ", Lives, " lives left"OUTPUT "You have " Lives " lives left"
Matches
OUTPUT "You have " Lives " lives left"
↓
The commas between the values are missing. Each value in an OUTPUT must be separated by a comma.
Applying
Meanings
Term
OUTPUT "You have ", Lives, " lives left"
Meaning
One OUTPUT command can display several values, separated by commas. Mix text in quotes with variables. Any spaces you want shown must be inside the quotes.
Practice
OUTPUT "You have ", Lives, " lives left"
Testing
Gaps
"You have ", Lives, " lives left"
Check Answer
Spots
1OUTPUT "Level " 1
2Score ← 0

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

The 'Firefly' badge — Night Coder, 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 OUTPUT command displays: You have 3 lives left (Lives holds 3)?
A. OUTPUT "You have ", Lives, " lives left" ✓
B. OUTPUT "You have " Lives " lives left"
Commas separate each value in one OUTPUT command. Without commas, the command is not valid.
2. 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 it is a variable. The computer shows the value stored in it, which is 3.
3. Which command puts the space between the word Score: and the number in Score: 50 (Score holds 50)?
A. OUTPUT "Score: ", Score ✓
B. OUTPUT "Score:", Score
The space must be inside the quotes. OUTPUT does not add spaces between values for you.
4. Name holds "Sam". What does OUTPUT "Hello", Name display?
A. HelloSam ✓
B. Hello Sam
There is no space inside the quotes, so none is displayed. Write "Hello " with a space to get Hello Sam.
5. Which is the correct way to display the text and the variable Total together?
A. OUTPUT "Total = Total"
B. OUTPUT "Total = ", Total ✓
Anything inside quotes is shown exactly as written. To display the value of a variable, put its name outside the quotes.

Match the Pairs

OUTPUT "You have ", Lives, " lives left" → Displays text, then the value of Lives, then more text, all on one line
OUTPUT "Score: ", Score → Displays the words Score: followed by the value stored in the variable Score
Spaces you want displayed must be placed inside the quotes of the text → OUTPUT "Name: ", Name
Text and variables can be mixed in one OUTPUT, with commas between each value → OUTPUT "Hello ", Name, "!"
OUTPUT "You have " Lives " lives left" → The commas between the values are missing. Each value in an OUTPUT must be separated by a comma.
OUTPUT "Score:", Score → There is no space inside the quotes after the colon, so the output shows Score:10 with no gap.

Key Term

OUTPUT "You have ", Lives, " lives left"
One OUTPUT command can display several values, separated by commas. Mix text in quotes with variables. Any spaces you want shown must be inside the quotes.

Fill in the Blanks

1. OUTPUT "You have ", Lives, " lives left"
Hint: Type the command that displays values 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. Coins ← 25 OUTPUT "Coins: ", Coins, " gold"
Hint: Type the variable name that is being given a value and then used in the OUTPUT.
4. Lives ← 3 OUTPUT "You have ", Lives, " lives left"
Hint: Type the assignment operator that stores 3 in the variable.
5. DECLARE Lives : INTEGER Lives ← 3 OUTPUT "Lives: ", Lives
Hint: Type the data type used for whole numbers.

Spot the Error

Question 1
A OUTPUT "Level " 1
B Score ← 0
C OUTPUT "Score ", Score
Line A — The values in an OUTPUT command must be separated by commas. A comma is missing between "Level " and 1. It should be OUTPUT "Level ", 1.
Question 2
A Lives ← 3
B OUTPUT "You have ", "Lives"
C Lives ← Lives - 1
Line B — Quotes around Lives make it text, so the word Lives is displayed instead of its value. A variable must be written without quotes: OUTPUT "You have ", Lives.
Question 3
A DECLARE Lives : INTEGER
B Lives ← 3
C Lives ← Lives - 1
D OUTPUT "Now", Lives, " left"
Line D — Spaces must be inside the quotes. Without a space after Now, the output runs together as Now2 left. It should be "Now ".
Question 4
A Score ← 10
B OUTPUT "Score: "; Score
C OUTPUT "Done"
Line B — OUTPUT values are separated by commas, not semicolons. It should be OUTPUT "Score: ", Score.
Question 5
A Name ← "Sam"
B Age ← 15
C OUTPUT Name, " is ", Age,
Line C — Commas go between values only. A trailing comma after the last value is an error because nothing follows it. It should be OUTPUT Name, " is ", Age.

Student with a class code? Join your class →