wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python (I/O to Lists) Formative Quiz

Total questions: 25

Worksheet time: 9mins

Name
Class
Date
1.

What is the syntax for an if-else statement in Python?

a)

if condition: # code block for else condition else: # code block for if condition

b)

if condition: # code block for if condition else: # code block for else condition

c)

if condition: # code block for if condition else: # code block for if condition

d)

if condition: # code block for if condition else: # code block for else condition

2.

When is the else block executed in an if-else statement?

a)

When the condition in the if statement is false.

b)

When the program encounters a break statement.

c)

When the condition in the if statement is null.

d)

When the condition in the if statement is true.

3.

Which Python code checks if a number is even or odd, using a conditional statement?

a)

num % 2 == 0

b)

num / 2 == 0

c)

num % 2 == 1

d)

num % 2 != 0

4.

What are the Boolean operators in Python?

a)

and, or, not

b)

if, else, while

c)

true, false, maybe

d)

plus, minus, multiply

5.

What is the result of the Boolean expression: True AND False?

a)

False

b)

True

c)

True AND True

d)

False AND True

6.

Explain the 'not' operator with an example in Python.

a)

Example: not False returns True

b)

Example: not 'hello' returns 'hello'

c)

Example: not 1 returns 0

d)

Example: not True returns False

7.

How do you assign a value to a variable in Python?

a)

assign variable_name = value

b)

variable_name = value

c)

value = variable_name

d)

value to variable_name

8.

What is the difference between '=' and '==' in Python?

a)

'=' is for assigning, while '==' is for comparing

b)

'=' is for comparing, while '==' is for assigning

c)

'=' is for calculating, while '==' is for comparing

d)

'=' is for calculating, while '==' is for assigning

9.

Write a Python code to swap the values of two variables without using a temporary variable.

a)

a, b = b, a

b)

a = b, b = a

c)

a = a + b

b = a - b

a = a - b

d)

temp = a

a = b

b = temp

10.

What is the syntax for a while loop in Python?

a)

if condition:

# code to be executed

b)

for condition:

# code to be executed

c)

do condition:

# code to be executed

d)

while condition:

# code to be executed

11.

How is the condition checked in a while loop in Python?

a)

By using a string expression

b)

By using a list expression

c)

By using a numeric expression

d)

By using a boolean expression

12.

Write a Python code to print numbers from 1 to 5 using a while loop.

a)

while num <= 5: print(num) num += 1

b)

print(1, 2, 3, 4, 5)

c)

while num < 5: print(num)

d)

for num in range(1, 6): print(num)

13.

What is a list in Python?

a)

A mathematical equation used in Python programming

b)

A type of data structure used in Java programming

c)

A collection of items that are ordered and changeable

d)

A type of snake found in the Amazon rainforest

14.

How do you access items in a list in Python?

a)

myList[index]

b)

myList<index>

c)

myList(index)

d)

myList{index}

15.

Write a Python code to add an item to the end of a list.

a)

my_list.extend(new_element)

b)

my_list.add(new_element)

c)

my_list.insert(new_element)

d)

my_list.append(new_element)

16.

What is the correct way to remove an item from a list in Python?

a)

my_list.remove(item)

b)

my_list.delete(item)

c)

my_list.pop(item)

d)

my_list.discard(item)

17.

How do you iterate through a list in Python using a for loop?

a)

for item in my_list:

b)

for i in range(len(my_list)):

c)

for item in range(my_list):

d)

for i in my_list:

18.

What is the result of the Boolean expression: False OR True?

a)

True

b)

False

c)

False OR False

d)

True OR False

19.

Write a Python code to print the numbers from 1 to 5.

a)

for i in range(5):

print(i)

b)

for i in range(1, 6):

print(i)

c)

for i in range(1, 5):

print(i)

d)

for i in range(6):

print(i)

20.

Explain the difference between 'break' and 'continue' statements in Python.

a)

'break' is used to exit the loop, while 'continue' is used to skip the current iteration and continue with the next iteration.

b)

'break' is used to skip the current iteration and continue with the next iteration, while 'continue' is used to exit the loop.

c)

'break' is used to continue with the next iteration, while 'continue' is used to exit the loop.

d)

Both 'break' and 'continue' are used to exit the loop

21.

BONUS: Which 2023 movie had the highest box-office gross worldwide?

a)

Barbie

b)

Oppenheimer

c)

The Super Mario Bros. Movie

d)

Guardians of the Galaxy Vol. 3

22.

BONUS!

a)

b)

c)

d)

23.

BONUS: According to Spotify, who is the top artist of 2023, with 26.1 billion global streams?

a)

Taylor Swift

b)

Bad Bunny

c)

The Weeknd

d)

Drake

24.

BONUS: Between these four YouTubers, who has the most subscribers?

a)

MrBeast

b)

Cocomelon

c)

Kids Diana Show

d)

PewDiePie

25.

BONUS: Which video game currently has the most monthly active users (MAU) globally?

a)

Fortnite

b)

Minecraft

c)

The Sims 4

d)

Roblox