PCPP 32 10x PCPP Certified Professional Python Programmer 1 · Free Practice Question Medium

Question 37

Consider the following code snippet using Tkinter:



Which of the following describes the behavior of the above script?

  • A

    The script displays a window with an Entry widget containing the text "Default text", and when the Entry widget is clicked, the function display_text() is called.

  • B

    The script does not display anything because it is missing a Label widget.

  • C

    The script displays a window with an Entry widget containing the text "Default text", and when the Entry widget text is changed, the function display_text() is called.

  • D

    The script displays a window with an Entry widget containing the text "Default text", but the function display_text() is not called by any event.

Reveal correct answer

Correct answer: D

A.

Although the script displays an Entry widget with "Default text", there is no event binding that would call the display_text() function when the Entry widget is clicked.

B.

The script does display a window with an Entry widget. A Label widget is not required for the window to display something.

C.

While the Entry widget is displayed with "Default text", the function display_text() is not called when the Entry widget text is changed. There is no event binding that would trigger the function in this case.

D.

The script does display a window with an Entry widget containing the text "Default text". However, although the display_text() function would print the content of the Entry widget when called, there is no event in the script that calls this function.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need