Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

priceyearOfReg gearbox modelkilometer fuelType brand 480 1993 manuell golf 15000

ID: 3591994 • Letter: P

Question

priceyearOfReg gearbox modelkilometer fuelType brand 480 1993 manuell golf 150000 benzin volkswagen 125000 diesel audi 125000 diesel jeep 150000 benzin volkswagen 18300 2011 manuell 9800 2004 automatik grand 1500 2001 manuel golf 3600 2008 manuell fabia Apply MapReduce to find number of cars in each brand? Total priceforeach brand? oldest car in each brand? 90000 diesel skoda 150000 benzin bmw 650 1995 manuell 3er 2200 2004 manuell 2_reihe 150000 benzin peugeot 40000 benzin volkswagen 0000 benzin ford 0 1980 manuell andere 45002014 manuell cmax 999 1998 manuell golf 2000 2004 manuell 3_reihe 150000 benzin mazda 150000 diesel volkswagen 2799 2005 manuell passat 150000 diesel volkswagen 999 1995 manuell passat 150000 benzin volkswagen 2500 2004 manuell passat 150000 diesel volkswagen 70000 diesel nissan 5000 benzin ford 17999 2011 manuell navara 450 1910 150000 benzin volkswagen 300 2016 17502004 automatik twingo150000 benzin renault 7550 2007 manuell c max 1850 2004 manuell a klasse 150000 benzin mercedes benz 150000 diesel ford 04002009 manuell scirocco 100000 benzinvolkswagen 36992002 automatik Ser 2900 150000 benzin bmw 50000 benzin opel 150000 benzin seat 2018 manuell meriva 50 1997 manuell arosa

Explanation / Answer

A utilities.py module will be provided to you that performs the basic file storage and retrieval.

The import statement must be used in your application to access the code in this module. So

you should put the following statement at the beginning of the code:

from utilities import store, retrieve

You must create a menu in the main() function that will provide the user several options as

shown below:

=== Simple Encryption ===

1) Encrypt

2) Decrypt

3) Exit

Enter option ==>

Initially, the user will choose Option 1, which will then cause a function named encrypt to be

executed. The encrypted function takes a cipher key and a message from the user. The

pseudocode for this function is as follows:

Encrypt:

Clear screen

Get cipher key (assume user enters integer when prompted for key request)

Check that value entered is between 0 and 127 inclusive

Convert integer cipher key to binary string and strip off "0b"

Check for 7-character length (and pad beginning with zeros if necessary)

Get message to be encrypted from standard input

Initialize encrypted message string to an empty string

Perform XOR operation on each binary bit of cipher key and message

o Get integer ascii value of each character in message

o Get binary value of ascii version of character and strip off "0b"

o Check for 7-character length (pad beginning with zeros if necessary)

o Perform XOR operation & append binary 7-bit result to encrypted string

Convert each binary bit of message character and key to an integer

Perform XOR operation on these two bits

Convert literal True and False to binary bit & append to output

Store encrypted message in file

This algorithm should be followed precisely. There is a built-in XOR operator, but this

operator cannot be used for this assignment. The purpose of the assignment is to gain

proficiency using control structures and conditional expression. The subsitution for the XOR

operation will be demonstrated during the lecture time.

The code requires clearing the screen using the os module. Clearing screen commands can

be different depending on the operating system. The following branching structure needs to

be placed in the main() function.

global clear_cmd

if os.name == "posix":

clear_cmd = "clear"

elif os.name == "nt":

clear_cmd = "cls"

else:

print "*** Unsupported System *** Application Terminating !!!"

option = "3"

The following function call can then be used in any function in your application where the

screen needs to be cleared:

# Clear screen

os.system(clear_cmd)

Once the user has encrypted the message, and it is stored in the data file, the user can then

select Option 2, which will then cause a function named decrypt to be executed. The

pseudocode for this function is as follows:

Decrypt:

Clear screen

Get cipher key (assume user enters integer when prompted for key request)

Check that value entered is between 0 and 127 inclusive

Convert cipher key to binary string and strip off "0b"

Check for 7-character length (pad beginning with zeros if necessary)

Get message to be encrypted from file

Initialize decrypted message string to an empty string

Perform XOR operation on each character of cipher key and message

o Initialize decrypted_bin_char string to an empty string

o Slice out each successive 7-bit portion of encrypted message

o Perform XOR operation and append binary result to decrypted string

Convert each binary bit of message character and key to an integer

Perform XOR operation on these two bits

Convert literal True and False to binary bit & append to output

o Append "0b" of decrypted_bin_char and get ASCII integer value

o Convert ASCII integer value to character

o Append character to decrypted message string

Clear screen

Print decrypted message to standard output

Pause screen clearing