Black is 0, Brown is 1, Red is 2, Orange is 3, Yellow is 4, Green is 5, Blue is 6, Violet is 7, Grey is 8 and white is 9. You can try the mnemonic device Bad Boys Ravish Only Young Girls But Violet Gives Willingly.
The color code is used in resistors to indicate their values or ratings. The reason for use it is because in early 1900's was so much easier to print color bands on tiny components than numbers or letters. Normaly, a resitor have four bands, three for numeric value and the fourth for tolerance.