top of page
  • Writer's pictureMiss S

Error Checking with Pseudocode and Python

This post covers two of the common error types in Python that you may encounter during your studies. It also covers common errors made when writing Pseudocode, because its super important to avoid these common errors in Pseudocode too as quite a lot of exam questions about programming can ask you to write Pseudocode and you don’t want these errors to hold you back from the marker seeing the depth of your understanding.

Error Types

Syntax errors are when part of the program has been written wrong to the point that it won’t function. It will cause an error, crash, and not proceed in running. Here is an example in Python:

That error message can be translated to mean that because there was a quotation mark missing, the program couldn’t find where the line ended, because it didn’t find the end quotation mark.

Logic errors are when the program runs correctly, but there may be numbers wrong here and there, or the wrong use of mathematical symbols.

Here is an example in Python, where a divisionFunction has been created, but instead of dividing the number we have added it:

As you can see, the program keeps running but the answer is wrong. This is how logic errors work.

Ways to avoid a syntax error

Sticking to the rules regarding variable names. If variable names don’t stick to these rules, your program will crash.

  1. Cannot begin with numbers

  2. Cannot contain spaces

  3. No special characters (@, #, etc.)

  4. Can only be made up of letters, numbers and underscores: _

  5. They are CASE SENSITIVE

Making sure you have considered what data type you are using for Arrays, because they can only store date of one data type, and in Python programming. Here is a reminder of some common data types:

  1. Strings - a string of text: a word or a sentence, surrounded by quotation marks

  2. Integers - a whole number

  3. Boolean - true or false

  4. Float - a decimal number

Using the correct type of brackets for your task, and making sure you always have both opening and closing brackets

  1. Functions ALWAYS have brackets around their parameters and arguments.

  2. Arrays and lists ALWAYS use brackets around their contents

  3. NEVER forget closing brackets, this is the most common mistake in programming.

  4. For arrays we use square brackets: []

  5. For function parameters and arguments we use curved brackets: ()

Making sure you have used indentation correctly (the space at the start of the line(s) of code inside if statements, loops or functions. Incorrect indentation can cause the program to cease working or to produce really unexpected outcomes. Indentation is shown by using:

  1. The Tab key

  2. Four spaces

Making sure all of your strings are surrounded by quotation marks. Otherwise the computer won’t know where the line stops, like in the example seen earlier.

Paying attention to your capitalisation. Everything in most programming languages, including Python, is case sensitive. It is also a good idea to capitalise key words in pseudocode to make them clearer.

  1. All function names must begin with a lowercase character.

  2. When we write pseudocode, all of our keywords must be CAPITALISED. We don’t benefit from the colour coding that a programming environment has and we have to show what our keywords are.

  3. Python is a case sensitive language - if variable names are not recognised later in the program be sure to check their capitalisation - you may have capital letters where they don’t belong.

  4. Do not use capital letters when trying to utilise Python’s built-in functions. It will not work.

2,131 views0 comments

Recent Posts

See All


bottom of page