Write a c functiun that takes two inputs as rectangle point. The function should return the integer value I if the point is c
ontained within the rectangle (including boundary) and it should retum if the
Answers
Answered by
1
Answer:
Python code:-
# Python3 program to Check
# if a point lies on or
# inside a rectangle | Set-2
# function to find if
# given point lies inside
# a given rectangle or not.
def FindPoint(x1, y1, x2,
y2, x, y) :
if (x > x1 and x < x2 and
y > y1 and y < y2) :
return True
else :
return False
# Driver code
if __name__ == "__main__" :
# bottom-left and top-right
# corners of rectangle.
# use multiple assigment
x1 , y1 , x2 , y2 = 0, 0, 10, 8
# given point
x, y = 1, 5
# function call
if FindPoint(x1, y1, x2,
y2, x, y) :
print("Yes")
else :
print("No")
# This code is contributed
# by @rian61
Output:-Yes
Some code Tests:-
- Input: bottom-left: (0, 0), top-right: (10, 8) point: (1, 5)
- Output: Yes
- Input: bottom-left: (-1, 4), top-right:(2, 3), point:(0, 4)
- Output: No
Similar questions
English,
2 months ago
Math,
2 months ago
Political Science,
5 months ago
Chemistry,
5 months ago
Math,
11 months ago
Computer Science,
11 months ago
Geography,
11 months ago