Writing pseudocode from an IPO chart

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

Writing pseudocode from an IPO chart

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. An IPO chart lists the input 'hourly rate'. Which pseudocode line turns it into code?
A PRINT rate
B INPUT rate
2. The IPO process column says 'total is price multiplied by quantity'. Which line does this?
A total ← price * quantity
B INPUT total
3. The IPO output column says 'display the total'. Which line matches?
A total ← INPUT
B PRINT total
4. In which order should the pseudocode follow the IPO chart?
A INPUT, then process, then PRINT
B PRINT, then process, then INPUT
5. The process column says 'if mark is 50 or more the result is Pass, otherwise Fail'. Which pseudocode fits?
A IF mark >= 50 THEN result ← "Pass" ELSE result ← "Fail" END IF
B INPUT mark >= 50

Match the Pairs

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

Left columnRight column
1INPUT mark ATurns an IPO input (a mark entered by the user) into an input statement that stores it in a variable
2PRINT result BTurns an IPO output (the result shown to the user) into a print statement
3A process that calculates a value becomes an assignment using the arrow CThe assignment is written backwards. The variable being assigned must be on the left of the arrow.
4A process that makes a decision becomes an IF selection DIF mark >= 50 THEN result ← "Pass" ELSE result ← "Fail" END IF
5PRINT total total ← price * quantity INPUT price, quantity Etotal ← price * quantity
6INPUT price price * 2 ← total PRINT total FThe statements are in the wrong order. The output is printed before the inputs are read and the process is done.

Definitions

IPO to pseudocode

Fill in the Blanks

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

1.
_____ price
2.
INPUT price INPUT qty total _ price * qty
3.
IF mark >= 50 ____ PRINT "Pass" ENDIF
4.
INPUT total _____ total
5.
INPUT radius area ← 3.14 * radius * radius PRINT ____

Spot the Error

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

Question 1
A INPUT price
B INPUT quantity
C price * quantity ← total
D PRINT total
Question 2
A INPUT mark
B IF mark >= 50
C PRINT "Pass"
D ELSE
E PRINT "Fail"
F END IF
Question 3
A INPUT length
B INPUT width
C area ← length * width
D INPUT area
Question 4
A INPUT c
B f ← c * 9 / 5 + 32
C PRINT "f"
Question 5
A PRINT hours
B pay ← hours * 30
C PRINT pay

Answer Key

Writing pseudocode from an IPO chart
Section A: Quick Questions
Q1
B — INPUT rate
Q2
A — total ← price * quantity
Q3
B — PRINT total
Q4
A — INPUT, then process, then PRINT
Q5
A — IF mark >= 50 THEN result ← "Pass" ELSE result ← "Fail" END IF
Section B: Match the Pairs
Q1
INPUT mark → Turns an IPO input (a mark entered by the user) into an input statement that stores it in a variable
Q2
PRINT result → Turns an IPO output (the result shown to the user) into a print statement
Q3
A process that calculates a value becomes an assignment using the arrow → total ← price * quantity
Q4
A process that makes a decision becomes an IF selection → IF mark >= 50 THEN result ← "Pass" ELSE result ← "Fail" END IF
Q5
PRINT total total ← price * quantity INPUT price, quantity → The statements are in the wrong order. The output is printed before the inputs are read and the process is done.
Q6
INPUT price price * 2 ← total PRINT total → The assignment is written backwards. The variable being assigned must be on the left of the arrow.
Section C: Definitions
Q1
IPO to pseudocode — Turn each IPO input into an INPUT statement, each process into assignments or IF selection, and each output into a PRINT statement, in that order.
Section D: Fill in the Blanks
Q1
INPUT price
Q2
INPUT price INPUT qty total ← price * qty
Q3
IF mark >= 50 THEN PRINT "Pass" ENDIF
Q4
INPUT total PRINT total
Q5
INPUT radius area ← 3.14 * radius * radius PRINT area
Section E: Spot the Error
Q1
C — The process is an assignment, so the variable being set goes on the left of the arrow. It should be total ← price * quantity.
Q2
B — An IF selection needs the keyword THEN after the condition. It should be IF mark >= 50 THEN.
Q3
D — The IPO chart lists area as an output, so it needs a PRINT statement. INPUT is only for values the user supplies. It should be PRINT area.
Q4
C — Quotes make PRINT show the letter f as text. To output the calculated value, print the variable without quotes: PRINT f.
Q5
A — hours is an input in the IPO chart, so it must be read with INPUT. PRINT would just display a value that has not been entered yet. It should be INPUT hours.