Python Forum
Are all points within a rectangle?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Are all points within a rectangle?
#1
Modify your function from the previous question so it takes a list of points rather than a single point and returns boolean True 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 return True
but allIn((0,0), (5,5), [(1,1), (0,0), (5,6)]) should return False
empty list of points allIn((0,0), (5,5), []) should return False
Use the same assumptions as above about the placement of the points and how rectangle is defined. Make sure that your function returns False for empty list of points (no values).
Test your function with at least 3 different sets of data points.
In [ ]:
def allIn(firstCorner=(0,0), secondCorner=(0,0), pointList=[]):
# YOUR CODE HERE
Reply
#2
What have you tried? We're not big on writing code for people here, but we would be happy to help you fix your code when you run into problems. When you do run into problems, please post your code in Python tags, and clearly explain the problem you are having, including the full text of any errors.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Plotting a specific bar / rectangle chart? glantz 2 2,127 Apr-30-2020, 11:33 AM
Last Post: glantz
  [matplotlib]Multiple persistent modifiable rectangle selector synaps 0 2,819 May-26-2019, 11:08 AM
Last Post: synaps

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020