''create three lists called(letters, Encoded, encryptedLettersNum)''' letters=[] Encoded=[] encryptedLettersNum=[]   '''Create a String variables called(EncodedMessage) that will contain message after the encryption''' EncodedMessage='' theAlphabetSmall='a'   '''create a for loop that add every element in theAlphabetSmall list to the letters list'''  for i in range(0,26):     letters.append(theAlphabetSmall)     theAlphabetSmall=chr(ord(theAlphabetSmall)+1)   '''print a question that tell the user to enter the message and save it in the message variable''' message=input ("Enter your message:\n")   '''create a for loop that add every character in the message variable to the letters list and add the index+1 to the encryptionLettersNum list'''  for i in range(len (message)):     index=letters.index(message[i])     encryptedLettersNum.append(index+1)   '''create a for loop in for loop that start from pointer +1 and end in the last character in the messag varible''' for i in range(len (message)):     for j in range(i+1,len (message)):         ''' create a if condation that see if the index i of the encryptedLettersNum             is bigger than the index j of the encryptedLettersNum and if it is not bigger             subtract them and set the index i of it to the total '''         if encryptedLettersNum[i]>encryptedLettersNum[j]:             encryptedLettersNum[i]=encryptedLettersNum[i]-encryptedLettersNum[j]             break   '''create a for loop that take the index encryptedLettersNum then decreased by 1 then added to Encoded list'''  for i in range(len (message)):     Encoded.append(letters[encryptedLettersNum[i]-1])   '''create a for loop that set the encodedMassage variable to the sum of it and the index of the encoded list ''' for i in range(len (message)):     EncodedMessage= EncodedMessage+Encoded[i];   '''print the message after encoded with the Encoded message''' print("The message after Encoded:\n" + EncodedMessage)       create the more efficient code and algorithm then describe the complexity.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

'''create three lists called(letters, Encoded, encryptedLettersNum)'''

letters=[]

Encoded=[]

encryptedLettersNum=[]

 

'''Create a String variables called(EncodedMessage) that will contain message

after the encryption'''

EncodedMessage=''

theAlphabetSmall='a'

 

'''create a for loop that add every element in

theAlphabetSmall list to the letters list''' 

for i in range(0,26):

    letters.append(theAlphabetSmall)

    theAlphabetSmall=chr(ord(theAlphabetSmall)+1)

 

'''print a question that tell the user to enter the message

and save it in the message variable'''

message=input ("Enter your message:\n")

 

'''create a for loop that add every character in the message variable

to the letters list and add the index+1 to the encryptionLettersNum list''' 

for i in range(len (message)):

    index=letters.index(message[i])

    encryptedLettersNum.append(index+1)

 

'''create a for loop in for loop that start from pointer +1

and end in the last character in the messag varible'''

for i in range(len (message)):

    for j in range(i+1,len (message)):

        ''' create a if condation that see if the index i of the encryptedLettersNum

            is bigger than the index j of the encryptedLettersNum and if it is not bigger

            subtract them and set the index i of it to the total '''

        if encryptedLettersNum[i]>encryptedLettersNum[j]:

            encryptedLettersNum[i]=encryptedLettersNum[i]-encryptedLettersNum[j]

            break

 

'''create a for loop that take the index encryptedLettersNum

then decreased by 1 then added to Encoded list''' 

for i in range(len (message)):

    Encoded.append(letters[encryptedLettersNum[i]-1])

 

'''create a for loop that set the encodedMassage variable to the sum of it and

the index of the encoded list '''

for i in range(len (message)):

    EncodedMessage= EncodedMessage+Encoded[i];

 

'''print the message after encoded with the Encoded message'''

print("The message after Encoded:\n" + EncodedMessage)

 

 

 

create the more efficient code and algorithm then describe the complexity

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education