Averting shutdown by chance If the chance is 20%, the shutdown will fail! The chance of shutdown success is 70%.
from random import random def avetting_shutdown(chance): if 0 < random() < chance: return 'Shutdown successful!' else: return 'Shutdown failed!' avetting_shutdown(0.7)