forked from uchicago-cs/python-practice-problems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
number_string.py
48 lines (33 loc) · 1.38 KB
/
number_string.py
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
def number_string(x):
"""
Given a number x, produce a string: "POSITIVE", "NEGATIVE", "ZERO"
(depending on whether the number is positive, negative, or zero)
"""
### YOUR CODE GOES HERE
# Replace the following line with your code.
# After running your code, variable s should contain the value
# we ask you to compute in this exercise.
s = None
### DO NOT MODIFY THE FOLLOWING LINE!
return s
#############################################################
### ###
### Testing code. ###
### !!! DO NOT MODIFY ANY CODE BELOW THIS POINT !!! ###
### ###
#############################################################
import sys
sys.path.append('../')
import test_utils as utils
def do_test_number_string(x, expected):
recreate_msg = utils.gen_recreate_msg("number_string", *(x,))
actual = number_string(x)
utils.check_none(actual, recreate_msg)
utils.check_type(actual, expected, recreate_msg)
utils.check_equals(actual, expected, recreate_msg)
def test_number_string_1():
do_test_number_string(x=10, expected="POSITIVE")
def test_number_string_2():
do_test_number_string(x=-7, expected="NEGATIVE")
def test_number_string_3():
do_test_number_string(x=0, expected="ZERO")