Q. How would you go about debugging Python code? A. Firstly, import pdb
|
1 2 |
import pdb |
Secondly, use “pdb.set_trace()” where ever you want the execution to pause as shown below with “addition.py” file.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import pdb; a = 5 pdb.set_trace() b = 10 pdb.set_trace() c = 10 result = a + b + c print(result) |
Thirdly, run your code as
|
1 2 |
$ python3 addition.py |
When your…