Quick Quiz on Asynchronous Programming
1
Which of the following statements allow you to execute an asynchronous function myPrint(x)
once?
A)
import asyncio
async def myPrint(x):
print(x)
await asyncio.sleep(1)
return
loop = asyncio.get_event_loop()
results = loop.run_until_complete(myPrint(1))
loop.close()
B)
import asyncio
async def myPrint(x):
print(x)
await asyncio.sleep(1)
return
loop = asyncio.get_event_loop()
results = loop.run_until_complete(asyncio.gather(myPrint(1))
myPrint(2))
loop.close()
Question 1 of 20 attempted
Get hands-on with 1400+ tech skills courses.