wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Python Round 3

Total questions: 30

Worksheet time: 15mins

Name
Class
Date
1.

What is the output of: print(type([]) is list)?

a)

True

b)

False

c)

Error

d)

None

2.

What will be the output? x = [1,2,3] y = x.copy() y.append(4) print(x)

a)

[1,2,3,4]

b)

[1,2,3]

c)

Error

d)

None

3.

Which statement about generators is TRUE?

a)

Store all values in memory

b)

Lazy evaluation

c)

Cannot iterate

d)

Faster than lists always

4.

Output of: print(list(map(lambda x: x * 2, [1, 2, 3])))

a)

[1, 2, 3]

b)

[2, 4, 6]

c)

Error

d)

None

5.

Which method is used to deep copy objects?

a)

copy()

b)

deepcopy()

c)

clone()

d)

duplicate()

6.

What happens if a mutable default argument is used?

a)

New object each call

b)

Same object reused

c)

Error

d)

None

7.

What is the output? print([i for i in range(5) if i%2==0])

a)

[1,3]

b)

[0,2,4]

c)

Error

d)

None

8.

Which decorator is used for static methods?

a)

@class

b)

@staticmethod

c)

@method

d)

@static

9.

What does __str__ method do?

a)

Returns memory address

b)

String representation

c)

Deletes object

d)

Initializes object

10.

Which statement creates a set?

a)

{}

b)

set()

c)

[]

d)

()

11.

Output: print({i*i for i in range(2,5)})

a)

{4, 9, 16}

b)

{2: 4, 3: 9, 4: 16}

c)

Error

d)

None

12.

What does zip() return?

a)

List

b)

Tuple

c)

Iterator

d)

Dict

13.

What is the output? print(bool('False'))

a)

True

b)

False

c)

Error

d)

None

14.

Which keyword prevents inheritance?

a)

final

b)

private

c)

Python has none

d)

stop

15.

What is the output? x = [1,2] y = x x += [3] print(y)

a)

[1,2]

b)

[1,2,3]

c)

Error

d)

None

16.

What does *args represent?

a)

Dictionary

b)

Tuple

c)

List

d)

Set

17.

Which function checks if all values are True?

a)

any()

b)

all()

c)

bool()

d)

sum()

18.

What is the output? print(sorted([3,1,2], reverse=True))

a)

[1,2,3]

b)

[3,2,1]

c)

Error

d)

None

19.

What does the finally block do?

a)

Executes only if there is an error

b)

Always executes

c)

Skips the exception

d)

Stops the program

20.

Which protocol supports iteration?

a)

__str__

b)

__iter__

c)

__add__

d)

__len__

21.

What is the output? print(type((5)))

a)

int

b)

tuple

c)

Error

d)

None

22.

Which keyword creates a coroutine?

a)

yield

b)

async

c)

await

d)

lambda

23.

What is the output? print('ABC'.lower().isdigit())

a)

True

b)

False

c)

Error

d)

None

24.

What does the with keyword ensure?

a)

Faster execution

b)

Automatic resource cleanup

c)

Encryption

d)

Debugging

25.

Which module is used for multithreading?

a)

multiprocessing

b)

threading

c)

asyncio

d)

os

26.

Output: print(len({1, 1, 2, 2, 3}))

a)

5

b)

3

c)

Error

d)

None

27.

What does dir() return?

a)

Variables only

b)

Attributes and methods

c)

Memory address

d)

File paths

28.

Which statement about tuples is TRUE?

a)

Mutable

b)

Supports append

c)

Immutable

d)

Unordered

29.

What is the output? print(5//2)

a)

2.5

b)

2

c)

3

d)

Error

30.

What is Python GIL?

a)

Garbage collector

b)

Thread lock mechanism

c)

Compiler

d)

Virtual memory