In a weighted code, each digit has a different numerical value. For example, in the 5421 code, the digit 5 represents a value of 5, the digit 4 represents a value of 4, the digit 2 represents a value of 2, and the digit 1 represents a value of 1. This means that the number 5421 represents the numerical value of 5 * 5 + 4 * 4 + 2 * 2 + 1 * 1 = 55.
Weighted codes are often used in applications where it is important to be able to quickly and accurately determine the numerical value of a code. This is because weighted codes can be easily converted to their numerical values by multiplying each digit by its corresponding numerical value and then adding the results together.