Lesson 6 Digi Trailblazers Course 2
Lesson 6 Digi Trailblazers Course 2
Course 2
Inspiring the next generation of digital innovators
Lesson 6 – Testing and Improving
Programs 1
By the end of the lesson you will understand more
about:
03
Activity 1
Different programming software has different tools to break, watch and step code.
Break: A place in a program where execution is stopped in order for the programmer to inspect the lines of
code following on from the break.
Watch: Opening a new window to display the variable and its contents. The developer can execute each line
of code and see what happens to the content of the variable.
Step: Each line of code is executed one at a time. During the step by step execution the program stops and
waits for user inputs and behaves as if it were being executed normally.
The tools used to break, watch or step code are known as code visualiser or debugging tools.
04
Activity 1 – continued
Let’s
Check
Together Look at the code in the example below
Four variables Quantity, UnitPrice,
# testing.py
Discount and Total are created
# This program contains a 3 stage calculation to demonstrate how a program
# inspection works. and initialised in this code.
The program is
waiting for the quantity
to be input by the user
before moving on.
06
Activity 1 – continued
A few lines later, you can see values have been added to the Quantity variable and the Unit Price variable.
07
Activity 1 – continued
When the program has finished executing the programmer can check the code,
the values input, the values in the variables and the final outputs.
08
Activity 1 – continued
Use the Python inspection tool to step through at least three Python programs that you have created and
saved.
Executing line by line and watch the contents of the variables change.
Make sure you inspect all the selections, loops and calculations.
Following the example in the first line, write down the program names in the table, including the features in
each and which lines have been inspected.
Program name Features Comments
eg Temperature.py If statement, while Temperature
loop, user defined conversion from
function Celsius to Fahrenheit
09
Terminology
• Break - a break is when a line of code is selected as the hold point
during the execution of a program so that debugging can take place
11
NCC Education Head South Africa Malaysia China Singapore
Office UK 1 Bridgeway Road Unit No.C-7-4 LG2-T1, Tower C 100 Victoria Street
The Towers Bridgeways Precinct Wisma Goshen, Plaza Pantai COFCO Plaza #13-01/02
Towers Business Park Century City No.5 Persiaran Pantai Baru No. 8 Jianguomennei Avenue National Library Building
Wilmslow Road Cape Town 59200 Kuala Lumpur Dongcheng District Singapore
Didsbury 7441 Malaysia Beijing 100005 188064
Manchester M20 2EZ South Africa China
United Kingdom
+27 21 830 5242 +60 3 2284 6200 +86 10 6520 4030 +65 6580 4555
+44 (0) 161 438 6200
Monday to Friday Monday to Friday Monday to Friday Monday to Friday
Monday to Friday 08:30 – 17:00 09:00 – 17:00 09:30 – 18:30 09:30 – 17:00
08:30 – 17:00