OUTPUT command

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

OUTPUT command

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which line correctly displays the text Welcome on screen?
A OUTPUT "Welcome"
B OUTPUT Welcome
2. Which line displays the value stored in the variable Score?
A OUTPUT "Score"
B OUTPUT Score
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"
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
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

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1OUTPUT Score AOUTPUT "Enter your age: "
2OUTPUT "You have ", Lives, " lives left" BOUTPUT "Game over"
3OUTPUT can show a plain message to the user in quote marks CDisplays the current value stored in the variable Score on the screen
4OUTPUT can be used as a user prompt to tell the user what to enter before an INPUT DDisplays text, then the value of Lives, then more text, all in one command
5OUTPUT "You have " Lives " lives left" EThe items are not separated by commas, so the command is invalid. Commas are needed between the text and the variable.
6OUTPUT "Score" FThe variable name is in quotes, so it displays the word Score instead of the value stored in the variable.

Definitions

OUTPUT

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
Score ← 50 ______ Score
2.
Lives ← 3 OUTPUT "You have ", _____, " lives left"
3.
______ "Enter your name: " INPUT Name
4.
Name ← "Sam" Score ← 42 OUTPUT ____, " scored ", Score
5.
Name ← "Sam" ______ "Hello ", Name, "!"

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A DECLARE Lives : INTEGER
B Lives ← 3
C OUTPUT "You have " Lives
Question 2
A Score ← 50
B OUTPUT "Score"
C OUTPUT "Well done"
Question 3
A OUTPUT "Enter your name
B INPUT Name
C OUTPUT "Hello ", Name
Question 4
A Price ← 5
B Qty ← 3
C OUTPUT "Cost: "; Price * Qty
Question 5
A DECLARE Age : INTEGER
B OUTPUT "Enter your age"
C INPUT Age
D OUTPUT "Age: ", "Age"

Answer Key

OUTPUT command
Section A: Quick Questions
Q1
A — OUTPUT "Welcome"
Q2
B — OUTPUT Score
Q3
A — OUTPUT "You have ", Lives, " lives left"
Q4
B — You have 3 lives left
Q5
A — OUTPUT can show text and variable values together
Section B: Match the Pairs
Q1
OUTPUT Score → Displays the current value stored in the variable Score on the screen
Q2
OUTPUT "You have ", Lives, " lives left" → Displays text, then the value of Lives, then more text, all in one command
Q3
OUTPUT can show a plain message to the user in quote marks → OUTPUT "Game over"
Q4
OUTPUT can be used as a user prompt to tell the user what to enter before an INPUT → OUTPUT "Enter your age: "
Q5
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.
Q6
OUTPUT "Score" → The variable name is in quotes, so it displays the word Score instead of the value stored in the variable.
Section C: Definitions
Q1
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.
Section D: Fill in the Blanks
Q1
Score ← 50 OUTPUT Score
Q2
Lives ← 3 OUTPUT "You have ", Lives, " lives left"
Q3
OUTPUT "Enter your name: " INPUT Name
Q4
Name ← "Sam" Score ← 42 OUTPUT Name, " scored ", Score
Q5
Name ← "Sam" OUTPUT "Hello ", Name, "!"
Section E: Spot the Error
Q1
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.
Q2
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.
Q3
A — The text in the user prompt is missing its closing quote mark. It should be OUTPUT "Enter your name".
Q4
C — OUTPUT items are separated by commas, not semicolons. It should be OUTPUT "Cost: ", Price * Qty.
Q5
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.