Feb-17-2020, 06:35 AM
You don't even need the
So, one can just write
if
and else
. Think about it:x3 >= x1 and x3 <= x2 and y3 >= y1 and y3 <= y2is an expression that evaluates to
True
or False
. Based on which, you're setting the value of point_is_in_rectangle
- if it's True
, you set the variable to True
and similarly if it evaluates to False
.So, one can just write
point_is_in_rectangle = x3 >= x1 and x3 <= x2 and y3 >= y1 and y3 <= y2