MCQs > IT & Programming > Python > Correct answer from the given options. import multiprocessing def enr(conn, msgs): for msg in msgs: conn.send(msg) print('{}'.format(msg)) conn.close() def cer(conn): while 1: msg = conn.recv() if msg == 'Hi': break print('{}'.format(msg)) if __name__ == '__main__': msgs = ['hello', 'hey', 'hru?', 'Hi'] parent_conn, child_conn = multiprocessing.Pipe() p1 = multiprocessing.Process(target=enr, args=(parent_conn,msgs)) p2 = multiprocessing.Process(target=cer, args=(child_conn,)) p1.start() p2.start() p1.join() p2.join()

Python MCQs

Find the output of the following Python code and choose the correct answer from the given options.

import multiprocessing

def enr(conn, msgs):

for msg in msgs:

    conn.send(msg)

    print("{}".format(msg))

conn.close()

def cer(conn):

while 1:

    msg = conn.recv()

    if msg == "Hi":

        break

    print("{}".format(msg))

if __name__ == "__main__":

msgs = ["hello", "hey", "hru?", "Hi"]

parent_conn, child_conn = multiprocessing.Pipe()

p1 = multiprocessing.Process(target=enr, args=(parent_conn,msgs))

p2 = multiprocessing.Process(target=cer, args=(child_conn,))

p1.start()

p2.start()

p1.join()

p2.join()


Answer

Correct Answer:

hello

hey

hru?

Hi

hello

hey

Hru? 


Explanation:

Note: This Question is unanswered, help us to find answer for this one

Python Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

More Python MCQ Questions

search

Python Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it