Try to understand these solutions and solve your Hands-On problems. (Not encourage copy and paste these solutions)
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())
- List of Fresco Play Courses without Hands-On | Fresco Play
- HMTL5 Semantics Elements MCQs Answers | Fresco Play
- HMTL5 Semantics Elements Hands-On Solutions | Fresco Play
- Styling with CSS3 Hands-On Solutions | Fresco Play
- Blockchain Intermedio MCQs Answers | Fresco Play
- Blockchain - Potentes Nexus MCQs Answers | Fresco Play
- Azure Essentials MCQs Answers | Fresco Play
- AWS Essentials MCQs Answers | Fresco Play
Post a Comment
Any comments and suggestion will be appreciated.