wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Exploring Tkinter in Python

Total questions: 142

Worksheet time: 1hrs 15mins

Name
Class
Date
1.

What is Tkinter in Python?

a)

Tkinter is a data analysis library for Python.

b)

Tkinter is a GUI toolkit for Python.

c)

Tkinter is a database management system.

d)

Tkinter is a web framework for Python.

2.

How do you create a basic Tkinter window?

a)

window = Tk()

b)

window.start()

c)

import tkinter as T

d)

import tkinter as tk window = tk.Tk() window.title('My Tkinter Window') window.mainloop()

3.

Which method is used to start the Tkinter event loop?

a)

execute()

b)

runloop()

c)

startloop()

d)

mainloop()

4.

What is the purpose of the Tk() class in Tkinter?

a)

To manage the layout of widgets in Tkinter.

b)

To handle events in Tkinter.

c)

The purpose of the Tk() class is to create the main application window in Tkinter.

d)

To create a button in Tkinter.

5.

How can you set the title of a Tkinter window?

a)

Use the title method: root.title("Your Title Here")

b)

Use the set_title method: root.set_title('Your Title Here')

c)

Call the configure method: root.configure(title='Your Title Here')

d)

Set the window name: root.name('Your Title Here')

6.

What is a widget in Tkinter?

a)

A widget in Tkinter is a type of database.

b)

A widget in Tkinter is a GUI element that allows user interaction.

c)

A widget in Tkinter is a programming language.

d)

A widget in Tkinter is a file format for images.

7.

Name three common widgets used in Tkinter applications.

a)

Slider

b)

Button, Label, Entry

c)

Canvas

d)

TextBox

8.

How do you add a button widget in Tkinter?

a)

Use the Button class from Tkinter to create a button and pack it into the main window.

b)

Use the Label class to create a button and place it in a frame.

c)

Add a button by using the Canvas widget to draw it on the screen.

d)

Create a button using the Entry class and insert it into the window.

9.

What layout manager is used to arrange widgets in a grid?

a)

GridLayout

b)

FlowLayout

c)

BorderLayout

d)

BoxLayout

10.

How do you create a label widget in Tkinter?

a)

label = root.Label('Your Text Here')

b)

label = Label(root, text='Your Text Here')

c)

label = createLabel(root, 'Your Text Here')

d)

label = Text(root, 'Your Text Here')

11.

What is event handling in Tkinter?

a)

Event handling in Tkinter is only for managing database connections.

b)

Event handling in Tkinter refers to the layout design of the application.

c)

Event handling in Tkinter is the mechanism to respond to user interactions with the GUI.

d)

Event handling in Tkinter is the process of creating new GUI elements.

12.

How do you bind a function to a button click event?

a)

buttonElement.onClick(myFunction);

b)

buttonElement.click(myFunction);

c)

myFunction.bind(buttonElement);

d)

buttonElement.addEventListener('click', myFunction);

13.

What method is used to retrieve text from an Entry widget?

a)

get()

b)

retrieve()

c)

fetch()

d)

extract()

14.

How can you change the background color of a Tkinter window?

a)

Use the pack method to set the background color.

b)

Use the config method or set the bg option to change the background color.

c)

Adjust the window size to modify the background color.

d)

Change the font size to alter the background color.

15.

What is the purpose of the pack() method in Tkinter?

a)

The purpose of the pack() method in Tkinter is to manage the layout of widgets.

b)

To change the color of widgets.

c)

To create a new window in Tkinter.

d)

To delete widgets from the layout.

16.

How do you create a dropdown menu in Tkinter?

a)

Create a listbox for multiple selections.

b)

Implement a button that opens a new window.

c)

Use the OptionMenu widget with a Tkinter variable and a list of options.

d)

Use the Label widget to display text only.

17.

What is the difference between the grid() and pack() methods?

a)

grid() allows for grid-based layout, while pack() provides a linear layout.

b)

grid() arranges widgets in a circular layout, while pack() stacks them vertically.

c)

grid() is for creating menus, while pack() is for handling events.

d)

grid() is used for image display, while pack() is for text alignment.

18.

How can you create a checkbox widget in Tkinter?

a)

Use the Button class to create a checkbox in Tkinter.

b)

Utilize the Label widget for checkbox functionality in Tkinter.

c)

Implement a Radiobutton for checkbox-like behavior in Tkinter.

d)

Use the Checkbutton class with an IntVar to create a checkbox in Tkinter.

19.

What is the purpose of the Frame widget in Tkinter?

a)

The purpose of the Frame widget in Tkinter is to serve as a container for organizing and managing other widgets.

b)

To handle user input and events.

c)

To display images and graphics.

d)

To create pop-up dialogs and alerts.

20.

How do you display an image in a Tkinter application?

a)

Display the image in a Text widget.

b)

Use a Button widget to display the image.

c)

Load the image using a String variable.

d)

Use PhotoImage to load the image and a Label or Canvas to display it.

21.

How can you create a scrollbar in a Tkinter application?

a)

Use the Scrollbar class and attach it to a widget.

b)

Implement a Frame widget to create a scrollbar.

c)

Use the Canvas widget to draw a scrollbar manually.

d)

Scrollbars cannot be created in Tkinter applications.

22.

What method is used to configure the properties of a widget in Tkinter?

a)

configure()

b)

update()

c)

modify()

d)

set()

23.

How do you create a message box in Tkinter?

a)

Message boxes are not supported in Tkinter.

b)

Implement a Frame to create a custom message box.

c)

Use the Label widget to display a message box.

d)

Use the messagebox module and call messagebox.showinfo().

24.

What method is used to destroy a Tkinter window?

a)

close()

b)

quit()

c)

destroy()

d)

exit()

25.

How can you create a radio button in Tkinter?

a)

Implement the Radiobutton class with a Tkinter variable to create a radio button.

b)

Use the Button class to create a radio button.

c)

Use the Label widget to simulate a radio button.

d)

Utilize the Checkbutton class for radio button functionality.

26.

What is the purpose of the LabelFrame widget in Tkinter?

a)

The LabelFrame widget is used to create a container with a border and a title.

b)

To display images and graphics.

c)

To handle user input and events.

d)

To create pop-up dialogs and alerts.

27.

Which command used to change the screen size?

a)

window = Tk()

b)

window.mainloop()

c)

window.geometry("400x300")

28.

Which of the following is easy to use from the user?

a)

Command Line

b)

GUI (Graphical User Interface)

29.

Which command used to change the screen size?

a)

window = Tk()

b)

window.mainloop()

c)

window.geometry("400x300")

30.

Which of the following is easy to use from the user?

a)

Command Line

b)

GUI (Graphical User Interface)

31.

__________ is an element of GUI.

a)

Widget

b)

GUI

c)

Application

32.

Which is the correct way to use tkinter in python

program?

a)

include tkinter *

b)

import tkinter *

c)

from tkinter import *

d)

from tkinter include *

33.

Which of the following function used to create window in

python tkinter.

a)

window()

b)

tk()

c)

toolkit()

d)

wd()

34.

Which of the following attribute used to change the text

color of a Label widget in python tkinter

a)

fg

b)

foreground

c)

bg

d)

background

35.

Which of the following attribute used to change the

background color of a Label widget in python tkinter

a)

background

b)

bg

c)

fg

d)

foreground

36.

What is the full form of GUI?

a)

Graphic Unit Interface

b)

Graphical User Interface

c)

Graphic Unit Input

37.

______________ library provides fast and easy way to create GUI applications in Python.

a)

Tkinter

b)

IbtikarMaker

c)

Graph

38.

Choose the correct statement to display title.

a)

window.title("My First Program")

b)

window.title(My First Program)

c)

window.title "My First Program"

39.

Label , Button , Sliders are all examples of Widgets.

a)

True

b)

False

40.

Which function is used to set the size of the tkinter

window?

a)

setsize()

b)

size()

c)

geometry()

d)

dimension()

41.

What is the use of mainloop() function in tkinter window?

a)

To create the window screen

b)

To hold the window screen

c)

To delete the window screen

d)

To disable the window screen

42.

What is tkinter?

a)

A Python GUI module

b)

A Python Scripting module

43.

It provides a scrollbar to the use so that the use can scroll the window up and down.

a)

Scrollbar()

b)

Spinbox()

c)

Menu()

d)

Entry()

44.

Your program code should end with .mainloop()

(a)  

45.

You can write your program without importing tkinter

(a)  

46.

How to initiate Tkinter window?

a)

Tk( )

b)

CTk( )

c)

TTK( )

d)

TK( )

47.

How to initiate Customtkinter window?

a)

Tk( )

b)

CTk( )

c)

CTK( )

d)

cTk( )

48.

What's the purpose of 'functions'?

a)

reduce the lines of code

b)

To perform repeated tasks

c)

Code readability

d)

Break down the codes

49.

Functions don't get executed unless they are called to perform a task. Yes or No?

(a)  

50.

To create a function, you need to start with 'def'.

Yes or No?

(a)  

51.

When do you use indent space?

(a)  

52.

When should I use .get( ) ?

(a)  

53.

button = Button (window, text = 'click to calculate', command = calculate).

What's the role of 'command' in the above code?

(a)  

54.

value = entry . get( )

In the above code, the input value from the entry widget will be assigned to value. True or False?

(a)  

55.

results_e . configure(text = 'new value')

In the above code, .configure ( ) is to update the values. Yes or No?

(a)  

56.

Your program code should end with .mainloop()

(a)  

57.

You can write your program without importing tkinter

(a)  

58.

How to initiate Tkinter window?

a)

Tk( )

b)

CTk( )

c)

TTK( )

d)

TK( )

59.

How to initiate Customtkinter window?

a)

Tk( )

b)

CTk( )

c)

CTK( )

d)

cTk( )

60.

What's the purpose of 'functions'?

a)

reduce the lines of code

b)

To perform repeated tasks

c)

Code readability

d)

Break down the codes

61.

Functions don't get executed unless they are called to perform a task. Yes or No?

(a)  

62.

To create a function, you need to start with 'def'.

Yes or No?

(a)  

63.

When do you use indent space?

(a)  

64.

When should I use .get( ) ?

(a)  

65.

button = Button (window, text = 'click to calculate', command = calculate).

What's the role of 'command' in the above code?

(a)  

66.

value = entry . get( )

In the above code, the input value from the entry widget will be assigned to value. True or False?

(a)  

67.

results_e . configure(text = 'new value')

In the above code, .configure ( ) is to update the values. Yes or No?

(a)  

68.

How do you create a Label widget in Tkinter?

a)

label = Label("Hello")

b)

label = Label(text="Hello")

c)

Label.new("Hello")

d)

 create_Label("Hello")

69.

Which method is used to change the font color in a tkinter widget?

a)

change_color()

b)

config(fontcolor=)

c)

set_fontcolor()

d)

configure(fg="color")

70.

What is the command to create a basic window in tkinter?

a)

create_window()

b)

 window = tk.Tk()

c)

window = BasicWindow()

d)

 window.create()

71.

What does GUI stand for in computer programming?

a)

Graphical User Interaction

b)

General Use Interface

c)

Graphical User Interface

d)

General User Interaction

72.

Which widget is used to input single-line text from the user in Tkinter?

a)

Label

b)

Text

c)

Entry

d)

Frame

73.

What is the function of the pack() method in Tkinter?

a)

Organizing widgets in a grid

b)

Organizing widgets in blocks before placing them in the parent widget

c)

Placing widgets on specific positions in the window

d)

Organizing the layout of multiple windows

74.

Which of the following is a Python library used for creating GUI applications?

a)

Pandas

b)

Matplotlib

c)

Tkinter

d)

NumPy

75.

What is the purpose of creating Frame widgets in a Tkinter application?

a)

To add decorative images

b)

To group related widgets or provide padding

c)

To control the application flow

d)

To set text color schemes

76.

What is the purpose of Tkinter in Python programming?

a)

Handling databases

b)

Creating Graphical User Interfaces (GUIs)

c)

Working with big data

d)

Developing machine learning models

77.

Which widget is used to display text or images that cannot be edited by the user in Tkinter?

a)

Button

b)

Entry

c)

Text

d)

Label

78.

Which parameter in the Button widget defines the text displayed on the button?

a)

text

b)

width

c)

height

d)

Command

79.

What geometry management technique allows specific positioning of widgets in Tkinter?

a)

grid

b)

place() method

c)

pack() method

d)

place() and pack()

80.

Which geometry manager is commonly used in Tkinter for organizing widgets?

a)

Place

b)

Grid

c)

Pack

d)

Layout

81.

What is the purpose of the grid() method?

a)

It creates a new window for the Tkinter application.

b)

Organizes the widgets in a (table-like structure) before placing them in the parent widget.

c)

It sets the font style and size of the label widget.

d)

It displays the window and starts the Tkinter event loop.

82.

What is the purpose of the mainloop() function in Tkinter?

a)

Ends the program execution

b)

Closes the GUI window

c)

Starts the main event loop

d)

Defines the main GUI layout

83.

What is a widget in the context of graphical user interfaces (GUIs)?

a)

A small furry creature that lives on the desktop.

b)

An element or component that users can interact with to perform tasks or access information in a GUI application.

c)

A tool used by developers to debug GUI code.

d)

A virtual container for storing data in a GUI application.

84.

Which widget is commonly used to trigger actions when clicked in Tkinter?

a)

Entry

b)

Label

c)

Button

d)

Frame

85.

Which of the following is NOT a widget in Tkinter?

a)

Button

b)

Label

c)

Frame

d)

Series

86.

What is the purpose of the update_clock() function when creating a digital clock?

a)

It sets the title of the Tkinter window to "Digital Clock".

b)

It retrieves the current time and updates the text of the clock_label widget every second.

c)

It creates a new Label widget named clock_label with a font size of 50.

d)

It initializes the Tkinter event loop and starts the application.

87.

When creating a simple GUI login interface, what should happen if the username is "admin" and the password is "password"?

a)

Display a message indicating invalid credentials

b)

Verify the credentials upon clicking the login button

c)

Exit the program with an error message

d)

Display a success message for incorrect credentials

88.

Is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicator such as primary notation, instead of text-based UIs, typed command labels or text navigation.

a)

Python

b)

G.U.I

c)

IDE

d)

IDLE

89.

This library provides a powerful object-oriented interface to the GUI toolkit.

a)

Pygames

b)

PyGUI

c)

tthinker

d)

tkinter

90.

what is the widget been programmed?

a)

if else

b)

messagebox

c)

label

d)

button

91.

what is the widget been programmed?

a)

text

b)

window title

c)

label

d)

button

92.

what is the correct execution of the code as seen in the picture?

a)

def clicked():

lbl.configure(text="Button was clicked !!")

b)

def pindot(): lbl.configure(text="Button was clicked !!")

c)

def clicked(): lbl.configurate(text="Button was clicked !!")

d)

def clicked(): button.configure(text="Button was clicked !!")

93.

what is the correct execution of the code as seen in the picture?

a)

lbl = label(window, text="Hello")

b)

lbl = Label(window, text="Hello")

c)

lbl = Text(window, text="Hello")

d)

lbl = txt(window, text="Hello")

94.

what is the widget been programmed?

a)

radiobutton

b)

selectbox

c)

combobox

d)

checkbox

95.

what is the widget been programmed?

a)

radiobutton

b)

button

c)

combobox

d)

checkbox

96.

what is the widget been programmed?

a)

message box

b)

info message

c)

alert box

d)

message content

97.

what is the correct code for the picture?

a)

btn = Button(window, text="Click Me", bg="org", fg="rd")

b)

btn = Button(window, text="Click Me", bg="blue", fg="red")

c)

btn = Button(window, text="Click Me", bg="orange", fg="red")

d)

btn = Button(window, text="Click Me", bg="red", fg="orange")

98.

How do you create a Label widget in Tkinter?

a)

label = Label("Hello")

b)

label = Label(text="Hello")

c)

Label.new("Hello")

d)

 create_Label("Hello")

99.

What is the command to create a basic window in tkinter?

a)

create_window()

b)

 window = tk.Tk()

c)

window = BasicWindow()

d)

 window.create()

100.

What is the function of the pack() method in Tkinter?

a)

Organizing widgets in a grid

b)

Organizing widgets in blocks before placing them in the parent widget

c)

Placing widgets on specific positions in the window

d)

Organizing the layout of multiple windows

101.

What is the purpose of creating Frame widgets in a Tkinter application?

a)

To add decorative images

b)

To group related widgets or provide padding

c)

To control the application flow

d)

To set text color schemes

102.

Which widget is used to display text or images that cannot be edited by the user in Tkinter?

a)

Button

b)

Entry

c)

Text

d)

Label

103.

Which geometry manager is commonly used in Tkinter for organizing widgets?

a)

Place

b)

Grid

c)

Pack

d)

Layout

104.

What is a widget in the context of graphical user interfaces (GUIs)?

a)

A small furry creature that lives on the desktop.

b)

An element or component that users can interact with to perform tasks or access information in a GUI application.

c)

A tool used by developers to debug GUI code.

d)

A virtual container for storing data in a GUI application.

105.

Which widget is commonly used to trigger actions when clicked in Tkinter?

a)

Entry

b)

Label

c)

Button

d)

Frame

106.

What is the purpose of the update_clock() function when creating a digital clock?

a)

It sets the title of the Tkinter window to "Digital Clock".

b)

It retrieves the current time and updates the text of the clock_label widget every second.

c)

It creates a new Label widget named clock_label with a font size of 50.

d)

It initializes the Tkinter event loop and starts the application.

107.

Which is the correct way to use tkinter in python

program?

a)

include tkinter *

b)

import tkinter *

c)

from tkinter import *

d)

from tkinter include *

108.

Which of the following function used to create window in

python tkinter.

a)

window()

b)

tk()

c)

toolkit()

d)

wd()

109.

Which of the following attribute used to change the

background color of a Label widget in python tkinter

a)

background

b)

bg

c)

fg

d)

foreground

110.

Choose the correct statement to display title.

a)

window.title("My First Program")

b)

window.title(My First Program)

c)

window.title "My First Program"

d)

title.window("My First Program")

111.

what is the correct execution of the code as seen in the picture?

a)

def clicked():

lbl.configure(text="Button was clicked !!")

b)

def pindot(): lbl.configure(text="Button was clicked !!")

c)

def clicked(): lbl.configurate(text="Button was clicked !!")

d)

def clicked(): button.configure(text="Button was clicked !!")

112.

what is the correct execution of the code as seen in the picture?

a)

lbl = label(window, text="Hello")

b)

lbl = Label(window, text="Hello")

c)

lbl = Text(window, text="Hello")

d)

lbl = txt(window, text="Hello")

113.

what is the widget been programmed?

a)

radiobutton

b)

selectbox

c)

combobox

d)

checkbox

114.

what is the widget been programmed?

a)

radiobutton

b)

button

c)

combobox

d)

checkbox

115.

what is the widget been programmed?

a)

message box

b)

info message

c)

alert box

d)

message content

116.

what is the correct code for the picture?

a)

btn = Button(window, text="Click Me", bg="org", fg="rd")

b)

btn = Button(window, text="Click Me", bg="blue", fg="red")

c)

btn = Button(window, text="Click Me", bg="orange", fg="red")

d)

btn = Button(window, text="Click Me", bg="red", fg="orange")

117.

what is the widget been programmed?

a)

Entry

b)

Canvas

c)

Relief Style

d)

Bitmaps

118.

To create a border style for a Label or Button, which property should we change?

a)

anchor

b)

bd

c)

relief

d)

text

119.

To add images to Tkinter, which library do we use?

a)

PIL

b)

pip

c)

tkinter

d)

os

120.

Which of the following class declarations is correct

a)

Class<class name>

b)

Class<class name>:

c)

class<class name>

d)

class<class name>:

121.

Which of the following is not a concept in object-oriented programming?

a)

Object

b)

String

c)

Attribute (field, attribute)

d)

Method

122.

What does OOP stand for?

a)

Object Oriented Programming

b)

Object Oriented Processing

c)

Open Object Programming

d)

Object Open Programming

123.

Which of the following statements about Python is false?

a)

Python is a high-level programming language

b)

Python is an object-oriented programming language

c)

Python is a structured programming language

d)

Python is a versatile programming language

124.

What does GUI stand for?

a)

Game User Interface

b)

Graphical User Internation

c)

Graphical Under Interface

d)

Graphical User Interface

125.

Which library do we use to program GUI?

a)

tkinter

b)

os

c)

math

d)

random

126.

Which of the following ways to declare the tkinter library is incorrect?

a)

import tkinter

b)

from tkinter import*

c)

import tkinter as k

d)

from tkinter

127.

What is the command to initialize a window in tkinter?

a)

Tk()

b)

tk()

c)

bg()

d)

Bg()

128.

What syntax is used to set up an event for a Button?

a)

command

b)

relief

c)

justify

d)

anchor

129.

Which command do we use to display a warning?

a)

messagebox.showinfo()

b)

messagebox.showwarning()

c)

messagebox.showerror()

d)

messagebox.askquestion()

130.

What command do we use to hide the Entry content with a *?

a)

show='*'

b)

bd='*'

c)

bg='*'

d)

relief='*'

131.

Which command is used to disable an Entry or Button?

a)

show=’ disable’

b)

relief=’ disable’

c)

state=’ disable’

d)

bd=’ disable’

132.

What command do we use to create a parent window?

a)

Top()

b)

TopLevel()

c)

Level()

d)

Tk()

133.

Which of the following statements about grid is incorrect?

a)

To facilitate the placement of control objects on the form

b)

The workspace is divided into rows and columns

c)

Rows and columns are counted from 0

d)

Can be used together with the pack() command

134.

To retrieve information from entry, Radiobutton, Textbox, which command should we use?

a)

.get()

b)

.textvariable

c)

.StringVar()

d)

.IntVar()

135.

What is the function of eval?

a)

Calculate an integer expression

b)

Calculate a string expression

c)

To draw a circle

d)

Calculate the result of strings

136.

What is the purpose of the try – except statement?

a)

Used to handle errors.

b)

Used to handle conditions like if – else

c)

To create a loop

d)

To fix program errors

137.

Which of the following statements is false about lambda functions

a)

A lambda function is a function defined without a name

b)

A lambda function can have multiple parameters but only one expression

c)

A lambda function cannot return a value

d)

A lambda function is also known as an anonymous function

138.

What is the syntax of a lambda function?

a)

def lambda (<parameter>):

<expression>

b)

lambda <parameter>: <expression>

c)

lambda <parameter>, <expression>

d)

lambda (<parameter>, <expression>)

139.

What command is used to set up events for items in the menu button?

a)

command

b)

tearoff

c)

separator

d)

add_command()

140.

What command do we use to create a color palette?

a)

chooser.askcolor()

b)

color.askcolor()

c)

colorchooser.askcolor()

d)

bg.askcolor()

141.

To create a parent menu, which structure do we use?

a)

add_cascade()

b)

add_cascade

c)

add_command()

d)

add_command

142.

What structure is used to create a slider?

a)

Scale(window,from_=<start value>,to=<end value>)

b)

ttk.Scale(window,from_=<start value>,to=<end value>)

c)

tk.Scale(window,from_=<start value>,to=<end value>)

d)

Tk.Scale(window,from_=<start value>,to=<end value>)