Question: QUESTION 1 How much time will the following program take to complete? import asyncio import time async def count(t): await asyncio.sleep(t) print(Hello) async def main():

 QUESTION 1 How much time will the following program take tocomplete? import asyncio import time async def count(t): await asyncio.sleep(t) print("Hello") asyncdef main(): await asyncio.gather(count(1), count(2), count(3)) if I name main s =time.perf_counter() asyncio.run(main()) elapsed = time.perf_counter() - S print(f"{file_} executed in {elapsed:0.2f} seconds.")O 1 sec O 2 sec O 3 sec 0 6 secQUESTION 3 How much time will the following program take to complete?

QUESTION 1 How much time will the following program take to complete? import asyncio import time async def count(t): await asyncio.sleep(t) print("Hello") async def main(): await asyncio.gather(count(1), count(2), count(3)) if I name main s = time.perf_counter() asyncio.run(main()) elapsed = time.perf_counter() - S print(f"{file_} executed in {elapsed:0.2f} seconds.") O 1 sec O 2 sec O 3 sec 0 6 sec QUESTION 3 How much time will the following program take to complete? import time def count(t): time. sleep(t) print("Hello") def main(): count(1) count(2) count(3) if name main s = time.perf_counter() main() elapsed = time.perf_counter() - 5 print(f"{file_} executed in {elapsed:0.2f} seconds.") O 1 sec O2 sec O 3 sec O 6 sec print(f"{file_} executed in {elapsed:0.2f} seconds.") O 1 sec O2 sec 3 sec O 6 sec QUESTION 4 Provide a brief explanation for your answer to Q3 T T T Arial 3 (12pt) T- Path: P Words:0 QUESTION 5 Take a look at the function mFunc defined below: def mFunc(): asyncio.sleep (3) print('I am awake') Will happen if you call mFunc() from your main function? Program will print 'I am awake' after 3 sec Program will throw the following exception or warning: coroutine 'sleep' was never awaited Program will print 'I am awake' without waiting for 3 sec Program will not execute and generate a syntax error. QUESTION 6 Take a look at the function mFunc() with pseudo-code given below: def mFunc(t, name) : print name sleep for time = t seconds print name finished Write down a program that uses the asyncio package to run mFunc as 3 concurrent coroutines with the following arguments: 1. mFunc(1, 'task-1') 2. mFunc (2, 'task-2') 3. mFunc(1, 'task-3') Your program should print out its total run time after it completes. Arial 3 (12pt) T- Path:p Words:0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!