<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 The simplest native coroutine demo
(that I could imagine)
Step1:  The driving code starts here
Step2:  A slightly more interesting demo
Now the generator-coroutine yields 3 times.
Step3:  Driving code
Step4:  A generator-coroutine that receives values
The driving code can send values other than None.
Step5:  Driving code must prime the coroutine by sending None initially
Step6:  To retrieve the last result, we must catch StopIteration and get its value attribute
<ASSISTANT_TASK:>
Python Code:
import types
@types.coroutine
def gen():
    yield 42
async def delegating():
    await gen()
Explanation: The simplest native coroutine demo
(that I could imagine)
End of explanation
coro = delegating()
coro
coro.send(None)
# coro.send(None)  # --> StopIteration
Explanation: The driving code starts here:
End of explanation
@types.coroutine
def gen123():
    return (i for i in range(1, 4))
async def delegating():
    await gen123()
Explanation: A slightly more interesting demo
Now the generator-coroutine yields 3 times.
End of explanation
coro = delegating()
coro.send(None)
coro.send(None)
coro.send(None)
# coro.send(None)  # --> StopIteration
# coro.send(None)  # --> RuntimeError
Explanation: Driving code:
End of explanation
import types
@types.coroutine
def times10(terms):
    n = yield 'Ready to begin!'
    for _ in range(terms):
        n = yield n * 10
    return n * 10
async def delegating(terms):
    res = await times10(terms)
    return res
Explanation: A generator-coroutine that receives values
The driving code can send values other than None.
End of explanation
coro = delegating(3)
coro.send(None)
coro.send(5)
coro.send(6)
coro.send(7)
Explanation: Driving code must prime the coroutine by sending None initially:
End of explanation
try:
    coro.send(8)
except StopIteration as e:
    res = e.value
res
Explanation: To retrieve the last result, we must catch StopIteration and get its value attribute:
End of explanation
<END_TASK>