Skip to content
C

Parallel Square Calculation with Multiprocessing

Mediumpython

Use multiprocessing.Pool to calculate the squares of a list of numbers, splitting the work across 2 processes.

Approach: split the input list into two halves, submit both halves to a 2-worker Pool.map() call, then combine and print the results in original order.

Input: One line: space-separated integers.

Output: One line: every input number's square, in original order, as a Python list.

Input (stdin)

Output

Run your code to see output here...