Interval¶
Write a function interval(li, ls, n, closed)
that takes 4 values: the upper and lower limits of an interval and
a number (3 real numbers) and a boolean containing
True if the interval is closed and
False if it is open,
and returns True if that number is inside the interval
and False otherwise.
Save the function in the file interval.py. This function must pass the doctest:
>>> interval(1.0, 10.0, 4.1, True) True >>> interval(1.0, 10.0, 10.0, True) True >>> interval(1.2, 10.4, -2.1, True) False >>> interval(1.0, 10.0, 10.0, False) False >>> interval(1.2, 10.4, 1.2, False) False >>> interval(-11.3, 10.8, 10.8, False) False >>> interval(-11.3, 10.8, -3.4, False) TrueNote
You can download the file with tests
interval.txt
Solution
You have solutions in the file interval.py