Quiz 1

Test what you have learnt so far.

Question # 1

Consider the below snippet:

def thread_task():
    print("{0} executing".format(current_thread().getName()))


myThread = Thread(group=None,  # reserved
                  target=thread_task(),
                  name="childThread")

myThread.start()
myThread.join()

Q

What will be the output of the above snippet?

A)

MainThread executing

B)

childThread executing

C)

Runtime Error occurs

Press + to interact
from threading import Thread
from threading import current_thread
def thread_task():
print("{0} executing".format(current_thread().getName()))
myThread = Thread(group=None, # reserved
target=thread_task(),
name="childThread")
myThread.start()
myThread.join()

Question

...

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.