NEW
Font size
S
M
L
XL
WorksheetsStib Quizz Asyncio
Total questions: 30
Worksheet time: 15mins
Name
Class
Date
1.
What is the main problem with synchronous code?
a)
CPU works on many tasks
b)
CPU waits idly during I/O
c)
Multiple threads run at once
d)
Memory overflows
2.
In IoT systems, synchronous execution is
a)
Faster
b)
Sequential and slow
c)
Always parallel
d)
Recommended
3.
The solution to idle CPU time is
a)
Using multiprocessing
b)
Asynchronous programming
c)
Multithreading only
d)
Larger buffers
4.
The main idea of async programming is to
a)
Execute tasks sequentially
b)
Execute multiple tasks concurrently
c)
Pause all tasks
d)
Restart CPU cycles
5.
A coroutine in Python is
a)
A normal function
b)
A function defined with async def
c)
A class
d)
A variable
6.
Calling an async function directly returns
a)
The result
b)
A coroutine object
c)
A thread
d)
A list
7.
A coroutine starts execution only when
a)
It’s called normally
b)
It’s awaited or scheduled
c)
It’s defined
d)
The script ends
8.
The keyword await is used to
a)
Run tasks faster
b)
Pause execution until completion
c)
Cancel the event loop
d)
Exit the coroutine
9.
await can only be used
a)
Inside async def functions
b)
Inside normal def functions
c)
Outside any function
d)
In loops only
10.
The asyncio.run() function
a)
Starts the event loop
b)
Creates a coroutine
c)
Ends all tasks
d)
Blocks code
11.
The event loop is
a)
A database
b)
The scheduler managing async tasks
c)
A decorator
d)
A blocking call
12.
The event loop manages
a)
Threads
b)
Coroutines and tasks
c)
CPU-bound code only
d)
None
13.
Asyncio is most efficient for
a)
CPU-heavy tasks
b)
I/O-bound tasks
c)
Static code
d)
Math operations
14.
When a coroutine hits await, the event loop
a)
Waits idly
b)
Switches to another task
c)
Stops
d)
Throws an exception
15.
Async code in Python runs
a)
On multiple threads by default
b)
In a single thread managing many tasks
c)
In parallel hardware cores
d)
Sequentially
16.
The function asyncio.gather()
a)
Runs coroutines one by one
b)
Runs multiple coroutines and waits for all
c)
Cancels all tasks
d)
Creates new threads
17.
You use asyncio.gather() when
a)
You need all results
b)
You need only one result
c)
You want sequential execution
d)
You want to block tasks
18.
The function asyncio.create_task()
a)
Creates a thread
b)
Wraps a coroutine as a task to run concurrently
c)
Blocks execution
d)
Deletes running tasks
19.
The main difference between create_task and gather is
a)
One runs sequentially
b)
One schedules tasks with more control
c)
Both block the loop
d)
None
20.
The function asyncio.sleep()
a)
Pauses all threads
b)
Simulates an async wait
c)
Blocks CPU
d)
Ends all tasks
21.
In an IoT async example, multiple sensors
a)
Start and finish sequentially
b)
Start together and finish at different times
c)
Run on different CPUs
d)
Block each other
22.
The total async execution time for 5 sensors (0.5–2s each) is around
a)
10 seconds
b)
5 seconds
c)
2 seconds
d)
20 seconds
23.
The asyncio.wait_for() function
a)
Repeats coroutines
b)
Sets a timeout for async operations
c)
Sleeps indefinitely
d)
Cancels all tasks
24.
A hanging sensor in async code is handled by
a)
Retry loops
b)
asyncio.wait_for()
c)
Multithreading
d)
await sleep
25.
Error handling in async code should
a)
Stop all tasks on exception
b)
Gracefully isolate and continue
c)
Restart all coroutines
d)
Ignore exceptions
26.
Continuous monitoring in asyncio means
a)
Running coroutines forever
b)
Running until timeout
c)
Running once
d)
Looping synchronously
27.
Continuous async loops are ideal for
a)
Interactive UIs
b)
Continuous IoT monitoring
c)
One-time tasks
d)
Debugging
28.
The main benefit of asyncio is
a)
Parallel CPU performance
b)
Efficient concurrency for I/O tasks
c)
Memory compression
d)
Code simplification
29.
The rule “cannot use await outside async def” means
a)
await is global
b)
await is valid only in async functions
c)
await runs threads
d)
await defines loops
30.
In async systems, failure of one task
a)
Stops all others
b)
Can be isolated while others continue
c)
Reboots the loop
d)
Corrupts memory
Reset
