python program
Use the provided shift function to create a caesar cipher program.
Your program should have a menu to offer the following options:
Read a file as current message
Save current message
Type in a new message
Display current message
"Encrypt" message
Change the shift value
For more details, see the comments in the provided code.
NO GLOBAL VARIABLES!
Complete the program found in assignment.py. You may not change any provided code. You may only complete the sections labeled:#YOUR CODE HERE
Submit source file and screenshot by the posted due date.
------------------------------------------------------
assignment.py:
shift takes a single character and an integer value as arguments
# Any character not == a-z or A-Z will be returned as is
# Any letter will be shifted by numPlaces in the alphabet
# shift('a',1) will return b
# shift('z',1) will return a
# shift('a',-1) will return z
def shift(letter, numPlaces):
digit = ord(letter)
numPlaces = numPlaces %26
if digit >= 65 and digit <= 122:
if digit <=90:
digit = (((digit - 65)+numPlaces)%26) + 65
elif digit >= 97:
digit = (((digit - 97)+numPlaces)%26) + 97
return chr(digit)
# Read a message from a file
# Read the entire contents into a single string
# Return the string
def readMessage():
#YOUR CODE HERE
return message
# Save the current message to a file
# Over write the file with the entire message string
# Do not return anything
def saveMessage(message):
#YOUR CODE HERE
# Print out the current message
# Nothing more
def displayMessage(message):
#YOUR CODE HERE
# Enter a new message from the keyboard
# Return the new message
def typeMessage():
#YOUR CODE HERE
# Change the shift value
# Prompt the user to enter a new shift value
# Return this new value as an int
def changeShift():
#YOUR CODE HERE
# "Encrypt" the message by shifting
# each character of the message by myShift
# Use the shift function here
# Return the new message
def encrypt(message,myShift):
newMsg = ""
#YOUR CODE HERE
return newMsg
# Create a menu for user
def menu(message,myShift):
#YOUR CODE HERE
# Basic setup stuff
def main():
message = ""
myShift = 5
menu(message,myShift)
main()