""" Solve the first problem. """ print "\n\n# Problem #1 : check if a point is in a square work space." xmin=-100 xmax=100 ymin=-100 ymax=100 print "The work-space [{xmin},{xmax}] × [{ymin},{ymax}].".format(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax) x = -43 y = 23 print "Alright, I will tell you if P(x={x}, y={y}) is in the work-space [{xmin},{xmax}] × [{ymin},{ymax}].".format(x=x, y=y, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax) # So it is quite easy: # if ((xmin <= x) and (x <= xmax)) and ((ymin <= y) and (y <= ymax)): # This syntax is also possible if (xmin <= x <= xmax) and (ymin <= y <= ymax): print "Yes, the point P is indeed inside!" else: print "No, the point P is not inside..." print "Done for that exercise."