Topic 11 Β· Programming Scenarios Β· 11.4

Practically Carrying Out the Program

Learn how to act out a programming task, identify the stages and turn those actions into an algorithm.

Invitation

What if the process is difficult to see?

Sometimes a scenario makes sense, but the algorithm still feels hidden.

In this method, you carry out the task yourself using example values. Each action you perform becomes a stage in the algorithm.

When the code is unclear, act out the problem and record what you do.
Reveal the hidden steps
Use example data
↓
Perform the task
↓
Record each action
Big Idea

Your actions become the algorithm

Read the requirement
β†’
Choose example values
β†’
Carry out the task
β†’
Write the steps
Practical action turns an abstract problem into a visible sequence.
Computational Thinking

The four thinking skills are still working

DecompositionCarry out one requirement at a time.
Pattern RecognitionNotice familiar actions such as input, selection, counting or repetition.
AbstractionUse simple example values and focus on the rule, not the story.
Algorithm DesignTurn the actions into ordered programming statements.
Worked Example

Act out the calculator

The calculator must take two numbers and an operator, then output the result.

RequirementRun-through 1Run-through 2Step Revealed
Take the first integer.Enter 10Enter 2INPUT Number1
Take the operator.Enter +Enter ^INPUT Operator
Take the second integer.Enter 20Enter 3INPUT Number2
Output the result.Output 30Output 8Check the operator, perform the calculation and output the result.
The run-through reveals both the order and the decision needed by the algorithm.
From Action to Code

Translate each action

I ask for a numberINPUT Number1
I ask for an operatorINPUT Operator
I ask for another numberINPUT Number2
I check the operatorUse IF and ELSEIF selection.
I show the resultOUTPUT the calculated value with a message.
Algorithm revealed by the run-throughPseudocode
INPUT Number1
INPUT Operator
INPUT Number2

IF Operator = "+"
THEN
    Result ← Number1 + Number2
ELSEIF Operator = "-"
THEN
    Result ← Number1 - Number2
ELSEIF Operator = "*"
THEN
    Result ← Number1 * Number2
ELSEIF Operator = "/"
THEN
    Result ← Number1 / Number2
ELSE
    Result ← Number1 ^ Number2
ENDIF

OUTPUT "The result is: ", Result
Adding the Extras

Improve the first working solution

PromptsTell the user what to enter.
ValidationReject unsuitable values.
MessagesExplain each output.
CommentsExplain sections of code.
ChecksConfirm every requirement.
First reveal the algorithm. Then improve its usability, reliability and readability.
Two Valid Methods

Choose the method that helps you think

Method 1: IPO

Identify the inputs, processes and outputs before writing the code.

Best when: the requirements separate clearly into data, actions and results.

Method 2: Act It Out

Carry out the task with example values and turn your actions into code.

Best when: the process or order is difficult to identify.

There is no single correct planning method. Use the one that makes the problem easier to understand.
Hinge Question

Why use more than one run-through?

Question

Why is it useful to carry out the calculator task with two different operators rather than only one?

β€œDifferent examples reveal that the program must make a decision and choose a different calculation depending on the operator.”
Exam Explainer

Use practical thinking when you get stuck

Step 1Choose simple example data.
Step 2Carry out every requirement.
Step 3Translate each action into code.
Exam tip: If you cannot identify a process, ask yourself: β€œWhat would I physically do to produce the required result?”
Common Mistake

Do not write down only the answers

βœ— Incomplete run-through

10 + 20 = 30

This records the answer but hides the stages.

βœ“ Useful run-through

Input 10 β†’ input + β†’ input 20 β†’ check operator β†’ add values β†’ output 30.

This reveals the algorithm.

Remember: Record the actions, decisions and orderβ€”not just the final result.
Summary

Act, identify and translate

ActCarry out the task.
IdentifyEach stage and decision.
TranslateThe actions into code.
Final rule: When an algorithm feels hidden, acting out the task can make every stage visible.