Questions: Event-Driven Programming

4 questions to test your understanding

Score: 0 / 4
Question 1 Multiple Choice

In Python's tkinter, a student writes `Button(root, text='Save', command=save_file())`. The file is saved once when the program starts, and clicking the button does nothing. Why?

Atkinter buttons can call a function only once
Bsave_file() runs immediately while the button is built, and its return value (None) is registered instead of the function
CThe button needs a second argument naming the event type
Dsave_file must be defined after the button is created
Question 2 True / False

In an event-driven program, event handlers always run in the order they are defined in the source code.

TTrue
FFalse
Question 3 Multiple Choice

A click handler in a single-threaded GUI program runs a loop that takes 10 seconds. What does the user most likely see during those 10 seconds?

AThe window keeps responding normally, because each click gets its own copy of the program
BThe window stops responding to clicks and redraws until the handler finishes
CThe program crashes immediately
DThe loop is skipped, because handlers cannot contain loops
Question 4 Short Answer

What is an event loop, and why do most event-driven programs not need to write one themselves?

Think about your answer, then reveal below.