wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Test

Total questions: 15

Worksheet time: 30mins

Name
Class
Date
1.

Which of the following is mutable in Python?

a)

A) Tuple

b)

B) String

c)

C) List

d)

D) Integer

2.

What is the output of the code?

print(bool("False"))

a)

A) False

b)

B) True

c)

C) Error

d)

D) None

3.

Which keyword is used to modify a global variable inside a function?

a)

A) extern

b)

B) static

c)

C) global

d)

D) public

4.

What is the output?

a = [1, 2, 3]

print(a * 2)

a)

A) [1, 2, 3, 2]

b)

B) [2, 4, 6]

c)

C) [1, 2, 3, 1, 2, 3]

d)

D) Error

5.

What is the difference between (is) and (==)?

a)

A) Both check value equality

b)

B) is checks memory location, == checks value

c)

C) == checks memory, is checks value

d)

D) No difference

6.

Which module is used for multithreading in Python?

a)

A) thread

b)

B) multiprocessing

c)

C) threading

d)

D) os

7.

Which keyword is used to check conditions in Python?

a)

A) if

b)

B) check

c)

C) condition

d)

D) when

8.

Which of the following is used to take input from the user?

a)

A) scan()

b)

B) input()

c)

C) read()

d)

D) get()

9.

Which loop is used when the number of iterations is known?

a)

A) while

b)

B) do-while

c)

C) for

d)

D) switch

10.

What is the output of print(type(10))?

a)

A) <class 'float'>

b)

B) <class 'str'>

c)

C) <class 'int'>

d)

D) <class 'bool'>

11.

What is the correct file extension for Python files?

a)

A) .pt

b)

B) .p

c)

C) .py

d)

D) .python

12.

Which symbol is used for comments in Python?

a)

A) //

b)

B) #

c)

C) /* */

d)

D) <!-- -->

13.

What does @classmethod receive as its first parameter?

a)

A) self

b)

B) cls

c)

C) obj

d)

D) class

14.

Which keyword is used to handle exceptions?

a)

A) catch

b)

B) handle

c)

C) except

d)

D) error

15.

What is the output?

print(sum([i for i in range(5)]))

a)

A) 15

b)

B) 10

c)

C) 5

d)

D) Error