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 | |
|---|---|---|
| 1label.config(text='Saved') | Aconfig() needs the option name text= before the value. It should be label.config(text='Done'). | |
| 2button.config(bg='green') | Bdef on_click(event): label.config(text='Clicked!') | |
| 3A key press handler updates a label to show which key the user pressed | CThe text value is missing quotes, so Python treats Done as a variable name and gives a NameError. It should be text='Done'. | |
| 4A mouse click handler changes a label so the user knows the click was detected | Ddef on_key(event): label.config(text=event.keysym) | |
| 5label.config(text=Done) | EChanges the background colour of a widget when the handler runs | |
| 6label.config('Done') | FChanges the text shown on a label so the user sees feedback after an event |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
label.config(text='Done') — A handler runs when an event happens and can call config() to change the interface, such as updating a label's text to give the user feedback.label.config(text='Done')label.config(text='Saved')def warn():
label.config(fg='red')
button = tk.Button(root, command=warn)def show(event):
label.config(text='Key pressed')
root.bind('<Key>', show)def show(event):
label.config(text='Mouse clicked')
label.bind('<Button-1>', show)