-
Notifications
You must be signed in to change notification settings - Fork 0
/
addition.py
executable file
·38 lines (29 loc) · 1.03 KB
/
addition.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python3
# import pdb; pdb.set_trace()
def add_number(x, y):
"""This is a basic function that sums 2 digits
debugging with pdb(python debugger)
h - displays some helpful commands, some of which are
n - takes us to the next line of code
x - shows us what is in the variable x
y - likewise displays content of variable y
result - displays contents of var result
exit() - exits the debugger
The debugger can also perform expressions the same way any python terminal would
"""
print(f"This is x: {x} of type {type(x)} and this is y: {y} of type {type(y)}\n")
# breakpoint()
try:
result = x + y
except TypeError as exception:
print("The wrong type was passed")
print("Exception:", exception)
try:
result = int(x) + int(y)
except ValueError as e:
print("\nOne of the variables is not a number")
print("Exception:", e)
result = "error"
print(f"\nThis is the result:{result}")
return result
add_number("one", 2)