Mark Lapin - Python L4 Writing Algorithms
Mark Lapin - Python L4 Writing Algorithms
Introduction to Python
Learning objectives
• Learn to write algorithms in pseudocode
• Review the difference between syntax errors, run-
time errors and logic errors
• Learn techniques for debugging programs
Introduction to Python
Writing algorithms
Writing Pseudocode
• Pseudocode is half code, half English
• It has no real syntax and would not run
• It is a structured sequence of instructions
• It is useful for planning algorithms
Pseudocode Example:
if unlock button pressed then
display PIN unlock screen
input PIN
if correct PIN entered
then
unlock phone
else display “Try again”
else display lock screen
Introduction to Python
Writing algorithms
Writing an Algorithm
• Write a pseudocode algorithm to display the correct
hat size based on the circumference of your head:
Debugging exercise
• Look at the two programs below and see if you can
find and correct the errors in them
SeasonFinderBUGS.py
TaxCalculatorBUGS.py