INPUT and OUTPUT

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

INPUT and OUTPUT

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which line correctly reads a value from the user into the variable Number?
A INPUT Number
B INPUT = Number
2. Which line correctly displays the message Total is followed by the value in Total?
A OUTPUT "Total is ", Total
B OUTPUT "Total is ", "Total"
3. What is the best order for a program that asks a user for a mark?
A INPUT Mark then OUTPUT "Enter a mark"
B OUTPUT "Enter a mark" then INPUT Mark
4. True or false: INPUT Score stores the value the user types in the variable Score.
A True
B False
5. Which keyword shows a message or value on the screen?
A INPUT
B OUTPUT

Match the Pairs

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

Left columnRight column
1INPUT Number ADisplays the message Total is followed by the value stored in Total
2OUTPUT "Total is ", Total BINPUT must be followed by a variable name to store the value in, not a message. Use OUTPUT for the message, then INPUT Number.
3Prompt the user first so they know what to enter, then read their value CTotal is in quotes so the word Total is displayed instead of the variable's value. Remove the quotes around Total.
4Show a variable's value on screen after a text label DReads a value typed by the user and stores it in the variable Number
5INPUT "Enter a number" EOUTPUT "Enter a number" INPUT Number
6OUTPUT "Total is ", "Total" FOUTPUT "Total is ", Total

Definitions

INPUT and OUTPUT

Fill in the Blanks

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

1.
_____ Number
2.
______ "Total is ", Total
3.
OUTPUT "Enter a number" INPUT ______ Total ← Total + Number
4.
Total ← Total + Number OUTPUT "Total is ", _____
5.
______ "Enter a mark" INPUT Mark Total ← Total + Mark

Spot the Error

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

Question 1
A DECLARE Number : INTEGER
B READ Number
C OUTPUT "You entered ", Number
Question 2
A OUTPUT "Enter a number"
B Number ← INPUT
C OUTPUT "Number is ", Number
Question 3
A OUTPUT Enter your age
B INPUT Age
C OUTPUT "Age is ", Age
Question 4
A OUTPUT "Enter first number"
B INPUT Num1
C OUTPUT "You typed " Num1
Question 5
A DECLARE Total : INTEGER
B Total ← 15
C OUTPUT "Total is ", "Total"

Answer Key

INPUT and OUTPUT
Section A: Quick Questions
Q1
A — INPUT Number
Q2
A — OUTPUT "Total is ", Total
Q3
B — OUTPUT "Enter a mark" then INPUT Mark
Q4
A — True
Q5
B — OUTPUT
Section B: Match the Pairs
Q1
INPUT Number → Reads a value typed by the user and stores it in the variable Number
Q2
OUTPUT "Total is ", Total → Displays the message Total is followed by the value stored in Total
Q3
Prompt the user first so they know what to enter, then read their value → OUTPUT "Enter a number" INPUT Number
Q4
Show a variable's value on screen after a text label → OUTPUT "Total is ", Total
Q5
INPUT "Enter a number" → INPUT must be followed by a variable name to store the value in, not a message. Use OUTPUT for the message, then INPUT Number.
Q6
OUTPUT "Total is ", "Total" → Total is in quotes so the word Total is displayed instead of the variable's value. Remove the quotes around Total.
Section C: Definitions
Q1
INPUT and OUTPUT — INPUT stores a value from the user in a variable, e.g. INPUT Number. OUTPUT shows a message or value on screen, e.g. OUTPUT "Total is ", Total. Prompt first so users know what to enter.
Section D: Fill in the Blanks
Q1
INPUT Number
Q2
OUTPUT "Total is ", Total
Q3
OUTPUT "Enter a number" INPUT Number Total ← Total + Number
Q4
Total ← Total + Number OUTPUT "Total is ", Total
Q5
OUTPUT "Enter a mark" INPUT Mark Total ← Total + Mark
Section E: Spot the Error
Q1
B — Cambridge pseudocode uses the keyword INPUT to read a value into a variable. Line 2 should be INPUT Number.
Q2
B — INPUT is a keyword that comes first, followed by the variable name. It is not used on the right of an assignment. It should be INPUT Number.
Q3
A — A message to display must be inside double quotes. Without them the computer reads the words as variable names. It should be OUTPUT "Enter your age".
Q4
C — Items in an OUTPUT statement must be separated by commas. The comma is missing after the message. It should be OUTPUT "You typed ", Num1.
Q5
C — Putting Total in quotes outputs the word Total instead of the value stored in the variable. It should be OUTPUT "Total is ", Total.