logo Hurry, Grab up to 30% discount on the entire course
Order Now logo
595 Times Downloaded

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Chris BarrieComputer science
(5/5)

611 Answers

Hire Me
expert
Thomas BornholdttEnglish
(5/5)

969 Answers

Hire Me
expert
Abhishek WadhwaEngineering
(5/5)

562 Answers

Hire Me
expert
Marius BantockGeneral article writing
(4/5)

634 Answers

Hire Me
Others
(5/5)

Create a Python program called Encryption.py that generates and prints two lists

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Encryption:   Create a Python program called Encryption.py that generates and prints two lists: 1. An ordered list of the alphabet, and 2. An encrypted (shuffled) list of the alphabet. You can use “from random import randrange” to generate random indexes for shuffling the alphabet letters. Your program will ask the end user to enter an E to encrypt a string, D to decrypt a string, or X to exit looping.  The user enters a string (only characters A-Z and blanks) and the program strips any leading or trailing blanks, flips the string to upper case, and performs the encryption, decryption or program exit shown below.  To organize your program, you can use the user-defined functions listed below.  The built in functions that you can use to validate your data and convert datatypes are: chr(), ord(), and str().  The string methods you can use are upper(), strip(), and for lists you can use the index() method.  When complete, please rename your program to “Your name Lab08.py” and send it to me as an attachment in a Blackboard message.

  

User-defined function headers are:

createAlphabetList() creates and returns the alphabet list    

createEncryptedList() creates and returns the encrypted list

printAlphabetList() void function prints the alphabet list

printEncryptedList() void function prints the encrypted list

encrypt(string) encrypts the inputted string and returns the encrypted string

decrypt(string) decrypts the inputted string and returns the decrypted string

 

Sample run:

Alphabet:   A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 

Encrypted:  J Z L F I H T D B Q O R C S N E V K A Y U P X W M G 

 

Enter 'E' to encrypt, 'D' to decrypt, or 'X' to exit: e

Enter a string to encrypt: Hello

HELLO encrypted is DIRRN

 

Enter 'E' to encrypt, 'D' to decrypt, or 'X' to exit: d

Enter a string to decrypt: dirrn

DIRRN decrypted is HELLO

 

Enter 'E' to encrypt, 'D' to decrypt, or 'X' to exit: e

Enter a string to encrypt: Programming is fun

PROGRAMMING IS FUN encrypted is EKNTKJCCBST BA HUS

 

Enter 'E' to encrypt, 'D' to decrypt, or 'X' to exit: d

Enter a string to decrypt: EKNTKJCCBST BA HUS

EKNTKJCCBST BA HUS decrypted is PROGRAMMING IS FUN

 

Enter 'E' to encrypt, 'D' to decrypt, or 'X' to exit: x

Thank you.  Goodbye.

 

 

 

Main Algorithm:

Call createAlphabetList() - creates the alphabet list

Call createEncryptedList() - create the encrypted list

Call printAlphabetList() - print the alphabet list spaced out

Call printEncryptedList() - print this lined up underneath the alphabet list

Using a while loop, flip choice to upper case

    validate E to encrypt, D to decrypt, or X to exit 

Using a while loop

    if E, then call encrypt(string)

    if D, then call decrypt(string)

    if X, then issue break to exit loop

    get next choice

    flip choice to upper case

print “Thank you.  Goodbye”

 

User-defined functions algorithms:

createAlphabetList()

o create a list for A-Z alphabet

o use a for loop

o start with 65 (A) and loop to 90 (Z) 

o return alphabet list    

createEncryptedList()

o create a list for shuffled (encrypted) alphabet

o use a for loop and randrange(0,26) to shuffle the letters 

o return encrypted (shuffled) list

printAlphabetList()

o use a for loop to print the alphabet list – use chr() to convert to character

printEncryptedList()

o use a for loop to print the encrypted list –use chr() to convert to character

encrypt(string)

o Initialize string to null string

o use a for loop to build the encrypted string – 

o if character is not equal to “ “, then use chr() and ord()

o    else assign “ “ to encrypted character

o return encrypted string

decrypt(string)

o Initialize string to null string

o use a for loop to build the decrypted string 

o if character is not equal to “ “, then use chr(), index(), and ord()

o    else assign “ “ to decrypted character 

o return decrypted string

 

 

(5/5)
Attachments:

Expert's Answer

595 Times Downloaded

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme