Errors and Bugs

Do Now - What happens if we have errors in our program when we are writing code?
Do now - When you press RUN on a program, what do you think happens inside the computer?
1 / 13
volgende
Slide 1: Open vraag
ComputingLower Secondary (Key Stage 3)

In deze les zitten 13 slides, met interactieve quizzen, tekstslides en 1 video.

Onderdelen in deze les

Do Now - What happens if we have errors in our program when we are writing code?
Do now - When you press RUN on a program, what do you think happens inside the computer?

Slide 1 - Open vraag

The CPU reads each instruction in order line by line, storing and updating variables in memory and waiting for any needed input. It then sends commands to output devices like the screen, any errors/bugs stop the program running or make it behave unexpectedly.

Slide 2 - Tekstslide

Learning Objective: 
To understand how errors and bugs affect our programs and apply this through identifying, fixing and debugging errors.

Slide 3 - Tekstslide

Errors
  • Errors in programs are often referred to as bugs

  • Errors can cause a program to produce unexpected results, or crash

  • There are two types of error that need to be considered:

  • syntax error
  • logic error





Errors & Bugs

Slide 4 - Tekstslide

What is a bug?
A
An error in an algorithm
B
An error in a program
C
A way of stopping a program that is running
D
An insect in the computer

Slide 5 - Quizvraag

  • Syntax is the spelling and grammar of a programming language

  • Programming languages have rules for spelling, punctuation and grammar, just like the English language. 

  • In programming, a syntax error occurs when:

  1. There is a spelling mistake
  2. There is a grammatical mistake

  • Syntax errors will cause a program to crash or not run at all

Syntax Errors

Slide 6 - Tekstslide


A
Spelling Mistake
B
Grammar Mistake

Slide 7 - Quizvraag


A
Spelling Mistake
B
Grammar Mistake

Slide 8 - Quizvraag


A
Spelling Mistake
B
Grammar Mistake

Slide 9 - Quizvraag

Logic Errors
  • Logic errors occur when there is a fault in the logic or structure of the program.

  • Logic errors do not usually cause a program to crash. However, logic errors can cause a program to produce unexpected results.

  • More than one type of logic error can exist. Parts of the program may:

  1. Be in the wrong sequence
  2. Have the wrong Boolean expression
  3. Be missing altogether

  • Any one or more of these errors may exist in a program, and each will cause the program to behave unexpectedly.

Slide 10 - Tekstslide

Turn and talk
What is the difference between syntax errors and logic errors?

Slide 11 - Tekstslide

Slide 12 - Video

In pairs recreate this broken Christmas chatbot code, fix the errors until it runs and works!

Slide 13 - Tekstslide