Python Concurrency and Parallelism
Python Concurrency and Parallelism - Important Points
31. | Which of the following is an example of a parallel processing library in Python? |
---|
A. NumPy
B. Pandas
C. TensorFlow
D. Flask
View Answer Discuss Work SpaceAnswer: option c
Explanation:
32. | What is the purpose of the asyncio module in Python? |
---|
A. To provide a way to execute code concurrently using threads and processes.
B. To provide a way to execute code concurrently using coroutines.
C. To provide a way to manage and control concurrency in Python code.
D. To provide a way to create and manage threads and processes.
View Answer Discuss Work SpaceAnswer: option b
Explanation:
33. | What is the purpose of the lock object in Python threading? |
---|
A. To ensure only one thread can access a shared resource at a time.
B. To prevent deadlock in multithreaded code.
C. To provide a way to communicate between threads.
D. To provide a way to synchronize tasks between threads.
View Answer Discuss Work SpaceAnswer: option a
Explanation:
34. | What is the purpose of the semaphore object in Python threading? |
---|
A. To ensure only one thread can access a shared resource at a time.
B. To prevent deadlock in multithreaded code.
C. To provide a way to communicate between threads.
D. To provide a way to limit the number of threads that can access a resource at a time.
View Answer Discuss Work SpaceAnswer: option d
Explanation:
35. | Which of the following is a disadvantage of using locks in multithreaded code? |
---|
A. They can cause deadlock if used improperly.
B. They can be less efficient than using other synchronization mechanisms.
C. They can be more difficult to use than other synchronization mechanisms.
D. They can be difficult to implement in Python code.
View Answer Discuss Work SpaceAnswer: option a
Explanation: