Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Study Topics Quiz

Total questions: 25

Worksheet time: 13mins

Name
Class
Date
1.

Which of the following is NOT a data type in Python?

a)

Strings

b)

Booleans

c)

Characters

d)

Floats

2.

What operator is used for comparison in Python?

a)

==

b)

!

c)

||

d)

&&

3.

Which string method converts a string to lowercase?

a)

.upper()

b)

.title()

c)

.lower()

d)

.capitalize()

4.

What keyword is used to define a function in Python?

a)

func

b)

def

c)

define

d)

function

5.

Which of the following is a valid way to create a list in Python?

a)

list = [1, 2, 3]

b)

list = <1, 2, 3>

c)

list = {1, 2, 3}

d)

list = (1, 2, 3)

6.

What does the 'yield' keyword do in Python?

a)

Creates a generator

b)

Raises an exception

c)

Returns a value from a function

d)

Ends a loop

7.

Which of the following is an immutable data structure in Python?

a)

Set

b)

Dictionary

c)

Tuple

d)

List

8.

What is the purpose of the 'global' keyword?

a)

To define a global variable

b)

To declare a constant

c)

To import modules

d)

To create a function

9.

Which of the following is a valid way to import a module in Python?

a)

require math

b)

using math

c)

include math

d)

import math

10.

What is a closure in Python?

a)

An error handling mechanism

b)

A data structure

c)

A type of loop

d)

A function that returns another function

11.

Which of the following is NOT a control flow statement?

a)

if

b)

for

c)

while

d)

define

12.

What does the 'append()' method do in a list?

a)

Reverses the list

b)

Sorts the list

c)

Adds an item to the end

d)

Removes an item

13.

Which of the following is a valid way to define a lambda function?

a)

def lambda x: x + 1

b)

lambda x: x + 1

c)

lambda: x + 1

d)

function lambda(x): x + 1

14.

What is the output of the expression '5 // 2' in Python?

a)

3

b)

2.5

c)

2

d)

5

15.

Which of the following is a valid dictionary in Python?

a)

{'one': 1, 'two': 2}

b)

(1, 2, 3)

c)

[1: 'one', 2: 'two']

d)

{1, 2, 3}

16.

What is the purpose of the 'with' statement in file handling?

a)

To write to a file

b)

To read a file

c)

To ensure proper resource management

d)

To open a file

17.

Which of the following is a valid way to create a set in Python?

a)

set = <1, 2, 3>

b)

set = {1, 2, 3}

c)

set = (1, 2, 3)

d)

set = [1, 2, 3]

18.

What does the 'break' statement do in a loop?

a)

Ends the loop

b)

Continues to the next iteration

c)

Exits the program

d)

Pauses the loop

19.

Which of the following is a valid way to define a function with default arguments?

a)

def func(x=1):

b)

func(x=1):

c)

def func(x): x=1

d)

function func(x=1):

20.

What is the output of the expression 'len([1, 2, 3])'?

a)

3

b)

2

c)

1

d)

None

21.

Which of the following is a valid way to slice a list?

a)

list[1, 3]

b)

list{1:3}

c)

list[1:3]

d)

list(1:3)

22.

What is the purpose of decorators in Python?

a)

To modify function behavior

b)

To create classes

c)

To handle exceptions

d)

To define variables

23.

Which of the following is a valid way to read a file in Python?

a)

file.read()

b)

file.get()

c)

file.open()

d)

file.load()

24.

What is the output of the expression '3 * 2 ** 2'?

a)

12

b)

6

c)

8

d)

9

25.

Which of the following is a valid way to create a tuple?

a)

<1, 2, 3>

b)

(1, 2, 3)

c)

{1, 2, 3}

d)

[1, 2, 3]