This is because of atmospheric pressure and the way gas molecules in the atmosphere move.
The faster molecules move – the higher the temperature. Nearer Earth, the pull of gravity increases pressure – so air moves faster and it’s warmed. As you get higher, pressure becomes lower and air moves slower, so it’s colder. Radiation bouncing from the Earth’s ground also helps increase temperature – which is lost are you move higher into the atmosphere.
Comments