and to check the coordinatesisbetween(point gety() gety() gety()again the question ariseshow do you combine the two testsin this case we need the point to be both between the sides and between the top and bottomso the proper connector is and think how to finish the isinside method hint sometimes you want to test the opposite of condition as in english you can use the word not for instanceto test if point was not inside rectangle rectyou could use the condition not isinside(rectpointin generalnot condition is true when condition is falseand false when condition is true the example program choosebutton pyshown belowis complete program using the isinside function in simple applicationchoosing colors pardon the length do check it out it will be the starting point for number of improvements that shorten it and make it more powerful in the next section first brief overviewthe program includes the functions isbetween and isinside that have already been discussed the program creates number of colored rectangles to use as buttons and also as picture components aside from specific data valuesthe code to create each rectangle is the sameso the action is encapsulated in functionmakecoloredrect all of this is fineand will be preserved in later versions the present main function is longthough it has the usual graphics starting codedraws buttons and picture elementsand then has number of code sections prompting the user to choose color for picture element each code section has long if-elif-else test to see which button was clickedand sets the color of the picture element appropriately '''make choice of colors via mouse clicks in rectangles - demonstration of boolean operators and boolean functions ''from graphics import def isbetween(xend end )'''return true if is between the ends or equal to either the ends do not need to be in increasing order ''return end < <end or end < <end def isinside(pointrect)'''return true if the point is inside the rectangle rect ''pt rect getp (pt rect getp (return isbetween(point getx()pt getx()pt getx()and isbetween(point gety()pt gety()pt gety()def makecoloredrect(cornerwidthheightcolorwin)''return rectangle drawn in win with the upper left corner and color specified ''corner corner clone(corner move(width-height once againyou are calculating and returning boolean result you do not need an if-else statement if statements