Question: Check if squares are overlapping. Programming language is in Python 3 7. Functions and Conditionals: Two Squares: Write a function called is_in_square() that takes in

Check if squares are overlapping. Programming language is in Python 3
7. Functions and Conditionals: Two Squares: Write a function called is_in_square() that takes in two Coordinate objects and two floats that represent two squares. Each square is represented by a Coordinate that specifies its centre as well as a float that specifies its side. If the second square is within the first square, or overlaps the first square, the function should return True, otherwise it should return false. The diagram shows all the cases where the function should return True. In the case on the right, it is True because the edges of the two squares overlap. Design your own test cases and verify the function. An example would be: >>> s1 = Coordinate() >>> 51.x, s1.y = 10, 10 >>> s2 = Coordinate() >>> 82.x, s2.y = 20, 10 >> is_in_square (s1, 5, s2, 4) False
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
