I'm doing a course for coursera and came across the following code:
def is_selected(self, pos):
inside_hor = self.location[0] <= pos[0] < self.location[0] + TILE_WIDTH
inside_vert = self.location[1] - TILE_HEIGHT <= pos[1] <= self.location[1]
return inside_hor and inside_vert
I cannot understand how the <=
and <
are used. I know that they mean "smaller or equals" and "smaller than", but how am I to evaluate the value of inside_hor
?
Why is inside_hor = self.location[0] <= pos[0] < self.location[0] + TILE_WIDTH
written like that, what function do the <=
and <
serve here, is there an alternative way of writing it?