Question 6 (Advanced):
In Python's context managers, what is the purpose of the
A) Memory allocation and garbage collection
B) Database connection pooling
C) Resource initialization and cleanup
D) Thread synchronization
#Python #ContextManagers #ResourceManagement #Advanced
In Python's context managers, what is the purpose of the
__enter__
and __exit__
methods?A) Memory allocation and garbage collection
B) Database connection pooling
C) Resource initialization and cleanup
D) Thread synchronization
#Python #ContextManagers #ResourceManagement #Advanced
Question 8 (Advanced):
What is the time complexity of checking if an element exists in a Python
A) O(1)
B) O(n)
C) O(log n)
D) O(n^2)
#Python #DataStructures #TimeComplexity #Advanced
✅ By: https://yangx.top/DataScienceQ
What is the time complexity of checking if an element exists in a Python
set
?A) O(1)
B) O(n)
C) O(log n)
D) O(n^2)
#Python #DataStructures #TimeComplexity #Advanced
✅ By: https://yangx.top/DataScienceQ
❤1
Question 1 (Advanced):
When using Python's
A) Windows lacks proper fork() implementation
B) Linux handles memory management differently
C) macOS has better garbage collection
D) Windows requires explicit process naming
#Python #Multiprocessing #ParallelComputing #Advanced
✅ By: https://yangx.top/DataScienceQ
When using Python's
multiprocessing
module, why is if __name__ == '__main__':
required for Windows but often optional for Linux/macOS? A) Windows lacks proper fork() implementation
B) Linux handles memory management differently
C) macOS has better garbage collection
D) Windows requires explicit process naming
#Python #Multiprocessing #ParallelComputing #Advanced
✅ By: https://yangx.top/DataScienceQ
Question 23 (Advanced):
How does Python's "Name Mangling" (double underscore prefix) work in class attribute names, and what's its practical purpose?
Options:
A) Completely hides the attribute
B) Renames it to
C) Makes it immutable
D) Converts it to a method
#Python #OOP #NameMangling #Advanced
✅ By: https://yangx.top/DataScienceQ
How does Python's "Name Mangling" (double underscore prefix) work in class attribute names, and what's its practical purpose?
class Test:
def __init__(self):
self.public = 10
self._protected = 20
self.__private = 30 # Name mangling
obj = Test()
print(dir(obj)) # What happens to __private?
Options:
A) Completely hides the attribute
B) Renames it to
_Test__private
C) Makes it immutable
D) Converts it to a method
#Python #OOP #NameMangling #Advanced
✅ By: https://yangx.top/DataScienceQ