Create a function that takes two numbers as arguments and return their sum.
def sum_two_numbers(a, b):
return a + b
Input: `add_numbers(5, 7)`
Output: `12`
Explanation: The sum of 5 and 7 is 12.
Input: `add_numbers(-3, -4)`
Output: `-7`
Explanation: The sum of -3 and -4 is -7.
Input: `add_numbers(10, -3)`
Output: `7`
Explanation: The sum of 10 and -3 is 7.
- None
NOTE: Make sure you're in the 004-python-sum-of-two-numbers
directory (containing the test.py
file) when executing the command above.
- To navigate to the directory containing the test file from the current terminal, run the following command:
cd scr/
- Then run the following command in a terminal to test your code:
python -m unittest -v test
- And make sure you get the following output:
test_add_mixed_numbers (test.TestAddNumbers.test_add_mixed_numbers) ... ok
test_add_negative_numbers (test.TestAddNumbers.test_add_negative_numbers) ... ok
test_add_positive_numbers (test.TestAddNumbers.test_add_positive_numbers) ... ok
----------------------------------------------------------------------
Ran 3 tests in 0.001s
OK