All Question of the MCQs Present Below for Ease Use Ctrl + F with the question name to find the Question. All the Best!
If you found answer for any of the questions is wrong. Please do mention in the comment section, could be useful for others. Thanks!
1.asyncio - Threads (Hands-On - Multithreading)
import threading
def square_it(n):
sq = n*n
print(sq)
def do_it(a,b):
a = threading.Thread(target = square_it,args=(a,))
b = threading.Thread(target = square_it,args=(b,))
a.start()
b.start()
2.asyncio - multiprocessing (Hands-On - Multiprocessing)
import multiprocessing
def calc_it(start, end):
s = 0
for i in range(start,end+1):
s = s+i
return s
def do_it(n):
s1 = 0
i = 0
while i<=n:
s1 = s1 + i
i = i + 1
return s1
3.asyncio - Basic asyncio program (Hands-On - asyncio coroutines)
import asyncio
async def question():
print("Is asyncio better for IO bound programs than the CPU bound ones?")
await asyncio.gather(answer())
print("Is async a keyword in the latest Python3?")
await asyncio.gather(answer())
print("Is event loop the heart of an asyncio program?")
await asyncio.gather(answer())
async def answer():
print("Yes, it is!")
asyncio.run(question())