Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help with python using spyder program Download and unzip the files in the V1PartialDecoder.zip file into your Current Folder. The decoder will implement 4
Need help with python using spyder program
Download and unzip the files in the V1PartialDecoder.zip file into your Current Folder. The decoder will implement 4 different rules to determine if the code is correct or not. In version 1 , you will implement Rules 1 and 2 and the partial implementation of Rule 3 and 4. Please use the provide lab2V1.py file to write your program. NOTE. Only Rules 1 and 2 may display an invalid message. When an invalid message is encountered, do not proceed with the remaining Rule checks. For example, if Rule 1 is invalid, do not check Rules 2,3 or 4. Rule 1. A valid code must be a 9-digit number. e.g. 123456789 , message MAY be valid e.g. 12345678 , message invalid e.g. 1234567890, message invalid If the code entered is invalid, display the message 'Decoy Message: Not a nine-digit number.' to the command window and terminate the program Rule 2. The code must pass the odd-even "truth" test. (Do not use any loops to do this) - If the sum of the digits is even, the message is invalid. e.g. 222222222 , sum =2+2+2+2+2+2+2+2+2=18, message invalid - If the sum of the digits is odd, the message MAY be valid. e.g. 222222223 , sum =2+2+2+2+2+2+2+2+3=19, message may be valid If the code entered is invalid, display the message 'Decoy Message: Sum is even.' to the command window and terminate the program Rule 3. Multiply the 3rd digit by the 2nd digit, then subtract the 1st digit. Display this number to the command window (Displaying the text 'day = ' is optional) Rule 4. Calculate the value of the 3rd digit to the power of the 2nd digit. Rule 4. Calculate the value of the 3rd digit to the power of the 2nd digit. - If the value is divisible by 3 , then subtract the 6 th digit - 5 th digit ENCMP 100 Computer Programming for Engineers - If the value is not divisible by 3 , then subtract the 5 th digit - 6th digit Display this number to the command console. (Displaying the text ' place = ' is optional) Test Case 112345678 Test Case 2123456788 Test Case 3123456789 Test Case 4732456789 The output for the test cases in the command window should match the images in the CommandOutputV1.pdf file that was unzipped. For further testing, go ahead and try other combinations. Test Case 112345678 Lab2 - Version 1 Please enter a code to break: 12345678 Decoy message: Not a nine-digit number. Test Case 2-123456788 Lab2 - Version 1 Please enter a code to break: 123456788 Decoy message: Sum is Even. Test Case 3123456789 Lab2 - Version 1 Please enter a code to break: 123456789 day =5 place =1 Test Case 4732456789 Lab2 - Version 1 Please enter a code to break: 732456789 day =1 place =1 Version 2: Full Decoder Download and unzip the files in the V2FullDecoder.zip file into your Current Folder. Modify/Add to your Version 1 code for full implementation of Rule 3 and 4. Rule 3. To determine the rescue day, multiply the 3rd digit by the 2nd digit, then subtract the 1st digit. The answer indicates the rescue day, as follows: 1=Monday4=Thursday2=Tuesday5=Friday3=Wednesday6=Saturday7=Sunday Any other number indicates that the message is invalid. Examples: 233407789332=7 Rescue is on Sunday 732456789237=1 Message is invalid. Rule 4. To determine the rendezvous point, calculate the value of the 3rd digit to the power of the 2nd digit - If the number is divisible by 3 , then the rendezvous point is 6 th digit - 5 th digit - If the number is not is divisible by 3 , then the rendezvous point is 5 th digit - 6th digit If the result is one of the following rendezvous numbers, the message is valid: Any other rendezvous number means that the message is invalid. The output for invalid messages should indicate only the first reason encountered for rejecting the message. The reasons are one of the following, in this order: - Decoy Message: Not a nine-digit number. - Decoy Message: Sum is even. - Decoy Message: Invalid rescue day. - Decoy Message: Invalid rendezvous point. Note - Multiple invalid messages displayed to the command window is incorrect. If the code successfully passes all 4 rules, please display a message to the command console indicating both the rescue date and rendezvous point on a single line. Please use the print() instruction to accomplish this. Test Case 1233407789 Lab 2 - Version 2 Please enter a code to break: 233407789 Rescued on Sunday at the rail station Test Case 2732456789 Lab 2 - Version 2 Please enter a code to break: 732456789 Decoy message: Invalid rescue day. Test Case 312345678 Lab 2 - Version 2 Please enter a code to break: 12345678 Decoy message: Not a nine-digit number. Test Case 4123456788 Lab 2 - Version 2 Please enter a code to break: 123456788 Decoy message: Sum is even. Test Case 5724120779 Lab 2 - Version 2 Please enter a code to break: 724120779 Rescued on Monday at the library Test Case 6-115984236 Lab 2 - Version 2 Please enter a code to break: 115984236 Rescued on Thursday at the airport Test Case 7-643158994 Lab 2 - Version 2 Please enter a code to break: 643158994 Rescued on Saturday at the river crossing Test Case 8132456789 Lab 2 - Version 2 Please enter a code to break: 132456789 Decoy message: Invalid rendezvous pointStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started