Syntax Errors

Computer Science: KS3, topic 2.1.19

Syntax Errors

Syntax errors are some of the easier bugs to fix in a broken program.

Syntax errors

Syntax errors

  • A syntax error is a mistake in the way the code is written.
  • It is similar to a spelling or grammar mistake in English.
  • Syntax errors prevent programs from running as a translator needs code to be syntactically correct.
Example of an error

Example of an error

  • prnt("Hello, world!");
  • Incorrect subroutine identifier.
  • newbalance = newBalance * 1.05;
  • Wrong capitalisation in variable identifier.
  • myBoolean = True NOT False;
  • NOT does not take two operands.

Test yourself on Syntax Errors

  • Why do syntax errors prevent programs from running?

  • Which of the following are syntax errors?

  • Would the following code cause a syntax error?

    print("Hello, world!")

Practise this topic for free