Question: Using Python object oriented programming, write a class called Interval that represents a one-dimensional open interval on the real line. This main purpose of this
Using Python object oriented programming, write a class called Interval that represents a one-dimensional open interval on the real line. This main purpose of this class is to simplify overlapping continuous intervals.


This is all of the given information.
Using Python object oriented programming, write a class called Interval that represents a one-dimensional open interval on the real line. This main purpose of this class is to simplify overlapping continuous intervals. The code below should get you started but there are a lot of missing pieces that you will have to figure out. The API should take a pair of integers as input and respond to theoperator such that >>> a = Interval(1,3) >>>bInterval (2,4) >Interval(5,1e) >>>ab Interval(1,4) >> b+c Interval(2,4), Interval(5, 10)] Note that in the case of non-overlapping intervals, the output should be a list of constituent Intervals. Keep in mind that these are open intervals. Specifically >Interval(2,3)+Interval(1,2) [Interval (2,3), Interval(1,2)] Note that these do not produce a single interval because each interval is open (not closed). The interval endpoints can be negative also (e.g. Interval(-10,-3) is valid). The output does not have to be sorted. This is where good object-oriented design pays off. Using Python object oriented programming, write a class called Interval that represents a one-dimensional open interval on the real line. This main purpose of this class is to simplify overlapping continuous intervals. The code below should get you started but there are a lot of missing pieces that you will have to figure out. The API should take a pair of integers as input and respond to theoperator such that >>> a = Interval(1,3) >>>bInterval (2,4) >Interval(5,1e) >>>ab Interval(1,4) >> b+c Interval(2,4), Interval(5, 10)] Note that in the case of non-overlapping intervals, the output should be a list of constituent Intervals. Keep in mind that these are open intervals. Specifically >Interval(2,3)+Interval(1,2) [Interval (2,3), Interval(1,2)] Note that these do not produce a single interval because each interval is open (not closed). The interval endpoints can be negative also (e.g. Interval(-10,-3) is valid). The output does not have to be sorted. This is where good object-oriented design pays off
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
