-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.py
More file actions
75 lines (55 loc) · 1.17 KB
/
calculator.py
File metadata and controls
75 lines (55 loc) · 1.17 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
def suma(a, b):
"""Add two numbers
Args:
a (numeric): First number
b (numeric): Second number
Returns:
numeric: Return the result of addition
>>> suma(4,5)
9
>>> suma(14,20)
34
"""
return a + b
def resta(a, b):
"""Diff two numbers
Args:
a (numeric): First number
b (numeric): Second number
Returns:
numeric: Result
>>> resta(3,44)
-41
"""
return a - b
def multiplicacion(a, b):
"""Multiply two numbers
Args:
a (numeric): First number
b (numeric): Second number
Returns:
numeric: Result
>>> multiplicacion(4,6)
24
>>> multiplicacion(4,0)
0
"""
return a * b
def division(a, b):
"""_summary_
Args:
a (numeric): First number
b (numeric): Second number
Raises:
ZeroDivisionError: _description_
Returns:
numeric: Result
>>> division(20,5)
4.0
>>> division(20,0)
Traceback (most recent call last):
ZeroDivisionError: Operación no permitida
"""
if b == 0:
raise ZeroDivisionError("Operación no permitida")
return a / b