Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Quiz Questions

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is the output of the following code? print(2 * 3 ** 2)

a)

36

b)

18

c)

12

d)

9

2.

Which of the following is not a valid variable name in Python?

a)

_myvar

b)

2var

c)

my_var

d)

var2

3.

What will be the output of the following code? print(bool([]), bool(0), bool(None))

a)

False False False

b)

True True True

c)

False True False

d)

True False True

4.

How do you open a file for both reading and writing in Python?

a)

"r"

b)

"w"

c)

"rw"

d)

"r+"

5.

What will len("Python") return?

a)

5

b)

6

c)

7

d)

Error

6.

What is the correct way to define a function in Python?

a)

define my_function():

b)

def my_function():

c)

function my_function():

d)

func my_function():

7.

What will list(range(2, 10, 2)) return?

a)

[2, 3, 4, 5, 6, 7, 8, 9]

b)

[2, 4, 6, 8]

c)

[2, 4, 6, 8, 10]

d)

[2, 6, 10]

8.

Which keyword is used to create a class in Python?

a)

class

b)

def

c)

object

d)

struct

9.

What is the output of the following code? print("Python".lower())

a)

PYTHON

b)

python

c)

Python

d)

error

10.

What is the result of 10 // 3 in Python?

a)

3.33

b)

3.0

c)

3

d)

4