forked from uchicago-cs/python-practice-problems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
out_of_range.py
48 lines (30 loc) · 1.3 KB
/
out_of_range.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 out_of_range(x, lb, ub):
""" Is x outside the range lb to ub (inclusive)?"""
### YOUR CODE GOES HERE
# Replace "None" with the correct expression
r = None
### DO NOT MODIFY THE FOLLOWING LINE!
return r
#############################################################
### ###
### Testing code. ###
### !!! DO NOT MODIFY ANY CODE BELOW THIS POINT !!! ###
### ###
#############################################################
import sys
sys.path.append('../')
import test_utils as utils
def do_test_out_of_range(x, lb, ub, expected):
recreate_msg = utils.gen_recreate_msg("out_of_range", *(x, lb, ub))
actual = out_of_range(x, lb, ub)
utils.check_none(actual, recreate_msg)
utils.check_type(actual, expected, recreate_msg)
utils.check_equals(actual, expected, recreate_msg)
def test_out_of_range_1():
do_test_out_of_range(x=5, lb=3, ub=10, expected=False)
def test_out_of_range_2():
do_test_out_of_range(x=15, lb=3, ub=10, expected=True)
def test_out_of_range_3():
do_test_out_of_range(x=3, lb=3, ub=10, expected=False)
def test_out_of_range_4():
do_test_out_of_range(x=10, lb=3, ub=10, expected=False)