Download our latest MNC Answers Application at Play Store. Download Now

Python Asynchronous Programming Handson Solutions TCS Fresco Play

Python Asynchronous Programming Handson Solutions TCS Fresco Play


Disclaimer: The primary purpose of providing this solution is to assist and support anyone who are unable to complete these courses due to a technical issue or a lack of expertise. This website's information or data are solely for the purpose of knowledge and education.

Make an effort to understand these solutions and apply them to your Hands-On difficulties.

 (It is not advisable that copy and paste these solutions).
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!

-----------------

Course Path: Data Science/DATA SCIENTIST'S TOOLBOX/Python Asynchronous Programming

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())