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 | |
|---|---|---|
| 1Button(window, text="Save", command=save_data) | Adef on_click(): print("Clicked") | |
| 2window.mainloop() | Bname_box = Entry(window) | |
| 3A text box control lets the user type in a value for the program to use | CThere is no window.mainloop() at the end, so the window closes straight away and never waits for events. | |
| 4A GUI program is event-driven: it runs a function in response to a user action such as a click | DStarts the event loop so the window stays open and waits for the user to click or type | |
| 5Button(window, text="Go", command=start()) | ECreates a button control that runs the save_data function when the user clicks it | |
| 6window = Tk() Label(window, text="Hi").pack() | Fstart() has brackets, so the function runs immediately when the button is created instead of on a click. Use command=start. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
GUI — A graphical user interface: windows and controls like buttons and text boxes the user clicks or types in. The program waits for events, such as a click, and responds to each one.import tkinter as tk
root = tk.Tk()
root.title("My App")root = tk.Tk()
btn = tk.Button(root, text="Click me")
btn.pack()entry = tk.Entry(root)
entry.pack()def greet():
print("Hi!")
btn = tk.Button(root, command=greet)btn.pack()
root.mainloop()