Please can I have a UML Class diagram for the Python program below:
def main():
print()
print("Welcome to Caesar Encryption and Viginere Decryption Cipher")
print()
print("Please select an option")
option = "c"
while option == "c":
hello = input('Choose Caesar Cipher encrypt 1:\n'
'Choose Viginere Cipher Decrypt 2:\n')
message = input('Enter a message: ')
password = input('Enter a password: ')
if hello == '1':
viginere_cipher(message, password)
elif hello == '2':
viginere_cipher_decrypt(message, password)
print()
print("Choose an option")
option = input('Enter c to continue or any key to exit: ')
# defines a function taking letter as input
def alphabet_index(letter):
return ord(letter) - 97
# defines a function called Caesar_cipher that takes a letter and a key
def caesar_cipher(letter, key):
if ord(letter) + key > ord('z'):
# it subtracts 26 from the ASCII value of the letter and the key and then returns it to a character
return chr(ord(letter) + key - 26)
elif letter == ' ': # if the letter we wrote is a space
return " " # return the space as is
else: # otherwise
# return the the ASCII value of the letter + key and turn into a character
return chr(ord(letter) + key)
def viginere_cipher(message, password): # defines a function that takes message and a password
ciphertext = '' # defines a variable as empty
counter = 0 # defines a variable as 0
for letter in message: # for every letter in the message
# add ciphertext to itself,implement a caesar cipher by taking a letter and the key is. #
# the alphabet_index which is the password by looping the counter count with the length of the password
ciphertext += caesar_cipher(letter, alphabet_index(password[counter % len(password)]))
counter += 1 # it adds 1 to counter each time
print(ciphertext) # return the ciphertext encryted
# defines a function that takes message and a password
def viginere_cipher_decrypt(message, password):
ciphertext = '' # defines a variable as empty
counter = 0 # defines a variable as 0
for letter in message: # for every letter in message
# add ciphertext to itself,implement a caesar cipher by taking
# a letter and the key as the alphabet_index which is
# the password by looping the counter count with the length of the password
ciphertext += caesar_cipher(letter, 26 - alphabet_index(password[counter % len(password)]))
counter += 1 # it adds 1 to counter each time
print(ciphertext) # return the ciphertext as is
main()Ans:
'''
The above python program for a cipher system comprising only of functions can not be easily represented in the form of UML class diagram since it does not have any classes, objects, data members or member functions.
Hence a more Suitable diagram to represent the above python program would be Sequence Diagram!
'''

/*
Sequence diagrams are appropriate to represent function calls, and you can specify the parameters and returned values as well. Communication Diagrams are also an option and tend to go into more detail with regards to parameters used within function calls.
*/
/*
PLEASE DO LIKE AND UPVOTE IF THIS WAS HELPFUL!
THANK YOU SO MUCH IN ADVANCE!
*/
Please can I have a UML Class diagram for the Python program below: def main(): print()...
I have a python project that requires me to make a password saver. The major part of the code is already giving. I am having trouble executing option 2 and 3. Some guidance will be appreciated. Below is the code giving to me. import csv import sys #The password list - We start with it populated for testing purposes passwords = [["yahoo","XqffoZeo"],["google","CoIushujSetu"]] #The password file name to store the passwords to passwordFileName = "samplePasswordFile" #The encryption key for the caesar...
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...
Can someone help me with this? ## caesar.py def encode(msg, shift): newmsg = "" #process each character in msg. #Hint: using a for loop #A for loop to check each ch in msg: if ('A' <= ch and ch <= 'Z'): #if the character is an uppercase letter #encode the character based on the shift number #Hint: the new character newch should be #chr((ord(ch) - ord('A') + shift) % 26 + ord('A')) elif ('a' <=...
For my computer class I have to create a program that deals with
making and searching tweets. I am done with the program but keep
getting the error below when I try the first option in the shell.
Can someone please explain this error and show me how to fix it in
my code below? Thanks!
twitter.py - C:/Users/Owner/AppData/Local/Programs/Python/Python38/twitter.py (3.8.3) File Edit Format Run Options Window Help import pickle as pk from Tweet import Tweet import os def show menu():...
Need help writing this code in python.
This what I have so far.
def display_menu():
print("======================================================================")
print(" Baseball Team Manager")
print("MENU OPTIONS")
print("1 - Calculate batting average")
print("2 - Exit program")
print("=====================================================================")
def convert_bat():
option = int(input("Menu option: "))
while option!=2:
if option ==1:
print("Calculate batting average...")
num_at_bats = int(input("Enter official number of at bats:
"))
num_hits = int(input("Enter number of hits: "))
average = num_hits/num_at_bats
print("batting average: ", average)
elif option !=1 and option !=2:
print("Not a valid...
Need help with Python (BinarySearch), code will be below after my statements. Thank you. Have to "Add a counter to report how many searches have been done for each item searched for." Have to follow this: 1) you'll create a counter variable within the function definition, say after "the top = len(myList)-1" line and initialize it to zero. 2) Then within the while loop, say after the "middle = (bottom+top)//2" line, you'll start counting with "counter += 1" and 3)...
Can you please enter this python program code into an IPO Chart? import random def menu(): print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the non-numbers #if user enters letters, then except will show the message, Numbers only! try: c=int(input("Enter your choice: ")) if(c>=1 and c<=3): return c else: print("Enter number between 1 and 3 inclusive.") except: #print exception print("Numbers Only!")...
I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...
VERY URGENT*** THANK YOU IN ADVANCE: THIS IS THE CODE I HAVE GOTTEN SO FAR: PYTHON This is a code that is supposed to help someone study/ practice for jeopardy. The two functions described below are required for this assignment. You may add other functions that you think are appropriate: menu() This function, which displays all the user options to the screen, prompt the user for their choice and returns their choice. This function will verify user input and ALWAYS...
I am currently facing a problem with my python program which i have pasted below where i have to design and implement python classes and record zoo database and takes user input as query. the error i am recieving says that in line 61 list index is out of range. kindly someone help me with it as soon as possible. Below is the program kindly check and correct it. Thanks! class Animal: def __init__(self, name, types, species, mass): self.name=name self.type=types...