whatsapp

Connect on Whatsapp : +1 206 673 2541, Get Homework Help 24x7, 100% Confidential. Connect Now

Question #3: is a data point within a rectangle? (4 points) write a

  Question #3: Is a data point  within a rectangle? (4 points) Write a function isIn() which returns  True ifa point is within a rectangle specined by two sets of coordinates  and False if the point is outside the rectangle. The function should  accept three parameters: the first parameter is a set of coordinates  which defines one of the corners of the rectangle, the second parameter  is also a set of coordinates that defines the second comer, the third  set of coordinates defines a single point which is being tested. For  example .isIn((1,2), (3,4), (1.5, 3.2)) should return True  .isIn((4,3.5), (2,1), (3, 2)) should return True .isIn((-1,0), (5,5),  (6,e)) should return False isin((4,1), (2,4), (2.5,4.5)) should return  False Test your function with at least 2 different sets of data points  in addition to the examples above. 1. If the point being tested is on  the side of the rectangle, consider it to be within the rectangle. For  example, if the rectangle is defined as (1,2), (3,4) and the point is  (2,2), the function should retum True 2. In this assignment, we assume  that the edges of the rectangle are parallel to coordinate axes. 3. We  also assume that the first parameter does not always represent the left  comer of the rectangle and the second parameter is not always the right  comer. The function should work correctly either way. Please note the  second test condition above where the first parameter, (4,3.5) ,  represents the top-right comer and the second parameter, (2,1)  represents left -bottom corner In [: def isIn(firstCorner-(e,0),  secondCorner-(0,8), point-(,0)): # YOUR CODE HERE In []: In []: Question  #4: Are all points within a rectangle? (4 points) Modity your function  from the previous question so it takes a list of points rather than a  single point and returns True only ir all points in the list are in the  rectangle For example . allIn( (,), (5,5), [(1,1), (,e), (5,5)]) should  return True but allIn( (e,e), (5,5), [(1,1), (e,e), (5,6)]) should  return False Use the same assumption as above about the placement of the  points and how rectangle is defined Test your function with at least 3  difterent sets of data points In []: def allIn(firstCorner-(8,e),  secondcorner-(e,), pointList-[]): # YOUR CODE HERE In []: In []: In []:  In :   

 Question #3: Is a data point within a rectangle? (4 points) Write a function isIn() which returns True ifa point is within a rectangle specined by two sets of coordinates and False if the point is outside the rectangle. The function should accept three parameters: the first parameter is a set of coordinates which defines one of the corners of the rectangle, the second parameter is also a set of coordinates that defines the second comer, the third set of coordinates defines a single point which is being tested. For example .isIn((1,2), (3,4), (1.5, 3.2)) should return True .isIn((4,3.5), (2,1), (3, 2)) should return True .isIn((-1,0), (5,5), (6,e)) should return False isin((4,1), (2,4), (2.5,4.5)) should return False Test your function with at least 2 different sets of data points in addition to the examples above. 1. If the point being tested is on the side of the rectangle, consider it to be within the rectangle. For example, if the rectangle is defined as (1,2), (3,4) and the point is (2,2), the function should retum True 2. In this assignment, we assume that the edges of the rectangle are parallel to coordinate axes. 3. We also assume that the first parameter does not always represent the left comer of the rectangle and the second parameter is not always the right comer. The function should work correctly either way. Please note the second test condition above where the first parameter, (4,3.5) , represents the top-right comer and the second parameter, (2,1) represents left -bottom corner In [: def isIn(firstCorner-(e,0), secondCorner-(0,8), point-(,0)): # YOUR CODE HERE In []: In []: Question #4: Are all points within a rectangle? (4 points) Modity your function from the previous question so it takes a list of points rather than a single point and returns True only ir all points in the list are in the rectangle For example . allIn( (,), (5,5), [(1,1), (,e), (5,5)]) should return True but allIn( (e,e), (5,5), [(1,1), (e,e), (5,6)]) should return False Use the same assumption as above about the placement of the points and how rectangle is defined Test your function with at least 3 difterent sets of data points In []: def allIn(firstCorner-(8,e), secondcorner-(e,), pointList-[]): # YOUR CODE HERE In []: In []: In []: In : 

Get FREE Essay Price Quote
Pages (550 words)
Approximate price: -