How to use the trace library in python and is it applicable to my situation

Hi, I’m hoping someone could explain how the trace library in Python works. In this class, I am taking a significant portion of it, is tracing my code output to a non-executable markdown file. To show step by step what Python compiles line by line and what the final result of code is. Below is an example of what I am talking about
for x in [0, 1, 2, 3, 4]:
value = x / 2 + 1
print( “Value: %d” % value )
In Memory -----------
line# variables
1 x: 0
2 x: 0 value: 1.0
3 x: 0 value: 1.0
1 x: 1
2 x: 1 value: 1.5
3 x: 1 value: 1.5
1 x: 2
2 x: 2 value: 2.0

1 x: 4
2 x: 4 value: 3.0

In Output -----------
Value: 1
Value: 1
Value: 2

Value: 3

Would the trace library be a simple way for me to do this?