program calls the points obtained this way pt and pt the and coordinates of pt pt and point can be recovered with the methods of the point typegetx(and gety(suppose that introduce variables for the coordinates of pt pointand pt calling these -coordinates end valand end respectively on first try you might decide that the needed mathematical relationship to test is end <val <end unfortunatelythis is not enoughthe only requirement for the two corner points is that they be diagonally oppositenot that the coordinates of the second point are higher than the corresponding coordinates of the first point it could be that end is end is and val is in this latter case val is between end and end but substituting into the expression above < < is false the and need to be reversed in this case this makes complicated situation also this is an issue which must be revisited for both the and coordinates introduce an auxiliary function isbetween to deal with one coordinate at time it startsdef isbetween(valend end )'''return true if val is between the ends the ends do not need to be in increasing order ''clearly this is true if the original expressionend <val <end is true you must also consider the possible case when the order of the ends is reversedend <val <end how do we combine these two possibilitiesthe boolean connectives to consider are and and or which appliesyou only need one to be trueso or is the proper connectivea correct but redundant function body would beif end <val <end or end <val <end return true elsereturn false check the meaningif the compound expression is truereturn true if the condition is falsereturn false in either case return the same value as the test condition see that much simpler and neater version is to just return the value of the condition itselfreturn end <val <end or end <val <end notein general you should not need an if-else statement to choose between true and false valuesoperate directly on the boolean expression side comment on expressions like end <val <end other than the two-character operatorsthis is like standard math syntaxchaining comparisons in python any number of comparisons can be chained in this wayclosely approximating mathematical notation though this is good pythonbe aware that if you try other high-level languages like java and ++such an expression is gibberish another way the expression can be expressed (and which translates directly to other languagesisend <val and val <end so much for the auxiliary function isbetween back to the isinside function you can use the isbetween function to check the coordinatesisbetween(point getx() getx() getx() more on flow of control