> <command-867591925311336>(4)getAccuracy()
2 def getAccuracy(self, correct, total):
3 # ...
----> 4 accuracy = correct / total
5 # ...
6 return accuracy
ipdb>
0
ipdb>
10
ipdb>
> <command-867591925311336>(15)printScore()
13
14 def printScore(self):
---> 15 print(f"You're score is: {self.system.getAccuracy(self.correct, self.total)}")
16
17 test = UserTest(
ipdb>
0
ipdb>
Tests
True
> <command-867591925310549>(4)getAccuracy()
2 def getAccuracy(self, correct, total):
3 # ...
----> 4 accuracy = correct / total
5 # ...
6 return accuracy
ipdb>
*** ZeroDivisionError: division by zero
ipdb>
10
ipdb>
0
ipdb>
> <command-867591925310549>(13)<cell line: 13>()
9
10 ## test coverage
11 print("Tests")
12 print(system.getAccuracy(10, 100) == 0.1)
---> 13 print(system.getAccuracy(10, 0), 0)
ipdb>
Use with The Python Debugger (pdb)
Notebooks running on Databricks Runtime 11.2 and above support The Python Debugger (pdb).
Some examples of using pdb in a notebook:
%debug
to debug from the last exception. This is helpful when you run into an unexpected error and are trying to debug the cause (similar topdb.pm()
).%pdb on
to automatically start the interactive debugger after exceptions (but before program terminates).Note that when you use these commands, you must finish using the debugger before you can run any other cell. Here are a few ways to exit the debugger:
c
orcontinue
to finish running the cell.exit
to throw an error and stop code execution.Cancel
next to the output box.