Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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) FalseStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started