In deze les zitten 36 slides, met interactieve quizzen, tekstslides en 1 video.
Lesduur is: 100 min
Onderdelen in deze les
Debugging and Tracing Code
Year 10
Slide 1 - Tekstslide
KO: To identify common mistakes when programming in Python
All
To identify the common 'mistakes' made when programming in Python.
Most
To identify the common 'mistakes' when programming in Python and fix them.
Some
To be-able to use a trace table, when debugging code in Python.
Slide 2 - Tekstslide
What is Debugging? What is it's purpose?
Slide 3 - Open vraag
What do you think the most common mistakes in programming are?
Slide 4 - Open vraag
Syntax Errors
These are errors that occur when you violate the rules of the Python language. For example, forgetting to include a colon at the end of an if statement, or not properly indenting the code within a loop or function. The compiler will not run with a Syntax error.
These occur when your code does not produce the expected output due to incorrect algorithms or decision-making. A program with a logical error can still compile and run without any syntax errors, but the program will not produce the intended output or behaviour.
x = (2 + 3) * 4 # addition needs to be performed first
print(x)
Slide 22 - Tekstslide
Second Task - Corrected Code
age = int(input("How old are you?"))
if age >= 18:
print("You are an adult")
else:
print("You are not an adult")
Slide 23 - Tekstslide
Third Task - Corrected Code
x = 10
while x > 0:
print(x)
x = x + 1
Slide 24 - Tekstslide
Casting (Data Type Conversion)
Casting in programming refers to the process of converting one data type to another. It is also known as type conversion.
Slide 25 - Tekstslide
Logical
Syntax
Infinite loops
Uninitialised variables
Misspelled keywords
Missing or extra punctuation
Incorrect data types
Incorrect function or method calls
Division by zero
Slide 26 - Sleepvraag
What do you think a 'Trace Table is'?
Slide 27 - Open vraag
What is a Trace Table?
A trace table is a tool used in computer programming to trace and visualise the execution of a program. It is a table that shows the values of variables at different stages of the program's execution.
The trace table is used to keep track of the program's control flow and the values of the variables as the program executes line by line.
Slide 28 - Tekstslide
What does a Trace Table look like?
In a trace table, the columns represent the variables used in the program, and the rows represent the stages of the program's execution. Each cell in the table represents the value of a variable at a particular stage of the program's execution.