The energy of the photon can be worked out using the equation If an electron moves ... and hence a different colour. This causes line emission spectra to be produced, as shown below.
Studying the line spectra produced by hot gases and absorbed by cooler gases allows us to identify the elements in stars. When a gas is very hot, it doesn’t emit all wavelengths of light.