WorksheetsComProg Midterm
Total questions: 35
Worksheet time: 24mins
What is the starting index of an array in Python?
1
0
-1
Any number
Which of the following best describes a one-dimensional array?
A list containing multiple lists
A standard linear list of values
A list containing three or more lists
A nested dictionary
How do you access the third element in an array arr?
arr[2]
arr[3]
arr(3)
arr[-3]
What is the correct keyword for an if statement in Python?
when
if
check
cond
Which statement is used for multiple conditions in decision-making?
elseif
elif
else-if
otherwise
What keyword is used to prematurely stop a loop in Python?
stop
exit
break
halt
The continue statement is used to:
End the program
Skip the rest of the loop and go to the next iteration
Repeat the loop forever
Exit the loop immediately
Which keyword represents an empty operation in Python?
skip
void
pass
empty
What does a two-dimensional array contain?
A single list of values
Two or more lists inside a list
A list with only numeric values
An unordered collection of data
What function is used to iterate over an iterable in Python?
while
loop
for
repeat
The while loop continues to execute as long as:
A specific condition is true
The loop variable is defined
The program is running
The loop has a break statement
What function is used to convert a variable into a string?
int()
str()
convert()
cast()
In Python, dictionaries store data as:
Key-value pairs
A list of numbers
A sorted sequence
An ordered set
What is used to mark body of an if statement in python
semicolon
indentation
parentheses
colon
These are immutable sequences of values
Tuple
List
Set
Dictionary
What method is used to display a Tkinter window indefinitely?
show()
display()
run()
mainloop()
In a Visual Studio Code setup, what extension is required for Python development?
Python (Microsoft)
Java Extension Pack
HTML Editor
GitLens
What is the primary use of an entry widget in Tkinter?
To display an image
To allow user input
To create a button
To close the application
Which of the following is NOT a Python data type?
Tuple
Integer
Set
Array
What does the title() method do in Tkinter?
Sets the window title
Centers the window
Changes the background color
Closes the window
A python library that is widely known as a standard GUI Library
(a)
This Tkinter method places widgets in a table-like structure.
(a)
Use in Tkinter to keep a window open and responsive.
(a)
This data structure in Python acts as an alternative to arrays.
(a)
This keyword skips the current iteration and moves to the next one in a loop.
(a)
This type of array consists of multiple two-dimensional arrays.
(a)
This keyword terminates a loop prematurely.
(a)
This keyword is used to check multiple conditions in a decision-making structure.
(a)
This executes a block of code only when every other condition is false.
(a)
This executes the block of code if the condition is true.
(a)
Fill in the missing keyword to initialize a Tkinter window:
import tkinter as tk
joshua = tk. (a) ()
Fill in the missing method to set the window title:
joshua. (a) ("Joshua")
Fill in the missing method to create a button widget:
b1 = tk. (a) (joshua, text="1")
Fill in the missing parameter to make a window non-resizable:
joshua. (a) (False, False)
Fill in the missing method to arrange a widget using the grid system:
e1. (a) (row=0, columnspan=3)
