# Main method if __name__ == '__main__': try: line1 = [] # Empty line 1 line2 = [] # Empty line 2 for i in range(2): co_ordinate1 = float( input('{0}. Enter coordinate for Line 1: '.format(i + 1))) line1.append(co_ordinate1) for i in range(2): co_ordinate2 = float( input('{0}. Enter coordinate for Line 2: '.format(i + 1))) line2.append(co_ordinate2) # Lines --> Tuple line1 = tuple(line1) line2 = tuple(line2) # Calling function Overlap result = overlap(line1, line2) print(result) # Exception handling for entering invalid inputs except ValueError: print('\n') print('_' * 42) print('Characters, strings are not allowed\n' "Please Enter two coordinates on each Line\n{0}".format('_' * 42))
def test_Integers_OverLaps(self): result = overlap((-1, -3), (1, 3)) self.assertEqual(result, "\n(-1, -3) & (1, 3) doesn\'t overlaps on x-axis")
def test_PositiveInt_OverLap(self): result = overlap((1, 5), (3, 6)) self.assertEqual(result, '\n(1, 5) & (3, 6) overlaps on x-axis')
def test_Origin_OverLap(self): result = overlap((0, 0), (0, 0)) self.assertEqual(result, '\n(0, 0) & (0, 0) overlaps on x-axis')
def test_Integers_OverLap(self): result = overlap((-1, 2), (0, -2)) self.assertEqual(result, '\n(-1, 2) & (0, -2) overlaps on x-axis')
def test_NegativeInt_NotOverLap(self): result = overlap((-1, -5), (-6, -11)) self.assertEqual(result, "\n(-1, -5) & (-6, -11) doesn\'t overlaps on x-axis")
def test_NegativeInt_OverLap(self): result = overlap((-1, -5), (-3, -6)) self.assertEqual(result, '\n(-1, -5) & (-3, -6) overlaps on x-axis')
def test_PositiveInt_NotOverLap(self): result = overlap((1, 5), (6, 11)) self.assertEqual(result, "\n(1, 5) & (6, 11) doesn\'t overlaps on x-axis")