NEW
Font size
WorksheetsPython Round 3
Total questions: 30
Worksheet time: 15mins
What is the output of: print(type([]) is list)?
True
False
Error
None
What will be the output? x = [1,2,3] y = x.copy() y.append(4) print(x)
[1,2,3,4]
[1,2,3]
Error
None
Which statement about generators is TRUE?
Store all values in memory
Lazy evaluation
Cannot iterate
Faster than lists always
Output of: print(list(map(lambda x: x * 2, [1, 2, 3])))
[1, 2, 3]
[2, 4, 6]
Error
None
Which method is used to deep copy objects?
copy()
deepcopy()
clone()
duplicate()
What happens if a mutable default argument is used?
New object each call
Same object reused
Error
None
What is the output? print([i for i in range(5) if i%2==0])
[1,3]
[0,2,4]
Error
None
Which decorator is used for static methods?
@class
@staticmethod
@method
@static
What does __str__ method do?
Returns memory address
String representation
Deletes object
Initializes object
Which statement creates a set?
{}
set()
[]
()
Output: print({i*i for i in range(2,5)})
{4, 9, 16}
{2: 4, 3: 9, 4: 16}
Error
None
What does zip() return?
List
Tuple
Iterator
Dict
What is the output? print(bool('False'))
True
False
Error
None
Which keyword prevents inheritance?
final
private
Python has none
stop
What is the output? x = [1,2] y = x x += [3] print(y)
[1,2]
[1,2,3]
Error
None
What does *args represent?
Dictionary
Tuple
List
Set
Which function checks if all values are True?
any()
all()
bool()
sum()
What is the output? print(sorted([3,1,2], reverse=True))
[1,2,3]
[3,2,1]
Error
None
What does the finally block do?
Executes only if there is an error
Always executes
Skips the exception
Stops the program
Which protocol supports iteration?
__str__
__iter__
__add__
__len__
What is the output? print(type((5)))
int
tuple
Error
None
Which keyword creates a coroutine?
yield
async
await
lambda
What is the output? print('ABC'.lower().isdigit())
True
False
Error
None
What does the with keyword ensure?
Faster execution
Automatic resource cleanup
Encryption
Debugging
Which module is used for multithreading?
multiprocessing
threading
asyncio
os
Output: print(len({1, 1, 2, 2, 3}))
5
3
Error
None
What does dir() return?
Variables only
Attributes and methods
Memory address
File paths
Which statement about tuples is TRUE?
Mutable
Supports append
Immutable
Unordered
What is the output? print(5//2)
2.5
2
3
Error
What is Python GIL?
Garbage collector
Thread lock mechanism
Compiler
Virtual memory
