INPUT

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

INPUT

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which line correctly reads a value typed by the user into a variable called Answer?
A INPUT Answer
B INPUT "Answer"
2. Which line reads a value into a variable called Age?
A INPUT Age
B Age INPUT
3. Which is the correct way to ask for a name, then read it?
A OUTPUT "Enter your name" INPUT Name
B INPUT Name OUTPUT "Enter your name"
4. Which statement is true about INPUT?
A One INPUT can read several variables at once
B Each INPUT reads one value into one variable
5. Which correctly reads two values, Width and Height?
A INPUT Width, Height
B INPUT Width INPUT Height

Match the Pairs

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

Left columnRight column
1INPUT Answer ATwo variables are listed in one INPUT. Each INPUT must read into only one variable.
2INPUT Scores[3] BOUTPUT "Enter your age" INPUT Age
3Show a prompt with OUTPUT first, then read the user's reply into a variable CReads a value typed by the user and stores it in element 3 of the array Scores
4Use one variable per INPUT, so two values need two INPUT statements DINPUT Length INPUT Width
5INPUT Length, Width EA prompt in quotes is placed after INPUT instead of a variable name. INPUT needs a variable, and the prompt belongs in an OUTPUT statement.
6INPUT "Enter a number" FReads a value typed by the user and stores it in the variable Answer

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.
INPUT Width _____ Height
4.
FOR Index ← 1 TO 5 INPUT Scores[_____] NEXT Index
5.
______ "Enter your name: " INPUT Name

Spot the Error

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

Question 1
A OUTPUT "Enter your name"
B READ Name
C OUTPUT "Hello ", Name
Question 2
A DECLARE Age : INTEGER
B OUTPUT "Enter your age"
C INPUT Aged
D OUTPUT Age
Question 3
A OUTPUT Enter your score
B INPUT Score
C OUTPUT Score
Question 4
A DECLARE A, B : INTEGER
B OUTPUT "Enter two numbers"
C INPUT A, B
D INPUT B
E OUTPUT A + B
Question 5
A DECLARE Number : INTEGER
B OUTPUT "Enter a number"
C OUTPUT "Between 1 and 10"
D INPUT Number + 1
E OUTPUT Number * 2

Answer Key

INPUT
Section A: Quick Questions
Q1
A — INPUT Answer
Q2
A — INPUT Age
Q3
A — OUTPUT "Enter your name" INPUT Name
Q4
B — Each INPUT reads one value into one variable
Q5
B — INPUT Width INPUT Height
Section B: Match the Pairs
Q1
INPUT Answer → Reads a value typed by the user and stores it in the variable Answer
Q2
INPUT Scores[3] → Reads a value typed by the user and stores it in element 3 of the array Scores
Q3
Show a prompt with OUTPUT first, then read the user's reply into a variable → OUTPUT "Enter your age" INPUT Age
Q4
Use one variable per INPUT, so two values need two INPUT statements → INPUT Length INPUT Width
Q5
INPUT Length, Width → Two variables are listed in one INPUT. Each INPUT must read into only one variable.
Q6
INPUT "Enter a number" → A prompt in quotes is placed after INPUT instead of a variable name. INPUT needs a variable, and the prompt belongs in an OUTPUT statement.
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
INPUT Width INPUT Height
Q4
FOR Index ← 1 TO 5 INPUT Scores[Index] NEXT Index
Q5
OUTPUT "Enter your name: " INPUT Name
Section E: Spot the Error
Q1
B — Pseudocode uses the keyword INPUT to read a value typed by the user. READ is not a pseudocode keyword. It should be INPUT Name.
Q2
C — INPUT must name the variable that was declared. Aged is a different, undeclared variable, so the value would not be stored in Age. It should be INPUT Age.
Q3
A — The prompt is a string, so it must be written inside quotation marks. It should be OUTPUT "Enter your score".
Q4
C — Each INPUT reads into one variable only. Using INPUT A, B breaks the one-variable-per-INPUT rule. It should be INPUT A, with a separate INPUT B on the next line.
Q5
D — INPUT can only be followed by a variable name, not an expression. The calculation must be done after the value has been read. It should be INPUT Number.