#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?

  1. Planning, implementation, documentation
  2. Hardware, software, data
  3. Input, processing, output
  4. Sender, channel, receiver

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?

  1. Because the computer reports at every call whether the output it delivered matches the input.
  2. Because you can feed in a known input and compare the result with the expected output.
  3. Because in a cleanly cut box you can see at once, just by reading the code, which line produces which part of the output.
  4. Because the processing inside the box is then so manageable that it can hardly be wrong any more.

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?

  1. The colour red, just as a person standing next to the sensor sees it.
  2. The word ""red"", which the sensor reports to the program as the colour it recognised.
  3. Four numbers: the shares of red, green and blue and the overall brightness.
  4. A small image of the lamp, from which the program reads off the colour at the brightest spot.
"

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""
  1. The output of encode() is the input of the next box.
  2. Sender and receiver must agree beforehand which colour stands for which letter.
  3. decode() can work independently of what encode() does.
  4. The chain shows the order in which the data flow through the system.
  5. The boxes can be put in any order, as long as every one of them is there.
" "

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
  1. The input is a text, the output is a list of colours.
  2. The input is a list of colours, the output is a text.
  3. The input is light, the output is four sensor readings.
  4. The input is a single letter, the output is a single colour.

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?

  1. Run classify() for an hour on live readings and see whether it holds up without crashing.
  2. Call classify() with random numbers and check that no error message appears.
  3. Feed in stored readings that were certainly taken with a red lamp and check that ""red"" comes out.
  4. Read the source code of classify() line by line and trace every condition in your head with example values.
" "

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?

  1. Both: a program also defines how colours and characters are represented.
  2. The question of processing: a program describes how the box does its work.
  3. The question of representation: a program defines what data look like.
  4. Neither: programs are a separate, third topic.

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
  1. Seen from outside, the whole sender is a single box: message in, light out.
  2. Opening the box turns its processing into a chain of smaller boxes with inputs and outputs of their own.
  3. 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.
  4. Which level is the right one depends on the question you are investigating.

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?

  1. Repeat the whole transmission until the text comes out right.
  2. Open the big box and check an inner box, say encode(), on its own with a known input.
  3. Put the source code of sender and receiver side by side and look for the spot where the agreement does not match.
  4. Change the distance between sender and receiver and send again.
"

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?

  1. Because the colour sensor is too cheap; a better one would deliver colours directly.
  2. Because a machine can only work with things that exist in a representation it can process, usually numbers.
  3. 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.
  4. Because the lamp never emits pure red.
  5. Because it does recognise the colour but stores it as numbers inside and can therefore only pass it on that way.
"

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?

  1. The box is finished and no longer needs checking.
  2. The input hardly matters: the assistant delivers similarly good code for any question, however you phrase it.
  3. You know the input and check the output, since the processing is closed to you.
  4. The box works fastest, so as much work as possible should go there.

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""
  1. Call to_signal(150) and check that ""on"" comes out.
  2. Call to_signal(150) and look at the result.
  3. Call to_signal() with many different values to keep the function busy.
  4. Check that the call produces no error message.
" "

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?

  1. The recognised colour, for example ""red"".
  2. The four readings of the sensor.
  3. The source code of classify().
  4. The colour as a person sees it.
"

Input, processing and output are three different things: readings, rule and decision.