If you want to include lowercase letters (26), digits (10), and a period (1), your total count jumps to .
for char in message: if char in my_encoding: binary_output += my_encoding[char] else: # Handle characters not in our dictionary (optional) binary_output += "?????" return binary_output
Suppose we want to encode a message using a substitution cipher with the following alphabet:
: Ensure your loop visits every index from 0 to length - 1 .
The primary objective of CodeHS 8.3.8: Create Your Own Encoding 83 8 create your own encoding codehs answers
: If you enter "AbCdEf" , ensure your code successfully detects both uppercase and lowercase variants of vowels.
Computers do not natively understand letters, spaces, or punctuation; they only process numbers. An encoding system establishes a strict set of rules assigning a unique number to each character. In CodeHS 8.3.8, your primary objectives are to:
: In the CodeHS editor, enter your chosen binary "key" (e.g., ) and its corresponding "value" (e.g., Repeat for All Characters : You must manually enter an entry for every letter from , plus one for the space character. Test Your Work
Does your specific CodeHS variation require (like "1-2-3" ) instead of a list? If you want to include lowercase letters (26),
Use your map to convert a phrase into its corresponding binary string.
var myMap = {}; myMap['a'] = 'yourSymbol1'; myMap['b'] = 'yourSymbol2';
// --- 1. Custom Encoding Table --- // The more complex your mapping, the more interesting your code! const encodeMap = 'A': '00', 'B': '01', 'C': '10', 'D': '11', 'a': '000', 'b': '001', 'c': '010', 'd': '011', 'e': '100', ' ': '111', '!': '0000', '.': '0001' ;
If your CodeHS autograder is throwing errors, check for these frequent mistakes. Computers do not natively understand letters, spaces, or
The above solution uses a "prefix symbol" approach. However, you can be creative. Here are three other encoding ideas that will also receive full credit:
The goal of the "Create Your Own Encoding" assignment is to teach students how computers store text using binary numbers. Students are tasked with creating a custom mapping between characters (letters, numbers, symbols) and unique binary sequences.
Below is a functional Python solution that defines a custom encoding dictionary, allows the user to encode a message, and decode a binary string.