Question: Question Are all points within a rectangle Write functionAllIn()in Python which returns booleanTrue only if all points in the list are in the rectangle. For

Question

Are all points within a rectangle

Write functionAllIn()in Python which returnsbooleanTrue only if all points in the list are in the rectangle.

For example,

  • allIn((0,0), (5,5), [(1,1), (0,0), (5,5)])should returnTrue
  • butallIn((5,5), (0,0), [(1,1), (0,0), (5,6)])should returnFalse
  • empty list of pointsallIn((0,0), (5,5), [])should returnFalse

1.In this assignment, we assume that the edges of the rectangle are parallel to coordinate axes.

  1. We also assume that the first parameter does not always represent the left corner of the rectangle and the second parameter is not always the right corner. The function should work correctly either way. Please note the second test condition above where the first parameter,(5,5), represents the top-right corner and the second parameter,(0,0), represents left-bottom corner.

Make sure that your function returnsFalsefor empty list of points (no values).

Test your function with at least 3 different sets of data points.

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 Programming Questions!