INPUT command

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

INPUT command

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 a variable called Age?
A INPUT 25 Age
B INPUT Age
2. What does INPUT Answer do?
A Reads what the user types and stores it in Answer
B Displays the value of Answer on the screen
3. Which is the better way to ask the user for their name?
A OUTPUT "Enter your name" INPUT Name
B INPUT Name OUTPUT "Enter your name"
4. Which INPUT statement follows the rule of one variable per INPUT?
A INPUT Height
B INPUT Height, Weight
5. Which command is used to take a value from the keyboard in Cambridge pseudocode?
A OUTPUT
B INPUT

Match the Pairs

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

Left columnRight column
1INPUT Answer AINPUT Length INPUT Width
2OUTPUT "Enter your age" BOUTPUT "Enter your name" INPUT Name
3Show a prompt first, then read the user's value into a variable CTwo variables are listed in one INPUT. Each INPUT must read into only one variable, so use INPUT Length then INPUT Width on separate lines.
4Use one variable per INPUT to read two separate values DINPUT needs a variable name, not a prompt string. Use OUTPUT for the prompt and then INPUT Age to store the value.
5INPUT Length, Width EReads a value typed by the user and stores it in the variable Answer
6INPUT "Enter your age" FShows a prompt message so the user knows what to type before the INPUT

Definitions

INPUT Answer

Fill in the Blanks

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

1.
_____ Answer
2.
DECLARE Age : INTEGER OUTPUT "Enter your age" INPUT ___
3.
______ "Enter your name" INPUT Name
4.
DECLARE Score : INTEGER OUTPUT "Enter your score" _____ Score
5.
OUTPUT "Enter a number" INPUT Number OUTPUT ______ * 2

Spot the Error

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

Question 1
A INPUT "Enter your name"
B INPUT Name
C OUTPUT "Hello ", Name
Question 2
A DECLARE Score : INTEGER
B OUTPUT "Enter your score"
C Input Score
D OUTPUT "Score: ", Score
Question 3
A DECLARE Height, REAL
B OUTPUT "Enter your height"
C INPUT Height
Question 4
A DECLARE Mark : INTEGER
B OUTPUT "Enter a mark"
C Mark ← INPUT
D OUTPUT "Mark: ", Mark
Question 5
A OUTPUT "Enter your name"
B INPUT Name
C OUTPUT "Enter your age"
D INPUT Name, Age
E OUTPUT Name, Age

Answer Key

INPUT command
Section A: Quick Questions
Q1
B — INPUT Age
Q2
A — Reads what the user types and stores it in Answer
Q3
A — OUTPUT "Enter your name" INPUT Name
Q4
A — INPUT Height
Q5
B — INPUT
Section B: Match the Pairs
Q1
INPUT Answer → Reads a value typed by the user and stores it in the variable Answer
Q2
OUTPUT "Enter your age" → Shows a prompt message so the user knows what to type before the INPUT
Q3
Show a prompt first, then read the user's value into a variable → OUTPUT "Enter your name" INPUT Name
Q4
Use one variable per INPUT to read two separate values → INPUT Length INPUT Width
Q5
INPUT Length, Width → Two variables are listed in one INPUT. Each INPUT must read into only one variable, so use INPUT Length then INPUT Width on separate lines.
Q6
INPUT "Enter your age" → INPUT needs a variable name, not a prompt string. Use OUTPUT for the prompt and then INPUT Age to store the value.
Section C: Definitions
Q1
INPUT Answer — INPUT followed by a variable name reads a value typed by the user and stores it in that variable. Use one variable per INPUT, and OUTPUT a prompt first.
Section D: Fill in the Blanks
Q1
INPUT Answer
Q2
DECLARE Age : INTEGER OUTPUT "Enter your age" INPUT Age
Q3
OUTPUT "Enter your name" INPUT Name
Q4
DECLARE Score : INTEGER OUTPUT "Enter your score" INPUT Score
Q5
OUTPUT "Enter a number" INPUT Number OUTPUT Number * 2
Section E: Spot the Error
Q1
A — INPUT reads a value into a variable, so it needs a variable name, not a message. Use OUTPUT to show the prompt: OUTPUT "Enter your name".
Q2
C — Cambridge pseudocode keywords are written in capital letters. It should be INPUT Score.
Q3
A — A DECLARE needs a colon between the variable name and its data type. It should be DECLARE Height : REAL.
Q4
C — INPUT is a command followed by the variable name. It is not a value you assign with ←. It should be INPUT Mark.
Q5
D — Use one variable per INPUT. Name was already read on line 2, so line 4 should be INPUT Age.