Work done is the transfer of energy by a force. When a force acts on a gas, it transfers energy to the gas particles, which increases the internal energy of the gas.
For example, let’s look at the diagram below.
1. A force is applied to push the piston by a certain distance.
2. This action decreases the volume of the gas container. Since the number of gas particles remains the same, there is now less space between them.
3. Because there is less space, the gas particles collide more frequently, leading to an increase in pressure.
The temperature of a gas is related to the average kinetic energy of the particles. As the kinetic energy of the gas particles has increased, the temperature of the gas has also increased.
In an expandable container, when a gas does work (like expanding against an external pressure), it uses up some of its internal energy. As a result, the gas might lose kinetic energy, leading to a decrease in temperature. This is provided no external heat is added.