Component parts of a problem: inputs

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

Component parts of a problem: inputs

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which one is an input to a system?
A A report printed on the screen
B A student types their name into a form
2. A greenhouse system measures the temperature. Where does this input come from?
A A printer
B A sensor
3. Which is an input to a program?
A A barcode scanned at a till
B A receipt printed for the customer
4. A program opens scores.txt and reads each line. What are those lines?
A Input from a file
B Output to a file
5. A school canteen system must work out the total cost of a meal. Which list shows only inputs?
A Item chosen, quantity entered
B Total cost, receipt printed

Match the Pairs

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

Left columnRight column
1INPUT Name AA siren and a flashing light are outputs. The inputs are the data going in, such as a reading from a motion sensor.
2READFILE("scores.txt", Line) BTemp ← ReadSensor("temperature")
3An input can be a reading from a sensor, such as a temperature sensor in a greenhouse CThese are outputs or results of processing, not inputs. Inputs are the raw data that goes in, such as each mark entered.
4Listing the inputs in a scenario: a quiz asks for a player name and an answer DReads one line of data from a stored file into the variable Line
5Inputs: total score, average mark, grade ETakes data typed in by the user and stores it in the variable Name
6Inputs for an alarm: siren sounds, light flashes FINPUT PlayerName INPUT Answer

Definitions

input

Fill in the Blanks

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

1.
OUTPUT "Enter your name" _____ Name
2.
OPENFILE "scores.txt" FOR ____ READFILE "scores.txt", Line
3.
OPENFILE "scores.txt" FOR READ ________ "scores.txt", Line
4.
OUTPUT "Enter your age" INPUT ___
5.
// A sensor reading is an _____ INPUT Temp

Spot the Error

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

Question 1
A OUTPUT "Enter your name"
B Name ← INPUT
C OUTPUT "Hello ", Name
Question 2
A Total ← 0
B FOR Count ← 1 TO 3
C INPUT Mark
D Total ← Total + Marks
E NEXT Count
Question 3
A OPENFILE "scores.txt" FOR READ
B READFILE "scores.txt", Line
C OUTPUT Line
D CLOSE "scores.txt"
Question 4
A OPENFILE "temps.txt" FOR READ
B READFILE Temp, "temps.txt"
C CLOSEFILE "temps.txt"
Question 5
A DECLARE Barcode : STRING
B OUTPUT "Scan the item"
C INPUT Barcode : STRING
D OUTPUT Barcode

Answer Key

Component parts of a problem: inputs
Section A: Quick Questions
Q1
B — A student types their name into a form
Q2
B — A sensor
Q3
A — A barcode scanned at a till
Q4
A — Input from a file
Q5
A — Item chosen, quantity entered
Section B: Match the Pairs
Q1
INPUT Name → Takes data typed in by the user and stores it in the variable Name
Q2
READFILE("scores.txt", Line) → Reads one line of data from a stored file into the variable Line
Q3
An input can be a reading from a sensor, such as a temperature sensor in a greenhouse → Temp ← ReadSensor("temperature")
Q4
Listing the inputs in a scenario: a quiz asks for a player name and an answer → INPUT PlayerName INPUT Answer
Q5
Inputs: total score, average mark, grade → These are outputs or results of processing, not inputs. Inputs are the raw data that goes in, such as each mark entered.
Q6
Inputs for an alarm: siren sounds, light flashes → A siren and a flashing light are outputs. The inputs are the data going in, such as a reading from a motion sensor.
Section C: Definitions
Q1
input — Data that goes into a system from a user, a sensor or a file, such as a typed name, a temperature reading or a line read from a stored file.
Section D: Fill in the Blanks
Q1
OUTPUT "Enter your name" INPUT Name
Q2
OPENFILE "scores.txt" FOR READ READFILE "scores.txt", Line
Q3
OPENFILE "scores.txt" FOR READ READFILE "scores.txt", Line
Q4
OUTPUT "Enter your age" INPUT Age
Q5
// A sensor reading is an input INPUT Temp
Section E: Spot the Error
Q1
B — INPUT is a keyword followed by the variable that stores the typed data. It is not a value to assign. It should be INPUT Name.
Q2
D — The value typed by the user is stored in Mark, so the variable Marks does not hold the input. It should be Total ← Total + Mark.
Q3
D — The Cambridge keyword for closing a file that was opened for reading input is CLOSEFILE, not CLOSE.
Q4
B — READFILE needs the file name first and then the variable that stores the data read in. It should be READFILE "temps.txt", Temp.
Q5
C — The data type belongs in the DECLARE statement. The INPUT line only names the variable that receives the scanned data. It should be INPUT Barcode.