Greetings!
Sleep is not allowed in the script, as you can see.
I suggest installing one of the official IBM Apps in the exchange, that come in with a "Timer" function you can directly add as an step in your workflow:
https://exchange.xforce.ibmcloud.com/hub?q=timer
For random time, in the function pre-process, you can generate a random time with python, just as you are doing in the script, and pass it to the function with "inputs.nameoftheinput = random.randrange(10)"
Hope this helps!
Cheers,
------------------------------
Pol Estecha Hernández
------------------------------