In this problem you will design an electronic safe program w

In this problem you will design an electronic safe program where the secret combination is entered series of signals. When the correct sequences of signals is received, it should print \"You know the secret code!\" The secret code is SIGSTOP, SIGTERM, SIGSTOP, SIGHUP. After the program receives those signals, in that order, it should print the message.

Solution

# This is done in python 3.5

signal = input(\"Enter code:\")                       # get the user input
l = signal.split(\",\")                               # split the string based on ,
try:                                               # if the signal does not have four parts exception will occur
   if(l[0] == l[2] == \"SIGSTOP\" and l[1] == \"SIGTERM\" and l[3] == \"SIGHUP\"):   # check condition
       print(\"You know the secret code!\")
   else:
       print(\"You don\'t know the secret code\")
except:
   print(\"You don\'t know the secret code\")

# sample output

#Enter code: SIGSTOP,SIGTERM

#You don\'t know the secret code

#Enter code: SIGSTOP,SIGTERM,SIGSTOP,SIGHUP

#You know the secret code!

 In this problem you will design an electronic safe program where the secret combination is entered series of signals. When the correct sequences of signals is

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site