Day 8 of #100DaysOfCode - Caesar Cipher

On Day 8 of #100DaysofCode, this mini project has taken me around 5 days to complete as there were issues with the code. I have created a caesar cipher program using the following python concepts from Dr Angela Yu's 100DaysOfCode: The Complete Python Bootcamp Udemy course:

  • Functions with inputs

  • Keyword Arguments

The purpose of creating caesar cipher program is giving the user the ability to encode plain text messages and decode encrypted messages. The program asks users to choose whether they want to encode or decode a message. For encoding, users are prompted to enter plain text messages and choose the number of shifts to apply to each character. The program outputs the encoded text. For decoding, If the users enter the encrypted message and the number of shifts used for encoding. The program functions by shifting each character in the message by a specific number of positions in the alphabet. If the users want to continue with the game, they enter "yes" and it would restart the cipher and ask you if you want to encode or decode. Where as, if the users enter "no" it will end the program.

Python Concepts Used:

Functions with Inputs

Function Inputs are used in the caesar cipher game by create one function called def caesar(direction, text, shift) which takes three inputs from the user which are direction, text and shift. When calling the caesar unction with the inputs, it executes all the lines of code inside the caesar function.

Keyword Arguments

Keyword argument is used while I was writing code for this mini project to specify the values that are being passed to each parameter in the def caesar() function without thinking about the order. For example, in def caesar() function, each parameter is specifically assigned to a value from the user input: cipher_direction is equal to user input direction, cipher_text to text and cipher_shift to shift. This makes sure that the computer has assigned the inputs correctly to the parameters in parallel. Even if the order of the parameters inside the caesar function has changed, the code will execute the specified values correctly. For instance, the function call caesar(cipher_direction=direction, cipher_text=text, cipher_shift=shift) demonstrates the use of keyword arguments to make the code more readable and robust.

caesar(cipher_direction=direction, cipher_text=text, cipher_shift=shift)

Reflections on the Caesar Cipher Program

During this mini project, I have faced several issues, specifically with scanning the characters, comparing them to the alphabet and using index values to assign the new character based on the number of shifts to help encode and decode the message. These difficulties made it tricky to get the program to work correctly. To troubleshoot, I used breakpoints to see how the computer was processing the def caesar() function. This helped me identify where the values were passed and pinpoint the error messages. Understanding these details through breakpoints and researching issues have massively helped me correct my mistakes and improve the capabilities of the caesar cipher program.

To access the full code - https://github.com/keiransystem14/Python100daysofcode/tree/main/Day%208%20Project%20-%20Caesar%20Chipher