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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!