1. Use the Self_Destruct.py from the previous activity. 2. Exception Handling (Try/Except) - Add Exception Handling to the Section of the script outlined in the supplied script (Lines 74 through 94)....

1 answer below »










1. Use the Self_Destruct.py from the previous activity.
2. Exception Handling (Try/Except) - Add Exception Handling to the Section of the script outlined in the supplied script (Lines 74 through 94).

####################################################################### # ADD EXCEPTION HANDLING TO THE FOLLOWING SECTION OF CODE             # # The user must enter a correct code in order to proceed with the     # # self destruct procedure.                                            # #                                                                     # # The script should force the user to enter a valid destruct code or  # # or offer the option to abort the Self Destruct request entirely.    # # Use the Exception Handling in the Section above as a reference.     # ####################################################################### initiate = input("Enter Self Destruct Confirmation Code: ")  # Compare Rank Codes if initiate == code:     print ("Self Destruct Initiate Code: ACCEPTED")     final_code = input("Enter Activation Code: ")      if final_code == authorized_final:         print ("Destruct Sequence Confirmed.")         # 5. EXPLAIN THE SIGNIFICANCE OF THE x         print (x, " seconds to Self Destruct.")         # A.         print ("ALL HANDS ABANDON SHIP - THIS IS NOT A DRILL")         countdown(x)         print ("Have a nice day!")         print ("BOOM!")     elif final_code == authorized_test:         print ("Destruct Sequence Test Order Confirmed.")         print ("THIS IS A DRILL - THIS IS A DRILL")         print ("Timer Set to: " + x + " seconds.")     else:         print ("Destruct Sequence Aborted.")

Answered 2 days AfterOct 11, 2021

Answer To: 1. Use the Self_Destruct.py from the previous activity. 2. Exception Handling (Try/Except) - Add...

Ketaki answered on Oct 13 2021
139 Votes
# 1. ADD PROPER HEADERS
#
#
###################################################################################################
import time
# Custom Functions
# 2. DESCRIBE HOW THE INC
LUDED countdown() FUNCTION WORKS
# A:
def countdown(n):
while n >= 0:
print (n)
time.sleep(1)
n -= 1
##################################################################################################
# Self Destruct Sequencer
# This is the custom function created to handle all of the Self Destruct
# features needed. There are a few steps involved in the process, so take a few
# moments to study how this function works and think about ways to make it better.
def self_destruct(x):
# Set Destruct Codes
authorized_test = "000-Destruct-0"
authorized_final = "000-Destruct-1"
# 3. CREATE VARIABLES (SIMILAR TO ABOVE) FOR THE COMMANDING OFFICER'S CODE (co_code)
# EXECUTIVE OFFICER'S CODE (xo_code) & CHIEF ENGINEER'S CODE (ce_code)
# Write your code here
##################################################################################################
# Consider the following print statements. Could they be combined into a single print
# statement and get the same result? (Answer: Yes) There are many ways to resolve
# issues in scripting. You get to decide what works best for your script.
# Display Self Destruct Warning
print ("--------------------- WARNING! ----------------------")
print ("You have initiated the USR ARES Self Destruct Program")
print ("_____________________________________________________")
print ("You must provide Authorized Initiate Code to Proceed.")
##################################################################################################
# Request Authorized Rank
# 4. EXPLAIN THE SIGNIFICANCE OF THE int() FUNCTION IN THE FOLLOWING LINE:
rank...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here