from mpi4py • import • MPla
-MPl .COMM WORLDC
comm
rank-comm. Get _ rank(
size-comm
n=int( input( "Enter the size of the
list " )
print( "Enter the - list - members" ) a
•forÄÄn•
s-int( input( ) F
I . append( s) c
• add=Oc
•forÄÄnA•.c
add-add* ic
print("The addition •of' the• list •
elements •are• •
, add)ü
• comm . send(l , dest=l
• comm . send(l , dest-2)a
elif• : a
add even=Oo
• I-comm. recv(
•forÄÄn 1: c
add even-add even+ia
from, the process-2 , the
addition • of • all • even • numbers , im the
list
•add odd-On
l=comm. recv(
forÄÄn I : a
if i%2--1:
•add odd-add odd+in
from&eorocess-3, •the
addition •of • all • odd • numbers • in the •
list