More on floating point problems [here](https://floating-point-gui.de/) of as [pdf](https://www.phys.uconn.edu/~rozman/Courses/P2200_15F/downloads/floating-point-guide-2015-10-15.pdf)
# How to improve programs step-ny-step: debuggability
If `print()` is so useful, why not integrating it into the program?
logging.info("Got a = {0} of type {1}".format(a,type(a)))
logging.info("Got b = {0} of type {1}".format(b,type(b)))
returna+b
if__name__=="__main__":
a,b=sys.argv[1],sys.argv[2]
print("{1}+{2}= {0}".format(sum(a,b)),a,b)
```
### basic log levels
- DEBUG: Detailed information, for diagnosing problems
- INFO: Confirm things are working as expected
- WARNING: Something unexpected happened, or indicative of some problem. But the software is still working as expected
- ERROR: More serious problem, the software is not able to perform some function
- CRITICAL: A serious error, the program itself may be unable to continue running
## Exceptions: try/except
Python has means to deal with non-intended behaviour called Exceptions. Using them will make your scripts easier to understand by others (and by yourself next week).
```python
try:
filehandle=open(filename)
exceptIOError:
print('File cannot be opened:',filename)
exit()
```
- Think about what could possibly go wrong
- Think about which requirements must be met for your code work
# python's own debugger: pdb/pudb
[list of python debugging tools](https://wiki.python.org/moin/PythonDebuggingTools)
# How to improve programs step-ny-step: debuggability