Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1canvas.bind('<Button-1>', on_click) | ARuns on_click when the left mouse button is clicked on the canvas | |
| 2canvas.bind('<Double-Button-1>', on_double) | Bwindow.bind('<Button-1>', show_menu) | |
| 3A handler reads where the mouse was clicked using the event it receives | Cdef on_click(event): print(event.x, event.y) | |
| 4Bind the left click on a window so that the function show_menu runs when it happens | DRuns on_double when the left mouse button is double-clicked on the canvas | |
| 5canvas.bind('<Button-1>', on_click()) | EThe handler has brackets, so it is called straight away instead of waiting for a click. It should be passed as on_click. | |
| 6def on_click(): print(event.x, event.y) | FThe handler is missing the event parameter, so event is not defined and the click position cannot be read. It should be def on_click(event): |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
widget.bind('<Button-1>', handler) — Runs the handler function when the left mouse button is clicked on that widget. The handler receives an event with event.x and event.y. Use '<Double-Button-1>' for a double click.canvas.bind('<Button-1>', on_click)canvas.bind('<Button-1>', on_click)print('Y:', event.y)canvas.bind('<Double-Button-1>', on_click)def clicked(event): print(event.x)