-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathsolution.py
More file actions
39 lines (32 loc) · 801 Bytes
/
solution.py
File metadata and controls
39 lines (32 loc) · 801 Bytes
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
SUBMIT = True
def sum_two_numbers(_a: int, _b: int) -> int:
# noqa: ARG001
"""Returns the sum of two integers.
Example usage:
>>> sum_two_numbers(3, 4)
7
>>> sum_two_numbers(-1, 1)
0
>>> sum_two_numbers(0, 0)
0
"""
return _a+_b
def test() -> None:
"""Simple self-test for Sum Two Numbers."""
cases = [
((3, 4), 7),
((-1, 1), 0),
((0, 0), 0),
]
for (a, b), expected in cases:
try:
res = sum_two_numbers(a, b)
assert res == expected, (
f"Failed for {a} + {b}: expected {expected}, got {res}"
)
except AssertionError as e:
print(f"❌ {e}")
return
print("✅ All tests passed!")
if __name__ == "__main__":
test()