Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective This assignment is designed to provide you with practice using selection statements to solve an encoding problem. Description Your friend Maverick recently landed a

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Objective This assignment is designed to provide you with practice using selection statements to solve an encoding problem. Description Your friend Maverick recently landed a lucrative engineering co-op work term in an oil-rich country. Meanwhile, you chose to make a modest salary as a co-op intern with the Canadian Security intelligence Service (CSIS). A week after arriving in the foreign country, Maverick is kidnapped by rebels opposed to oil exploration. He is held captive in a small village within rebel territory. Luckily, a group of disenchanted rebels are willing to smuggle Maverick to one of seven rendezvous points: - the village bridge - the village library - river crossing - nearby airport - bus terminal - hospital - railway station where an allied helicopter will pick them up and fly them to safety. For the plan to work, the friendly rebels need to know two pieces of information: - the day of the rendezvous - the rendezvous point. CSIS has devised a nine-digit code to carry this information to the friendly rebels. When the time is ripe, CSIS will insert a coded message into the online newspaper of the oil-rich country, as a number on the front page. The rebels have internet access via satellite links and follow the news. While it is helpful (as a decoy strategy) that the newspaper has other numbers on the front page, e.g. in real adverts, it is vital that the rebel insiders can detect and decode the secret message. CSIS has found a way to smuggle a decoder to the friendly rebels. You are asked to program the decoder in Python. The safety of your friend Maverick depends on your ability to program the decoder correctly. Version 0: Getting Started Download and unzip the files in the VoGetStarted.zip file into your Current Folder. Open the lab2vo.py file in the Editor Window and inspect it before running it. The program will prompt the user to enter a code to break. Try the following input The output for the test case in the command console should match the image in the CommandOutputvo. pdf file that was unzipped. For further testing, go ahead and try other combinations. Version 1: Partial Decoder 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. 2222222222 , 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. 2222222223 , 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 3t digit by the 2nit digit, then subtract the 1n1 digit. Display this number to the command window (Displaying the text 'day = ' is optional) Rule 4. Calculate the value of the 3st digit to the power of the 22i 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 - 6 th 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 4-732456789 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. import numpy as np print('Version 1r ) * -n-m-.-studentg write/modify their code below here code = input ('please enter a code to break: ') code = np.array ( list (code), dtype=int) print ("The code entered is " \& code) 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 3 - 123456789 Lab2 - Version 1 Please enter a code to break: 123456789 day =5 place =1 Test Case 4 - 732456789 Lab2 - Version 1 Please enter a code to break: 732456789 day =1 place =1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

denigration of emotional outbursts; being reserved;

Answered: 1 week ago