Is there a way to take a string and use it as a command in Python?

Something similar to the example shown below.

```
x = "import time"

x

time.sleep(1)

```

I know the example above won't work, that is just to help you understand what I am trying to do.