Hi, I'm a Python novice. I have the following code, but after running it doesn't return any result, not even error code, what is the problem?
Write a function isIn() which returns boolean True if a point is within a rectangle specified by two sets of coordinates and boolean 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 corner,
the third set of coordinates defines a single point which is being tested.
def isIn(firstCorner=(1,2), secondCorner=(3,4), point=(1.5, 3.2)): x1 , y1 = firstCorner x2 , y2 = secondCorner test1 , test2 = point if (test1 >= x1 and test1 <= x2 and test2 >= y1 and test2 <= y2): print('True') elif (test1 >= x1 and test1 <= x2 and test2 <= y1 and test2 >= y2): print('True') elif (test1 <= x1 and test1 >= x2 and test2 >= y1 and test2 <= y2): print('True') elif (test1 <= x1 and test1 >= x2 and test2 <= y1 and test2 >= y2): print('True') else: print('False')P.s. the code is for solving the following problem:
Write a function isIn() which returns boolean True if a point is within a rectangle specified by two sets of coordinates and boolean 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 corner,
the third set of coordinates defines a single point which is being tested.
Gribouillis write Jun-02-2022, 03:37 PM:
Please post all code, output and errors (in it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (in it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.