A code is a way of changing information into something else. Sometimes this is done as a way of keeping a message secret. This is called encryption or cryptography. One source gives this explanation: a code is "a word, number or some other symbol used to represent a word, phrase or syllable in plaintext". It is one of the earliest forms of cryptography. Contrast code with cypher, in which the individual letters are encrypted (changed).
Sometimes it is done as an easier way of sending a message. For example, when people on two different boats want to send a message, they may be too far away to shout, but they can send messages with a flag code. Another code that people use is called Morse code, which changes letters to dots and dashes, like this:
Computers use codes, by changing letters into 1's and 0's. This is called an ASCII code.
Some people write codes as a kind of game. They think it is fun to make ciphers, and fun to break them. Breaking a code means taking it apart to understand how it works, and then you can understand messages that are written in that code. Cryptanalysis is also serious business. Nations and other organizations have been breaking each other's ciphers for many centuries.
Code Facts for Kids. Kiddle Encyclopedia.