By chance, override shutdown. If the chance is 20%, the override shutdown will fail! Overriding the shutdown will succeed if the chance is 70%!
import random def override_shutdown(chance): if chance > random.random(): print("Shutdown overridden!") return True else: print("Shutdown failed!") return False override_shutdown(0.3)