// 8.3.8 Create your own Encoding (JavaScript)
Understanding and Creating Your Own Encoding: CodeHS 8.3.8 Guide
Make sure you use the input() function to let the grader or user test different phrases. 8.3 8 create your own encoding codehs answers
Ensure no two letters share the same binary string.
The goal of this exercise is to write a program that takes a string of text from the user and "encodes" it by shifting or replacing characters based on a specific rule. Most students choose a (shifting letters by a fixed number) or a simple mapping system. Key Concepts Required To solve this, you need to be comfortable with: Most students choose a (shifting letters by a
Master CodeHS 8.3.8: Create Your Own Encoding Encoding algorithms form the backbone of modern data security and computer science. In the CodeHS "Create Your Own Encoding" exercise, you move beyond basic substitution ciphers to build a custom text encryption system using Python.
If your CodeHS autograder is throwing errors, check for these common pitfalls: If your CodeHS autograder is throwing errors, check
# Prompt the user for the secret message secret_message = input("Enter a message to encode: ") # Initialize an empty string to store the encoded result encoded_message = "" # Iterate through each character in the original message for char in secret_message: # Get the ASCII value of the character ascii_value = ord(char) # Apply the custom encoding rule (Shift the ASCII value by 3) new_ascii_value = ascii_value + 3 # Convert the new ASCII value back into a character new_char = chr(new_ascii_value) # Append the encoded character to our result string encoded_message += new_char # Print the final encoded message print("Encoded message: " + encoded_message) Use code with caution. Code Walkthrough and Logic
| Character | Binary Code | |-----------|-------------| | Space | 0 | | E | 10 | | T | 110 | | A | 1110 | | O | 11110 | | I | 111110 | | N | 1111110 | | S | 11111110 | | H | 111111110 | | R | 1111111110 | | … (others mapped to longer codes) |