Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

ComProg Midterm

Total questions: 35

Worksheet time: 24mins

Name
Class
Date
1.

What is the starting index of an array in Python?

a)

1

b)

0

c)

-1

d)

Any number

2.

Which of the following best describes a one-dimensional array?

a)

A list containing multiple lists

b)

A standard linear list of values

c)

A list containing three or more lists

d)

A nested dictionary

3.

How do you access the third element in an array arr?

a)

arr[2]

b)

arr[3]

c)

arr(3)

d)

arr[-3]

4.

What is the correct keyword for an if statement in Python?

a)

when

b)

if

c)

check

d)

cond

5.

Which statement is used for multiple conditions in decision-making?

a)

elseif

b)

elif

c)

else-if

d)

otherwise

6.

What keyword is used to prematurely stop a loop in Python?

a)

stop

b)

exit

c)

break

d)

halt

7.

The continue statement is used to:

a)

End the program

b)

Skip the rest of the loop and go to the next iteration

c)

Repeat the loop forever

d)

Exit the loop immediately

8.

Which keyword represents an empty operation in Python?

a)

skip

b)

void

c)

pass

d)

empty

9.

What does a two-dimensional array contain?

a)

A single list of values

b)

Two or more lists inside a list

c)

A list with only numeric values

d)

An unordered collection of data

10.

What function is used to iterate over an iterable in Python?

a)

while

b)

loop

c)

for

d)

repeat

11.

The while loop continues to execute as long as:

a)

A specific condition is true

b)

The loop variable is defined

c)

The program is running

d)

The loop has a break statement

12.

What function is used to convert a variable into a string?

a)

int()

b)

str()

c)

convert()

d)

cast()

13.

In Python, dictionaries store data as:

a)

Key-value pairs

b)

A list of numbers

c)

A sorted sequence

d)

An ordered set

14.

What is used to mark body of an if statement in python

a)

semicolon

b)

indentation

c)

parentheses

d)

colon

15.

These are immutable sequences of values

a)

Tuple

b)

List

c)

Set

d)

Dictionary

16.

What method is used to display a Tkinter window indefinitely?

a)

show()

b)

display()

c)

run()

d)

mainloop()

17.

In a Visual Studio Code setup, what extension is required for Python development?

a)

Python (Microsoft)

b)

Java Extension Pack

c)

HTML Editor

d)

GitLens

18.

What is the primary use of an entry widget in Tkinter?

a)

To display an image

b)

To allow user input

c)

To create a button

d)

To close the application

19.

Which of the following is NOT a Python data type?

a)

Tuple

b)

Integer

c)

Set

d)

Array

20.

What does the title() method do in Tkinter?

a)

Sets the window title

b)

Centers the window

c)

Changes the background color

d)

Closes the window

21.

A python library that is widely known as a standard GUI Library

(a)  

22.

This Tkinter method places widgets in a table-like structure.

(a)  

23.

Use in Tkinter to keep a window open and responsive.

(a)  

24.

This data structure in Python acts as an alternative to arrays.

(a)  

25.

This keyword skips the current iteration and moves to the next one in a loop.

(a)  

26.

This type of array consists of multiple two-dimensional arrays.

(a)  

27.

This keyword terminates a loop prematurely.

(a)  

28.

This keyword is used to check multiple conditions in a decision-making structure.

(a)  

29.

This executes a block of code only when every other condition is false.

(a)  

30.

This executes the block of code if the condition is true.

(a)  

31.

Fill in the missing keyword to initialize a Tkinter window:
import tkinter as tk

joshua = tk. (a)   ()

32.

Fill in the missing method to set the window title:
joshua. (a)   ("Joshua")

33.

Fill in the missing method to create a button widget:
b1 = tk. (a)   (joshua, text="1")

34.

Fill in the missing parameter to make a window non-resizable:
joshua. (a)   (False, False)

35.

Fill in the missing method to arrange a widget using the grid system:
e1. (a)   (row=0, columnspan=3)