New single "Avatar - The Final Incarnation -"
11 December 2025
New studio album ‘ASPIRAL’ out now
OrderNew single "Avatar - The Final Incarnation -"
11 December 2025
Asia Tour 2025
24 September 2025
New Album ‘Aspiral’ – Out Today!
11 April 2025
The goal of CodeHS 8.3.8 is to write a program that takes a standard string of text from a user and transforms it into a coded format based on custom rules.
Write code that takes your custom binary string and translates it back into the original plain text. 8.3.8 Create Your Own Encoding Solution (Python)
: Updates the result string step-by-step before returning it to the main start() function. Python Solution: 8.3.8 Create Your Own Encoding
This public link is valid for 7 days and shares a thread, including any personal information you added. This link or copies made by others cannot be deleted. If you share with third parties, their policies apply. Can’t copy the link right now. Try again later.
Start by creating a dictionary that defines your cipher. Each key should be a lowercase letter, and each value should be the character you want to replace it with. # Example: A simple "Shift" cipher or random map encoding_map # ... continue for the whole alphabet Use code with caution. Copied to clipboard 2. Create the Encoding Function 8.3 8 create your own encoding codehs answers
: Inside the encoding function, encoded_result = "" creates a clean slate.
# Test with a more complex string test = "CodeHS 8.3.8 is fun!" print("\nTest original:", test) enc_test = encode(test) print("Test encoded:", enc_test) print("Test decoded:", decode(enc_test))
Replacing specific characters with symbols, numbers, or entirely different letters (e.g., replacing all vowels with numbers). Step-by-Step Logic Breakdown
The encoding and decoding methods must use the same mapping table. If 'A' is mapped to 0000 in the encoder, it must be 0000 in the decoder. The goal of CodeHS 8
: Remember that 'A' (65) and 'a' (97) have different numeric values. The ord() function handles this automatically, but your shifts might push letters into punctuation ranges if the shift value is too large.
A: Most autograders expect consistency. Converting the input to uppercase before encoding is a simple and effective strategy.
Prompt the user to enter a message or string using input() .
The simplest and most effective method for this assignment is a or a Shift Cipher (like the Caesar Cipher). Python Solution: 8
Once you submit this, challenge yourself: modify the shift value or try a non-linear transformation. That’s where real computer science begins.
You will create your own encoding scheme. Write a function encode(message) that takes a string message as a parameter and returns an encoded version. Then write a function decode(encoded_message) that reverses the process. You must also include a main block that demonstrates both functions working.
Before diving into the code, it's helpful to understand why this matters. Custom encodings are a foundational concept in computing. They help demonstrate: