Question: I need the code for interval_and(self, other), interval_contains(self, x), and interval_sub(self, other) with the correct parameters used. It must pass the tests assigned for each




I need the code for interval_and(self, other), interval_contains(self, x), and interval_sub(self, other) with the correct parameters used. It must pass the tests assigned for each code.
def interval_and(self, other):
"""Intersection; returns an interval, or None."""
### YOUR CODE HERE
Interval.__and__ = interval_and
def interval_contains(self, x):
### YOUR CODE HERE
Interval.__contains__ = interval_contains
def interval_sub(self, other):
"""Subtracts from this interval the interval other, returning a possibly
empty list of intervals."""
### YOUR CODE HERE
Interval.__sub__ = interval_sub
1 class Interval(object): 4 5 _init__(self, x0, x1): # Sorts the endpoints, to ensure that xo
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
