- Which module is used for multithreading in Python?
View Answer
Correct answer: A — threading
- What will be printed?
1 python 2 import threading 3 print(hasattr(threading,"Thread")) View Answer
Correct answer: A — True
- Which method starts a thread?
View Answer
Correct answer: A — start()
- What is the output of below code?
1 python 2 import threading 3 def show(): 4 print("Eduinq") 5 t = threading.Thread(target=show) 6 t.start() View Answer
Correct answer: A — Eduinq
- Which method waits for thread completion?
View Answer
Correct answer: A — join()
- What will be printed?
1 python 2 import threading 3 def show(): 4 print("Eduinq") 5 t = threading.Thread(target=show) 6 t.start() 7 t.join() 8 print("Done") View Answer
Correct answer: A — Eduinq Done
- Which of the following is used for synchronization?
View Answer
Correct answer: D — All of the above
- What is the output of below code?
1 python 2 import threading 3 lock = threading.Lock() 4 print(isinstance(lock,threading.Lock)) View Answer
Correct answer: A — False
- Which of the following is used for multiprocessing in Python?
View Answer
Correct answer: A — multiprocessing
- What will be printed?
1 python 2 import multiprocessing 3 print(hasattr(multiprocessing,"Process")) View Answer
Correct answer: A — True
- Which method starts a process?
View Answer
Correct answer: A — start()
- What is the output of below code?
1 python 2 import multiprocessing 3 def show(): 4 print("Eduinq") 5 p = multiprocessing.Process(target=show) 6 p.start() 7 p.join() View Answer
Correct answer: A — Eduinq
- Which of the following is used for inter process communication?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 python 2 import multiprocessing 3 q = multiprocessing.Queue() 4 q.put("Eduinq") 5 print(q.get()) View Answer
Correct answer: A — Eduinq
- Which of the following is used for shared memory?
View Answer
Correct answer: D — All of the above
- What is the output of below code?
1 python 2 import multiprocessing 3 val = multiprocessing.Value('i',10) 4 print(val.value) View Answer
Correct answer: A — 10
- Which of the following is used for process pool?
View Answer
Correct answer: A — Pool
- What will be printed?
1 python 2 import multiprocessing 3 pool = multiprocessing.Pool(processes=2) 4 print(hasattr(pool,"map")) View Answer
Correct answer: A — True
- Which of the following is used for concurrent futures?
View Answer
Correct answer: A — concurrent.futures
- What is the output of below code?
1 python 2 from concurrent.futures import ThreadPoolExecutor 3 with ThreadPoolExecutor(max_workers=2) as ex: 4 f = ex.submit(lambda: "Eduinq") 5 print(f.result()) View Answer
Correct answer: A — Eduinq
- Which of the following is used to create a thread subclass?
View Answer
Correct answer: A — threading.Thread
- What will be printed?
1 python 2 import threading 3 class MyThread(threading.Thread): 4 def run(self): 5 print("Eduinq Thread") 6 t = MyThread() 7 t.start() View Answer
Correct answer: A — Eduinq Thread
- Which of the following is used to create a process subclass?
View Answer
Correct answer: A — multiprocessing.Process
- What is the output of below code?
1 python 2 import multiprocessing 3 class MyProcess(multiprocessing.Process): 4 def run(self): 5 print("Eduinq Process") 6 p = MyProcess() 7 p.start() 8 p.join() View Answer
Correct answer: A — Eduinq Process
- Which of the following is used for thread synchronization?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 python 2 import threading 3 event = threading.Event() 4 event.set() 5 print(event.is_set()) View Answer
Correct answer: A — True
- Which of the following is used for process synchronization?
View Answer
Correct answer: D — All of the above
- What is the output of below code?
1 python 2 import multiprocessing 3 lock = multiprocessing.Lock() 4 print(isinstance(lock,multiprocessing.Lock)) View Answer
Correct answer: A — False
- Which of the following is used for thread communication?
View Answer
Correct answer: A — Queue.Queue
- What will be printed?
1 python 2 import queue 3 q = queue.Queue() 4 q.put("Eduinq") 5 print(q.get()) View Answer
Correct answer: A — Eduinq
- Which of the following is used for process communication?
View Answer
Correct answer: A — multiprocessing.Queue
- What is the output of below code?
1 python 2 import multiprocessing 3 q = multiprocessing.Queue() 4 q.put(5) 5 print(q.get()) View Answer
Correct answer: A — 5
- Which of the following is used for thread pool?
View Answer
Correct answer: A — concurrent.futures.ThreadPoolExecutor
- What will be printed?
1 python 2 from concurrent.futures import ThreadPoolExecutor 3 with ThreadPoolExecutor(max_workers=2) as ex: 4 f = ex.submit(lambda: "Eduinq") 5 print(f.result()) View Answer
Correct answer: A — Eduinq
- Which of the following is used for process pool?
View Answer
Correct answer: C — Both A and B
- What is the output of below code?
1 python 2 from concurrent.futures import ProcessPoolExecutor 3 with ProcessPoolExecutor(max_workers=2) as ex: 4 f = ex.submit(lambda: 5*5) 5 print(f.result()) View Answer
Correct answer: A — 25
- Which of the following is used to get current thread?
View Answer
Correct answer: A — threading.current_thread()
- What will be printed?
1 python 2 import threading 3 print(threading.current_thread().name) View Answer
Correct answer: A — MainThread
- Which of the following is used to get current process?
View Answer
Correct answer: A — multiprocessing.current_process()
- What is the output of below code?
1 python 2 import multiprocessing 3 print(multiprocessing.current_process().name) View Answer
Correct answer: A — MainProcess
- Which of the following is used to get active thread count?
View Answer
Correct answer: A — threading.active_count()
- What will be printed?
1 python 2 import threading 3 print(threading.active_count()>=1) View Answer
Correct answer: A — True
- Which of the following is used to get active children processes?
View Answer
Correct answer: A — multiprocessing.active_children()
- What is the output of below code?
1 python 2 import multiprocessing 3 print(type(multiprocessing.active_children())) View Answer
Correct answer: A — list
- Which of the following is used to set daemon thread?
View Answer
Correct answer: C — Both A and B
- What will be printed?
1 python 2 import threading 3 t = threading.Thread(target=lambda:None) 4 t.daemon=True 5 print(t.isDaemon()) View Answer
Correct answer: A — True
- Which of the following is used to set daemon process?
View Answer
Correct answer: A — p.daemon=True
- What is the output of below code?
1 python 2 import multiprocessing 3 p = multiprocessing.Process(target=lambda:None) 4 p.daemon=True 5 print(p.daemon) View Answer
Correct answer: A — True
- Which of the following is used to terminate a process?
View Answer
Correct answer: A — terminate()
- What will be printed?
1 python 2 import multiprocessing 3 p = multiprocessing.Process(target=lambda:None) 4 p.start() 5 p.terminate() 6 print(p.exitcode is not None) View Answer
Correct answer: A — True