Locos, except for older steam ones, have classification codes that identify them. This code is of the form '[gauge][power][load][series][subtype][suffix]'
In this the first item, '[gauge]', is a single letter identifying the gauge the loco runs on:
W...
more... = Broad Gauge
Y = Meter Gauge
Z = Narrow Gauge (2' 6")
N = Narrow Gauge (2')
The second item, '[power]', is one or two letters identifying the power source:
D = Diesel
C = DC traction
A = AC traction
CA = Dual-power AC/DC traction
B = Battery electric(rare)
The third item, '[load]', is a single letter identifying the kind of load the loco is normally used for:
M = Mixed Traffic
P = Passenger
G = Goods
S = Shunting
L = Light Duty (Light Passenger?) (no longer in use)
U = Multiple Unit (EMU / DEMU)
R = Railcar (see below)
The fourth item, '[series]', is a digit identifying the model of the loco. Until recently, this series number was simply assigned chronologically as new models of locos were introduced.
Revised class notation for diesels, 2002: However, starting in 2002, for diesel passenger, goods, and mixed locos, i.e., WDP, WDG, and WDM sequences, (and only for them, apparently, not for electrics, nor for diesel shunters), the series digit identifies the horsepower range of the loco, with '3' for locos with over 3000hp but less than 4000hp, '5' for locos over 5000hp but less than 6000hp, etc. This new scheme will be applied to all passenger/goods/mixed-haul diesel locos starting in June 2002, except for the WDM-2 and WDP-1 classes of locos.
The fifth item, '[subtype]', is an optional letter or number (or two of them) that indicates some smaller variation in the basic model or series, perhaps different motors, or a different manufacturer. With the new scheme for classifying diesel locos (see above), the fifth item is a letter that further refines the horsepower indication in 100hp increments: 'A' for 100hp, 'B' for 200hp, 'C' for 300hp, etc. So in this scheme, a WDM-3A refers to a 3100hp loco, while a WDM-3F would be a 3600hp loco.
The last item, '[suffix]', is an optional indication that indicates something special about the loco, such as a different gearing ratio or brake system than usual.
Source: irfca.org