menu

Python Concurrency and Parallelism


1. Which of the following is a tool for detecting and debugging concurrency issues in Python?

PyCharm

Black

Flake8

Pyroscope


2. Which of the following is an example of a concurrency bug in Python?

A race condition

A deadlock

A livelock

A memory leak


3. Which of the following is a way to overcome the limitations of the GIL in Python?

Using multiprocessing instead of threading

Using asyncio instead of threading

Using coroutines instead of threads

Using locks to manage access to shared resources


4. What is the purpose of the asyncio module in Python?

To provide a way to execute code concurrently using threads and processes.

To provide a way to execute code concurrently using coroutines.

To provide a way to manage and control concurrency in Python code.

To provide a way to create and manage threads and processes.


5. Which keyword is used to define a Python function as a coroutine?

async

await

coroutine

yield


6. What is the Global Interpreter Lock (GIL) in Python?

A mechanism that ensures only one thread can execute Python bytecode at a time.

A mechanism that allows multiple threads to execute Python bytecode simultaneously.

A mechanism that allows multiple processes to execute Python bytecode simultaneously.

A mechanism that prevents Python code from being executed on more than one processor at a time.


7. Which of the following is an example of a common use case for multiprocessing in Python?

Web scraping

GUI programming

Numerical computation

Database programming


8. Which of the following is an example of a parallel algorithm?

Merge sort

Bubble sort

Quick sort

Insertion sort


9. Which method is used to retrieve the result of a submitted task in Python?

result()

get()

retrieve()

fetch()


10. Which module is used to create and manage threads in Python?

threading

multiprocessing

concurrent.futures

asyncio