Skip to content

Commit 4860d13

Browse files
bites 254
1 parent d059b2d commit 4860d13

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@
3636
/252/README.md
3737
/231/README.md
3838
/225/README.md
39+
/254/README.md

254/scoping.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
num_hundreds = -1
2+
3+
4+
def sum_numbers(numbers: list) -> int:
5+
"""Sums passed in numbers returning the total, also
6+
update the global variable num_hundreds with the amount
7+
of times 100 fits in total"""
8+
global num_hundreds
9+
sum_of_numbers = sum(numbers)
10+
num_hundreds += sum_of_numbers // 100
11+
return sum_of_numbers
12+
13+
14+
# sum_of_numbers, num_hundreds = sum_numbers()
15+
16+

254/test_scoping.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pytest
2+
3+
from scoping import sum_numbers
4+
5+
6+
@pytest.mark.parametrize("arg, ret, hundreds_value", [
7+
([], 0, -1),
8+
([1, 2, 3], 6, -1),
9+
([40, 50, 60], 150, 0),
10+
([140, 50, 60], 250, 2),
11+
([140, 150, 160], 450, 6),
12+
([1140, 150, 160], 1450, 20),
13+
])
14+
def test_sum_numbers(arg, ret, hundreds_value):
15+
assert sum_numbers(arg) == ret
16+
from scoping import num_hundreds
17+
assert num_hundreds == hundreds_value

0 commit comments

Comments
 (0)