Last active
December 18, 2016 02:06
-
-
Save serashioda/8ea5dad97c12a0ac5fc310e39ed71869 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Implementation of the add_me module.""" | |
def add_me(num_lst, sing_digit): | |
"""returns sum of list of nums as a whole num and adds single dig.""" | |
num_sum = int(''.join(map(str, num_lst))) | |
result = num_sum + sing_digit | |
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Test for add_me function.""" | |
import pytest | |
TEST_TABLE = [ | |
[([1, 2, 3, 4], 1), 1235], | |
[([1, 2, 3, 4], -1) 1233] | |
] | |
@pytest.mark.parametrize("num_lst, sing_digit, result", TEST_TABLE) | |
def test_add_me(num_lst, sing_digit, result, Test_TABLE) | |
"""Test the add_me function.""" | |
from add_me import add_me | |
assert add_me(num_lst, sing_digit) == result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write a function that takes as arguments: | |
- a list of integers that represents a whole number | |
--> ex: [1, 2, 3 ,4] = 1234 | |
--> ex: [8, 2] = 82 | |
- a single-digit integer (-9, 9) | |
Return the sum of the whole-number version of the | |
list of numbers, and that single-digit integer, as a list | |
add_me([1, 2, 3, 4], 1) --> [1, 2, 3, 5] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Halfway there! Just make sure to relax and read the problem carefully. I hold off coding for at least 5 minutes on gists and just think about the problem. See if you can go back and get the second half of this (returning the list).