Input with INPUT

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

Input with INPUT

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which line reads a value from the user into a variable called Age?
A INPUT Age
B INPUT 25
2. Which pair of lines is in the correct order?
A DECLARE Age : INTEGER INPUT Age
B INPUT Age DECLARE Age : INTEGER
3. Where does the value the user types go after INPUT Answer runs?
A Onto the screen as output
B Into the variable Answer
4. A variable is declared as DECLARE Score : INTEGER. Which entry can INPUT Score accept?
A 42
B forty-two
5. Which is the better way to ask the user for their name?
A INPUT Name OUTPUT "Enter your name"
B OUTPUT "Enter your name" INPUT Name

Match the Pairs

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

Left columnRight column
1INPUT Age AWaits for the user to type a value and stores it in the variable Age
2OUTPUT "Enter your name: " BDECLARE Score : INTEGER INPUT Score
3The variable must be declared before it is used to store the input CAge is an INTEGER, so the user cannot enter text like hello. The type decides what can be entered.
4Ask the user with OUTPUT first, then read their answer with INPUT DShows a prompt so the user knows what to type before the INPUT statement
5INPUT "Age" EINPUT needs a variable name (identifier), not a string in quotes. It should be INPUT Age.
6DECLARE Age : INTEGER INPUT Age // user types: hello FOUTPUT "Enter a number: " INPUT Number

Definitions

INPUT Answer

Fill in the Blanks

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

1.
DECLARE Age : INTEGER OUTPUT "Enter your age: " _____ Age
2.
DECLARE Name : STRING OUTPUT "Enter your name: " INPUT ____
3.
DECLARE Score : _______ OUTPUT "Enter your score: " INPUT Score
4.
DECLARE Price : REAL ______ "Enter the price: " INPUT Price
5.
_______ Colour : STRING OUTPUT "Favourite colour? " INPUT Colour

Spot the Error

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

Question 1
A DECLARE Name : STRING
B OUTPUT "Enter your name"
C READ Name
Question 2
A DECLARE Age : INTEGER
B OUTPUT "Enter your age"
C Age ← INPUT
Question 3
A DECLARE Score : INTEGER
B INPUT Mark
C OUTPUT "You scored ", Score
Question 4
A DECLARE Price : REAL
B INPUT "Price"
C OUTPUT "Price is ", Price
Question 5
A DECLARE Count : INTEGER
B OUTPUT "How many?"
C INPUT Count
D OUTPUT "You chose " Count

Answer Key

Input with INPUT
Section A: Quick Questions
Q1
A — INPUT Age
Q2
A — DECLARE Age : INTEGER INPUT Age
Q3
B — Into the variable Answer
Q4
A — 42
Q5
B — OUTPUT "Enter your name" INPUT Name
Section B: Match the Pairs
Q1
INPUT Age → Waits for the user to type a value and stores it in the variable Age
Q2
OUTPUT "Enter your name: " → Shows a prompt so the user knows what to type before the INPUT statement
Q3
The variable must be declared before it is used to store the input → DECLARE Score : INTEGER INPUT Score
Q4
Ask the user with OUTPUT first, then read their answer with INPUT → OUTPUT "Enter a number: " INPUT Number
Q5
INPUT "Age" → INPUT needs a variable name (identifier), not a string in quotes. It should be INPUT Age.
Q6
DECLARE Age : INTEGER INPUT Age // user types: hello → Age is an INTEGER, so the user cannot enter text like hello. The type decides what can be entered.
Section C: Definitions
Q1
INPUT Answer — Reads a value typed by the user and stores it in the variable named after INPUT (here Answer). Declare the variable first; its data type decides what can be entered.
Section D: Fill in the Blanks
Q1
DECLARE Age : INTEGER OUTPUT "Enter your age: " INPUT Age
Q2
DECLARE Name : STRING OUTPUT "Enter your name: " INPUT Name
Q3
DECLARE Score : INTEGER OUTPUT "Enter your score: " INPUT Score
Q4
DECLARE Price : REAL OUTPUT "Enter the price: " INPUT Price
Q5
DECLARE Colour : STRING OUTPUT "Favourite colour? " INPUT Colour
Section E: Spot the Error
Q1
C — Cambridge pseudocode uses the keyword INPUT to read a value from the user, not READ. The line should be INPUT Name.
Q2
C — INPUT is a statement, not a value to assign. The variable name goes after INPUT, so the line should be INPUT Age.
Q3
B — Mark was never declared. INPUT must name a declared variable, so the line should be INPUT Score.
Q4
B — INPUT needs a variable identifier, not a string in quotes. There should be no quotes: INPUT Price.
Q5
D — Several values in one OUTPUT must be separated by commas. The comma is missing after the text: OUTPUT "You chose ", Count.