Grade by Grade
B. Software Development · Software Development: Problem Solving, Design, Testing and the Life Cycle

The Input-Process-Output Model

B1.3About 65 minutes
Learning goals
  • I can describe the input-process-output (IPO) model and give examples of each part.
  • I can read a word problem and sort its information into inputs, processing and outputs.
  • I can complete an IPO chart before I write a program, and then write the program from the chart.
  • I can chain steps so the output of one calculation becomes the input of the next.

Words to know

input
Data that comes into a program from outside: typed at the keyboard, read from a file, or measured by a sensor.
processing
The work the program does with the input: calculations, decisions, repetition, sorting or searching.
output
The results the program gives back: text on a screen, a file, a sound, a printed page.
IPO chart
A three-column planning table listing a program's inputs, processing steps and outputs.
intermediate value
A value the program calculates in the middle of its work and then uses again, such as the tax before the total.
HST
Harmonized Sales Tax. In Ontario it is 13%, so a program multiplies a pre-tax price by 0.13 to find the tax.

Every program has the same skeleton

Think about a microwave. You press buttons (2 minutes, start). It heats your leftover soup. It beeps and shows 0:00. Something goes in, something happens, something comes out.

Almost every program works the same way. This is the input-process-output model, or IPO model. When you face a new programming problem, the IPO model is the very first thing to figure out. Once you know what goes in and what must come out, the processing in the middle becomes a much smaller puzzle.

INPUTdata coming inprice = 40PROCESScalculatetax = 40 × 0.13total = 40 + taxOUTPUTresults shownTax: $5.20Total: $45.20keyboard, file, sensorarithmetic, decisions, loopsscreen, file, printer
The IPO model for a sales-tax calculator. The input (a price) is processed (tax and total are calculated) into output (two labelled amounts on the screen).

Reading a word problem the IPO way

A useful trick for any problem statement:

  • Values that are given or that the user supplies are inputs.
  • Values the problem asks for are outputs.
  • The verbs and formulas (calculate, find, compare, count, sort) describe the processing.

Some numbers are fixed by the rules of the problem rather than typed by the user, like the 13% HST rate. Those are constants. List them under processing (or as a separate note), not as inputs.

We record all of this in an IPO chart.

Worked example

Example 1: An IPO chart for an HST calculator

A store needs a program that asks for a price before tax, then shows the Ontario HST (13%) and the total. Make an IPO chart, then write the program.

  1. Input: the price before tax (a decimal number, so use float).
  2. Processing: tax = price × 0.13; total = price + tax. The tax is an intermediate value: it is an output, and it is also used to find the total.
  3. Output: the tax and the total, each labelled and shown to 2 decimal places.
  4. Write the code in the same order as the chart: input lines first, then processing, then output.

The IPO chart and the program are shown below. With an input of 40, the output is Tax: $5.20 and Total: $45.20.

InputProcessingOutput
price (before tax)tax = price × 0.13tax, to 2 decimal places
total = price + taxtotal, to 2 decimal places
IPO chart for the HST calculator.
price = float(input("Price before tax: $"))
tax = price * 0.13
total = price + tax
print(f"Tax: ${tax:.2f}")
print(f"Total: ${total:.2f}")

Sample run: the user types 40 at the prompt. The program prints Tax: $5.20 and then Total: $45.20. The blank lines separate input, processing and output, just like the chart.

Chains of IPO

Big problems are often several small IPO steps in a row. The output of one step becomes the input of the next. Drawing the chain shows you which values to calculate first.

Worked example

Example 2: A road-trip fuel calculator

A family drives 450 km to visit relatives over Thanksgiving weekend. Their car uses 7.5 L of gas per 100 km, and gas costs $1.60 per litre. Plan and write a program that finds how many litres they need and what the gas will cost. The user should be able to type all three numbers.

  1. Inputs: distance (km), fuel use (L per 100 km), price ($ per L).
  2. Processing step 1: litres = distance × fuel use ÷ 100 = 450 × 7.5 ÷ 100 = 33.75 L.
  3. Processing step 2: cost = litres × price = 33.75 × 1.60 = $54.00. Step 2 needs the output of step 1, so the order matters.
  4. Outputs: litres (2 decimal places) and cost (in dollars, 2 decimal places).

They need 33.75 L and the gas costs $54.00.

distance: 450 km7.5 L per 100 kmprice: $1.60/Llitres = 450 × 7.5 ÷ 100= 33.75 Lcost = 33.75 × 1.60= $54.00Trip cost: $54.00an output becomesthe next input
The road-trip calculation as a chain. The litres calculated in the first step feed into the cost calculation.
distance = float(input("Distance (km): "))
use = float(input("Fuel use (L/100 km): "))
price = float(input("Gas price ($/L): "))
litres = distance * use / 100
cost = litres * price
print(f"Litres needed: {litres:.2f}")
print(f"Gas cost: ${cost:.2f}")

Sample run: the user types 450, 7.5 and 1.60 at the three prompts. Output: Litres needed: 33.75 and Gas cost: $54.00.

Worked example

Example 3: IPO with a loop in the processing

Write the IPO chart for a program that asks how many quiz marks there are, reads that many marks, and shows the class average.

  1. Inputs: the count n, then n marks.
  2. Processing: set total to 0; repeat n times: read a mark and add it to the total; then average = total ÷ n. (Extreme case from the last lesson: if n is 0 we must not divide. We will handle that properly in the lesson on exceptions.)
  3. Output: the average, rounded to 1 decimal place.
  4. Notice that input and processing are mixed inside the loop. The IPO model describes what the program does, not a strict order of lines.

Input: n and the marks. Processing: running total in a loop, then divide. Output: the average.

n = int(input("How many marks? "))
total = 0
for i in range(n):
mark = float(input("Mark: "))
total = total + mark
average = total / n
print(f"Average: {average:.1f}")

Sample run: the user types 3, then the marks 72, 85 and 83. Output: Average: 80.0 (240 ÷ 3 = 80).

Just for fun

A computer will happily take garbage in and give you garbage out, and it will do it billions of times a second without complaining. Programmers even have a name for it: GIGO.

Good habits from the IPO model

  • Plan the IPO chart before you code.
  • Name variables after the chart (price, tax, total), not a, b, c.
  • Give every output a label and units (Gas cost: $54.00, not just 54.0).
  • Keep the three parts in separate groups of lines, with a blank line or a comment between them.
Hands-on activity

IPO detective at home

You need: paper and a pencil, and a computer with Python (or a free browser-based Python).

  1. Find three devices at home (for example: microwave, thermostat, washing machine, smartphone calculator). For each one, write its input, process and output in a three-column chart.
  2. Now plan a recipe scaler. A pancake recipe for 4 people uses 250 mL of milk, 2 eggs and 300 mL of flour. Your program should ask how many people you are feeding and print the amounts needed. Make the IPO chart first.
  3. Write and run the program. Test it with 4 people (the amounts should not change), 8 people (everything doubles) and 2 people (everything halves).

What to look for: input = number of people; processing = factor = people ÷ 4, then multiply each amount by the factor; output = three labelled amounts. For 6 people: 375 mL milk, 3 eggs, 450 mL flour.

Your turn

1

Give the input, processing and output of a toaster.

2

Make an IPO chart for: "Ask for the radius of a circle and display its area."

3

In the HST program, why is 0.13 not an input?

4

What does the HST program print as the total for an input of 100?

5

A program asks for the number of hours worked and the hourly wage and shows the pay. Write the processing step and find the pay for 12 hours at $17.20 per hour.

6

In the road-trip program, what is the intermediate value?

7

Write a Python program from this IPO chart. Input: a temperature in °C. Processing: F = C × 9 ÷ 5 + 32. Output: the temperature in °F with a label.

More practice: warm-up

1

What do the letters IPO stand for?

2

Name two ways data can be input to a program.

3

Is a printed receipt input, processing or output?

4

In a word problem, are the values you are asked to find usually inputs or outputs?

5

Which Python function is most often used for keyboard input?

More practice: on your own

1

Make an IPO chart for a program that converts a distance in kilometres to metres and centimetres. Then give the output for 2.5 km.

2

A program reads the length and width of a rink in metres and the cost of paint per square metre, and outputs the cost to paint the ice surface. Write the IPO chart and find the cost for a 60 m by 26 m rink at $0.75 per m².

3

Explain why the order of the two processing lines in the road-trip program matters.

4

A student wrote total = price + price * 13. Using the IPO chart, find the bug and fix it.

5

What does this program print if the user types 7?

  1. n = int(input("n: "))
  2. square = n * n
  3. print("Square:", square)
  4. print("Double the square:", 2 * square)

Challenge

1

Design (as an IPO chart) a program for a snow-removal business: a driveway costs $35 per visit, and a customer pays for the number of snowfalls in the season. Add 13% HST. Then find the bill for 14 visits.

2

A program must output the number of whole boxes needed to ship n hockey pucks if each box holds 24. Write the processing in Python without using if, and give the answers for 48, 49 and 0 pucks.

3

Draw (or describe) an IPO chain for a program that reads a temperature in °F, converts it to °C, and then outputs "Snow possible" if the temperature is at or below 0 °C and "Too warm for snow" otherwise. What does it output for 30 °F?

Check your understanding

Quiz

1.

In the IPO model, which part is "calculate the total with tax"?

2.

A program asks for the length and width of a room and shows its area. What are the inputs?

3.

Why should the 13% HST rate usually not be an input?

4.

A car uses 8 L per 100 km. How many litres for a 250 km trip?

5.

Which tool lists inputs, processing and outputs in three columns before coding?

6.

In a chain of calculations, what is an intermediate value?

For parents and teachers

Big idea: Expectation B1.3 asks students to use the input-process-output model to solve problems. It is the simplest and most useful planning tool in programming.

How to help: Point at devices and ask "What goes in? What comes out? What happens in between?" Ask your teen to show you their IPO chart before they start typing a program.

Common difficulties:

  • Listing constants (like a tax rate) or the answer itself as inputs.
  • Forgetting that input() gives text: "40" + 1 fails, so numbers need int() or float().
  • Putting processing lines in the wrong order, so a value is used before it is calculated.
  • Outputs with no labels or units. A bare 54.0 is not a useful answer.