く Interval intersection [ ] # @title Interval intersection def interval_and(self, other): """Intersection%; returns an interval, or None.""" if other.x0 > self.x1: return None x0 = max(self.x0, other.x0) x1 = min(self.x1, other.x1) return Interval(x0, x1) Interval. _and____ = interval_and # Tests 10 points. Interval(6, 10) assert Interval(3, 10) & Interval(6, 20) assert Interval(3, 4) & Interval(5, 6) is None [↑] AttributeError Traceback (most recent call last) in () 1 # Tests 10 points. 2 3 assert Interval (3, 10) & Interval(6, 20) == Interval (6, 10) 4 assert Interval (3, 4) & Interval(5, 6) is None in interval_equality(self, other) return False 7 8 9 return self.start == other.start and self.end == other.end 10 11

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter7: File Handling And Applications
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
く
Interval intersection
[ ] # @title Interval intersection
def interval_and(self, other):
"""Intersection%; returns an interval, or None."""
if other.x0 > self.x1:
return None
x0 = max(self.x0, other.x0)
x1 = min(self.x1, other.x1)
return Interval(x0, x1)
Interval. _and____ = interval_and
# Tests 10 points.
Interval(6, 10)
assert Interval(3, 10) & Interval(6, 20)
assert Interval(3, 4) & Interval(5, 6) is None
[↑]
AttributeError
Traceback (most recent call last)
<ipython-input-30-2f2a2912fd36> in <cell line: 3>()
1 # Tests 10 points.
2
3 assert Interval (3, 10) & Interval(6, 20) ==
Interval (6, 10)
4 assert Interval (3, 4) & Interval(5, 6) is None
<ipython-input-22-af6a63b86cf3> in interval_equality(self, other)
return False
7
8
9
return self.start == other.start and self.end == other.end
10
11
Transcribed Image Text:く Interval intersection [ ] # @title Interval intersection def interval_and(self, other): """Intersection%; returns an interval, or None.""" if other.x0 > self.x1: return None x0 = max(self.x0, other.x0) x1 = min(self.x1, other.x1) return Interval(x0, x1) Interval. _and____ = interval_and # Tests 10 points. Interval(6, 10) assert Interval(3, 10) & Interval(6, 20) assert Interval(3, 4) & Interval(5, 6) is None [↑] AttributeError Traceback (most recent call last) <ipython-input-30-2f2a2912fd36> in <cell line: 3>() 1 # Tests 10 points. 2 3 assert Interval (3, 10) & Interval(6, 20) == Interval (6, 10) 4 assert Interval (3, 4) & Interval(5, 6) is None <ipython-input-22-af6a63b86cf3> in interval_equality(self, other) return False 7 8 9 return self.start == other.start and self.end == other.end 10 11
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage