Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this program works and is ready to turn in to my teacher. i want to go a little father and use recursion to call the

image text in transcribed

this program works and is ready to turn in to my teacher. i want to go a little father and use recursion to call the the function Start to encrypt and decrypt untill they wanna stop. but am not sure how to access global variables in python. so please help i will attach what i was trying to do next. if i put it ontop it says some variables are not defined if i put it after then same problem but with the other fucntion. please explain your code so i can lear from my mistakes self.

image text in transcribed

import os # the string to be encrypted/decrypted message = input ('please enter message to encrypt or decrypt: ') # the encryption/decryption key key =int (input ("Please enter Number for encryptions Key: "), 10) # set to 'encrypt ' or 'decrypt' option- input ("Please enter e for Encryption d for decryption:) # stores the encrypted/decrypted form of the message translated = ' , # capitalize the string in message message message . upper() def caesarEncrypt (msg, ky) # every possible symbol that can be encrypted global message, LETTERS, num, translated LETTERS = 'ABCDEFGH lJKLMNOPQRSTUVWXYZ' for symbol in message: if symbol in LETTERS: # get the encrypted (or decrypted) number for this symbol num = LETTERS, find (symbol) # get the number of the symbol num (num + key) % 26 # add encrypted/decrypted number's symbol at the end of translated translated = translated + LETTERS [num] else: # just add the symbol without encrypting/decrypting translated translated + symbol def caesarDecrypt (msg, ky): # every possible symbol that can be encrypted global message, LETTERS, num, translated LETTERS = 'ABCDEFGH lJKLMNOPQRSTUVWXYZ' for symbol in message: if symbol in LETTERS: # get the decrypted number for this symbol num = LETTERS, find (symbol) # get the number of the symbol num (num- key) % 26 # add encrypted/decrypted number's symbol at the end of translated translated = translated + LETTERS [num] else: # just add the symbol without encrypting/decrypting translated translated + symbol if 'e' in option: caesarEncrypt (message, key) elif 'd' in option: caesarDecrypt (message, key) else: print(not an option") print translated)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

6. Identify the belly of the whale in Raiders of the Lost Ark.

Answered: 1 week ago