Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Programming Concepts Quiz

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is the main purpose of a for loop?

a)

To make a decision based on a condition.

b)

To repeat a block of code a specific number of times or for each item in a sequence.

c)

To store a single piece of data.

d)

To stop the program from running.

2.

Which line of code correctly checks if a variable score is exactly 50?

a)

if score = 50

b)

if score > 50

c)

if score == 50

d)

if score != 50

3.

What will len(['A', 'B', 'C']) return?

a)

2

b)

3

c)

'C'

d)

An error

4.

How do you add a comment to a single line in a Python script?

a)

``

b)

/* This is a comment */

c)

// This is a comment

d)

# This is a comment

5.

What is a Boolean value?

a)

A number with a decimal point.

b)

A whole number.

c)

A sequence of characters.

d)

A value that can only be True or False.

6.

What is a 2D array?

a)

A list that can only contain numbers.

b)

A special type of variable for storing text.

c)

A list where each item is another list, creating a grid-like structure.

d)

A list that cannot be changed.

7.

Using map = [[0, 1], [2, 3]], how would you access the number 1?

a)

map[1][0]

b)

map[0][1]

c)

map[1][1]

d)

map[0, 1]

8.

In a nested loop for row in range(3): for col in range(3):, which variable changes the fastest?

a)

row

b)

col

c)

They change at the same time.

d)

range

9.

What is the term for the first number used to access an element in a 2D array, like the 0 in grid[0][1]?

a)

The column number

b)

The element

c)

The row index

d)

The list index

10.

If seating_plan = [['Amy', 'Ben'], ['Chloe', 'Dan'], ['Eva', 'Finn']], what is len(seating_plan)?

a)

6

b)

2

c)

3

d)

5

11.

You have a 2D array scores where each inner list is [student_id, score]. How would you get the score of the first student?

a)

scores[1][0]

b)

scores[0][0]

c)

scores[1]

d)

scores[0][1]

12.

You want to loop through a 10x8 grid called pixel_data (10 rows, 8 columns). What is the correct range for the loops?

a)

for row in range(8): for col in range(10):

b)

for row in range(9): for col in range(7):

c)

for row in range(10): for col in range(8):

d)

for row in range(11): for col in range(9):

13.

Given grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]], what is the best way to set the entire first column to 1?

a)

grid[0] = [1, 1, 1]

b)

for i in range(3): grid[i][0] = 1

c)

grid[1][0] = 1

d)

grid[0][1] = 1

14.

When processing a 2D array of sales data, why is a nested for loop a good structure to find the total sales?

a)

Because it is the only way to access the elements.

b)

Because it allows you to systematically visit every cell by iterating through each row and column.

c)

Because it is faster than a single loop.

d)

Because it uses less memory.

15.

What is the purpose of initializing a variable like `total_points = 0` before starting a loop that calculates a team's score?

a)

To make sure the variable is a number and not text.

b)

To store the highest possible score a team can get.

c)

To make the code easier to read without changing how it runs.

d)

To create a clean starting point (an accumulator) that you can correctly add points to during each iteration of the loop.