def mouse_press(x, y, text, color, quiz_type): a = [x,y] rect_list_text = [] rect_list_color = [] print(x, y, text, color, quiz_type) for dictionary in shapes: if dictionary['text'] == text: rect_list_text.append(dictionary['rect']) #get the cpordinates of rectangle with color same as of quiz shown if dictionary['color'] == color: rect_list_color.append(dictionary['rect']) check_result0 = is_inside(a, rect_list_text[0]) check_result1 = is_inside(a, rect_list_color[0]) if quiz_type ==0 and check_result0 == True: return True elif quiz_type ==1 and check_result1 == True: return True else: return False
def mouse_press(x, y, text, color, quiz_type): rect_answer = [] for box in shapes: if quiz_type == 0: if box['text'].upper() == text: rect_answer = box['rect'] elif quiz_type == 1: if box['color'] == color: rect_answer = box['rect'] if is_inside([x, y], rect_answer): return True else: return False
def mouse_press(x, y, text, color, quiz_type): shapes = get_shapes() for shape in shapes: if is_inside([x,y], shape['rect']): if quiz_type == 0: if text == shape['text']: return True else: return False else: if color == shape['color']: return True else: return False
def mouse_press(x, y, text, color, quiz_type): from inside import is_inside point = [x, y] rect_detail = [] for detail in shapes: rect_detail = detail['rect'] press = is_inside(point, rect_detail) if press: if quiz_type == 1: if detail['color'] == color: return True else: return False elif quiz_type == 0: if detail['text'].upper() == text: return True else: return False
from inside import is_inside # case 1: point1 = [100, 120] rect1 = [140, 60, 100, 200] case1 = is_inside(point1, rect1) # case 2: point2 = [200, 120] rect2 = [140, 60, 100, 200] case2 = is_inside(point2, rect2) if case1 == False and case2 == True: print("Your function is correct") else: print("Ooops, bugs detected")