The documentation for asyncio gives two examples for how to print \"Hello World\" every two seconds: https://docs.python.org/3/library/asyncio-eventloop.html#asyncio-hello-w
With Python 3.8, you can use the new asyncio REPL.
$ python -m asyncio
>>> async def greet_every_two_seconds():
... while True:
... print('Hello World')
... await asyncio.sleep(2)
...
>>> # run in main thread (Ctrl+C to cancel)
>>> await greet_every_two_seconds()
...
>>> # run in background
>>> asyncio.create_task(greet_every_two_seconds())