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

The encryption problem is divided into three parts. the fourth part, solving dec

ID: 3862638 • Letter: T

Question

The encryption problem is divided into three parts. the fourth part, solving decryption, is optional. To begin, set up your main program with the following: alpha = ' ' abcdefghijklmnopqrstuvwxyz ' ' offset = int (input (''Enter the offset: '')) phrase = input (''Enter the phrase to encrypt: '') Note that there is a space character at the end of the alphabet string so that you can include spaces in your phrases. 1. You will need to be able to find where a character occurs in the alphabet. Write a function called findpos (A, ch) that returns the position of character ch in string A. Positions start from 0 in the string. For example, if the alphabet A is as defined above and ch is "d", then the function returns 3. Call this from the main program to test that it works.

Explanation / Answer

def findPos(A, ch):
return A.find(ch)


alpha = "abcdefghijklmnopqrstuvwxyz "
offset = int(input("Enter an offset for substitution cipher: "))
phrase = input("Enter phrase to encrypt: ")

print("Position of d in " + alpha + " is " + str(findPos(alpha, 'd')))

# link for code https://goo.gl/5XkEfE

'''

Enter an offset for substitution cipher: 1   

Enter phrase to encrypt: test

Position of d in abcdefghijklmnopqrstuvwxyz  is 3   

'''

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote