Hello World

Exercise 1

./code/hello_world/ex1.py
1import asyncio
2
3
4async def hello():
5    print("hello world")
6
7
8asyncio.run(hello())

Exercise 2

./code/hello_world/ex2.py
 1import asyncio
 2import time
 3
 4
 5loop = asyncio.get_event_loop()
 6
 7
 8@asyncio.coroutine
 9def hello():
10    print(f"hello {time.strftime('%X')}")
11    yield from asyncio.sleep(1)
12    print(f"world {time.strftime('%X')}")
13
14
15if __name__ == "__main__":
16    loop.run_until_complete(hello())