0% found this document useful (0 votes)
13 views5 pages

L06. Introduction To Tracing and Debugging

The document introduces the concepts of tracing and debugging in Python, emphasizing the importance of understanding code behavior by reading it line-by-line. It explains that tracing helps identify and fix errors (bugs) in code, which is crucial even for professional programmers. The document also includes examples of tracing and mentions a tracing worksheet for practice.

Uploaded by

derekhaozhe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

L06. Introduction To Tracing and Debugging

The document introduces the concepts of tracing and debugging in Python, emphasizing the importance of understanding code behavior by reading it line-by-line. It explains that tracing helps identify and fix errors (bugs) in code, which is crucial even for professional programmers. The document also includes examples of tracing and mentions a tracing worksheet for practice.

Uploaded by

derekhaozhe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Introduction to Tracing and

Debugging
Python 1
What is Tracing?
● The process where you go read code line-by-line and determine its
behaviour
● We have done this in the past in some in-class exercises such as: "What
does this code output?"
● However, sometimes the code will become more and more complex, but
you will still have to understand how it works
● Tracing would also include keeping proper records of variables and their
values as well as how they change.
Why do we learn tracing?
● When you have the tracing skills, you
would be able to easily identify the
source of many errors (known as bugs)
in your code and fix them.
○ Identifying bugs and fixing them is
known as debugging.
● Even at the professional level,
programmers make mistakes in their
code! What also matters is how they can
determine the mistake and fix it.
Tracing Examples
m = 30
n = 10
x = m // n + 3
m //= 2 Visualizer
n += 2
print(x, m, n)
x += m // 4
n = x + m
print(x, m, n)
Tracing Handout
Get a tracing worksheet

You might also like