#separator:tab
#html:true
#tags:input-processing-output-quiz
#columns:Front Back
According to the IPO model, what are the three parts of every piece of a problem that a computer can solve?
- Planning, implementation, documentation
- Hardware, software, data
- Input, processing, output
- Sender, channel, receiver
- Input, processing, output
Exactly: something goes in at the front, something comes out at the back, and in between the machine computes. Input, processing, output, IPO for short.
Every piece a computer can solve has an input, a processing and an output.
Why does a box with a clear input and a clear expected output bring its own test along?
- Because the computer reports at every call whether the output it delivered matches the input.
- Because you can feed in a known input and compare the result with the expected output.
- Because in a cleanly cut box you can see at once, just by reading the code, which line produces which part of the output.
- Because the processing inside the box is then so manageable that it can hardly be wrong any more.
- Because you can feed in a known input and compare the result with the expected output.
That is exactly the test: known input, expected output, comparison, with a yes or no and no room for interpretation.
A known input and an expected output are already a test, without looking inside the box.
"A red lamp shines in front of a colour sensor with four measuring channels. What is the actual input a receiver program works with?
- The colour red, just as a person standing next to the sensor sees it.
- The word ""red"", which the sensor reports to the program as the colour it recognised.
- Four numbers: the shares of red, green and blue and the overall brightness.
- A small image of the lamp, from which the program reads off the colour at the brightest spot.
" - Four numbers: the shares of red, green and blue and the overall brightness.
Exactly: the sensor delivers four readings, for example r=203, g=41, b=57, c=310. Which of them counts as red is a decision the program makes from the numbers.
The input of the box is what the sensor delivers, and the decision is the work of the program.
"A link sends text with light as a chain of boxes. Which statements are true? (Several answers may be correct.)
""hi"" → encode() → colours → light → sensor → decode() → ""hi""
- The output of
encode() is the input of the next box. - Sender and receiver must agree beforehand which colour stands for which letter.
decode() can work independently of what encode() does.- The chain shows the order in which the data flow through the system.
- The boxes can be put in any order, as long as every one of them is there.
" "- The output of
encode() is the input of the next box.
Correct, that is what connecting boxes means: the output of one becomes the input of the next. - Sender and receiver must agree beforehand which colour stands for which letter.
Correct: encode() turns letters into colours and decode() turns colours back into letters, so both need the same table, for example ""h"" is red. Without it the receiver sees colours but cannot read them. - The chain shows the order in which the data flow through the system.
Correct: boxes in a row show the data flow, from message to message.
Boxes in a row show data flow, and sender and receiver fit together only when they use the same agreement.
"
Look at this function as an IPO box. What are its input and its output?
def encode(text):
colours = []
for letter in text:
colours.append(colour_for(letter))
return colours
- The input is a text, the output is a list of colours.
- The input is a list of colours, the output is a text.
- The input is light, the output is four sensor readings.
- The input is a single letter, the output is a single colour.
- The input is a text, the output is a list of colours.
Correct: text goes in, every letter adds a colour to the list, and colours comes out. That is the sender's box.
The parameters of a function are its input, its return value is its output, and a call inside it is a smaller box.
"You want to check a box classify() that decides on a colour from four sensor readings. Which test fits the IPO model?
- Run
classify() for an hour on live readings and see whether it holds up without crashing. - Call
classify() with random numbers and check that no error message appears. - Feed in stored readings that were certainly taken with a red lamp and check that ""red"" comes out.
- Read the source code of
classify() line by line and trace every condition in your head with example values.
" "- Feed in stored readings that were certainly taken with a red lamp and check that ""red"" comes out.
Exactly: known input, expected output, comparison. The box is checked against data whose truth you know.
A test needs inputs whose correct output you know beforehand.
"
The IPO box raises two questions: how does the box do its work, and how are input and output represented for the machine? Which of them does a program answer?
- Both: a program also defines how colours and characters are represented.
- The question of processing: a program describes how the box does its work.
- The question of representation: a program defines what data look like.
- Neither: programs are a separate, third topic.
- The question of processing: a program describes how the box does its work.
Exactly: a program is what happens inside the box. The question of representation stays open and is answered by readings, symbols and code systems.
Programs answer how a box works; representation answers what crosses its edges.
The same IPO model appears on several levels. Which statements are true? (Several answers may be correct.)
system: message → sender → light
function: text → encode() → colours
logic gate: 1, 1 → AND → 1
- Seen from outside, the whole sender is a single box: message in, light out.
- Opening the box turns its processing into a chain of smaller boxes with inputs and outputs of their own.
- A single logic gate is too small for the IPO model, because it does not process anything but merely lets current pass or blocks it.
- Which level is the right one depends on the question you are investigating.
- Seen from outside, the whole sender is a single box: message in, light out.
Correct: send() is then the name for all the processing inside. - Opening the box turns its processing into a chain of smaller boxes with inputs and outputs of their own.
Correct, and each of those smaller boxes can be checked on its own, which is what makes the levels so useful. - Which level is the right one depends on the question you are investigating.
Correct: testing the whole system needs different inputs and outputs than examining only encode().
The shape stays the same on every level, and the right level is the one at which your question can be tested.
A text transmission over a light link delivers the wrong text at the end. According to the box model, what is the most sensible next step?
- Repeat the whole transmission until the text comes out right.
- Open the big box and check an inner box, say
encode(), on its own with a known input. - Put the source code of sender and receiver side by side and look for the spot where the agreement does not match.
- Change the distance between sender and receiver and send again.
"- Open the big box and check an inner box, say
encode(), on its own with a known input.
Exactly: one level down, the small boxes have their own inputs and outputs and can be checked one by one, so that ""wrong somewhere"" becomes ""wrong here"".
Follow the data and test one boundary after the other until you find the box where they first go wrong.
"
"Why does the computer not ""see"" a colour, only numbers?
- Because the colour sensor is too cheap; a better one would deliver colours directly.
- Because a machine can only work with things that exist in a representation it can process, usually numbers.
- Because the detour via numbers is a quirk of the programming language; a language with a built-in colour type would see the colour directly.
- Because the lamp never emits pure red.
- Because it does recognise the colour but stores it as numbers inside and can therefore only pass it on that way.
" - Because a machine can only work with things that exist in a representation it can process, usually numbers.
Exactly the core point: before a computer can work with something, it has to be represented. Your eyes see red, the box sees 203, 41, 57, 310.
A computer works only with representations, and the meaning comes from the rule in the program.
An AI assistant is an IPO box as well: your words go in, code comes out, and you cannot look inside. What follows from that?
- The box is finished and no longer needs checking.
- The input hardly matters: the assistant delivers similarly good code for any question, however you phrase it.
- You know the input and check the output, since the processing is closed to you.
- The box works fastest, so as much work as possible should go there.
- You know the input and check the output, since the processing is closed to you.
Exactly: the processing is out of reach, but input and output belong to you, and the checking happens at the output.
With a test you do not have to trust a box you cannot look into.
"Which of the following calls is a test with a built-in expectation?
def to_signal(brightness):
if brightness > 100:
return ""on""
return ""off""
- Call
to_signal(150) and check that ""on"" comes out. - Call
to_signal(150) and look at the result. - Call
to_signal() with many different values to keep the function busy. - Check that the call produces no error message.
" "- Call
to_signal(150) and check that ""on"" comes out.
Exactly: known input, 150, expected output, ""on"", since 150 is greater than 100, and a comparison. A yes or no result with no interpretation.
The expectation comes before the result; without it, a call is no test.
"
"Which of these belongs to the input of the box classify(), which decides on a colour from a sensor's readings?
- The recognised colour, for example ""red"".
- The four readings of the sensor.
- The source code of
classify(). - The colour as a person sees it.
" - The four readings of the sensor.
Correct: the four numbers are all the box receives.
Input, processing and output are three different things: readings, rule and decision.