Hands-On - Python - Coroutines
Hands-On - Python - Coroutines
def coroutine_decorator(coroutine_func):
def start(*args, **kwargs):
cr = coroutine_func(*args, **kwargs)
next(cr)
return cr
return start
# Define the coroutine function 'linear_equation' below
@coroutine_decorator
def linear_equation(a, b):
while True:
x=yield
s=a*(x**2)+b
print("Expression, {}*x^2 + {}, with x being 6.0 equals {}".format(a,b,s))
def main(x):
n = numberParser()
n.send(x)