def main ): userInput - displayMenuAndGetOption ) if userInput-"E" or userInput "D": getFiles () elif userInput-"Q print ("nErrorInvalid option.") input ("nRun complete. Press the Enter key to exit.") def displayMenuAndGetoption ): print ("File Encryption Program\n") print ("E Encrypt a file\nD = Decrypt a file\nQ Quit the Program") userInput= input ("\nEnter menu selection (E, D, or Q) : ").upper() return userInput def getFiles 0: outFileopen ("encryptedFile.txt", "w") try: encrypt File open (input ("Enter the file to ENCRYPT. Press Enter alone to abort. "), 'r') except FileNotFoundError: print ("Error - that file does not exist. Try again.") convert (encryptFile, outFile) def convert (inputFile, outputFile): # Encryption and decryption are inverse of one another CODE = {'A' : ' ) ' , ' a' : ' 0' , 'B':'(','b':'9','C':'*','c':18',\
def main ): userInput - displayMenuAndGetOption ) if userInput-"E" or userInput "D": getFiles () elif userInput-"Q print ("nErrorInvalid option.") input ("nRun complete. Press the Enter key to exit.") def displayMenuAndGetoption ): print ("File Encryption Program\n") print ("E Encrypt a file\nD = Decrypt a file\nQ Quit the Program") userInput= input ("\nEnter menu selection (E, D, or Q) : ").upper() return userInput def getFiles 0: outFileopen ("encryptedFile.txt", "w") try: encrypt File open (input ("Enter the file to ENCRYPT. Press Enter alone to abort. "), 'r') except FileNotFoundError: print ("Error - that file does not exist. Try again.") convert (encryptFile, outFile) def convert (inputFile, outputFile): # Encryption and decryption are inverse of one another CODE = {'A' : ' ) ' , ' a' : ' 0' , 'B':'(','b':'9','C':'*','c':18',\
Chapter13: File Input And Output
Section: Chapter Questions
Problem 7PE
Related questions
Question
How would I open a file and encrypt that file from a dictionary in Python? Attached is a picture of my current code. I am currently stuck at the getFiles() and convert(inputFile, outputFile) functions.

Transcribed Image Text:def main ):
userInput - displayMenuAndGetOption )
if userInput-"E" or userInput "D":
getFiles ()
elif userInput-"Q
print ("nErrorInvalid option.")
input ("nRun complete. Press the Enter key to exit.")
def displayMenuAndGetoption ):
print ("File Encryption Program\n")
print ("E Encrypt a file\nD = Decrypt a file\nQ Quit the Program")
userInput= input ("\nEnter menu selection (E, D, or Q) : ").upper()
return userInput
def getFiles 0:
outFileopen ("encryptedFile.txt", "w")
try:
encrypt File
open (input ("Enter the file to ENCRYPT. Press Enter alone to abort.
"),
'r')
except FileNotFoundError:
print ("Error - that file does not exist. Try again.")
convert (encryptFile, outFile)
def convert (inputFile, outputFile):
# Encryption and decryption are inverse of one another
CODE = {'A' : ' ) ' , ' a' : ' 0' , 'B':'(','b':'9','C':'*','c':18',\
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images

Knowledge Booster
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.Recommended textbooks for you

EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage

Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,

EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage

Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L

Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning

C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning