Why does a gas become hotter when compressed by a piston in a cylinder?

When a gas is compressed by a piston in a cylinder, its temperature increases due to the conservation of energy and the transfer of work. To understand why this happens, we need to examine the relationship between pressure, volume, and temperature in gases.

The behavior of gases is described by the ideal gas law, which states that the pressure (P), volume (V), and temperature (T) of a gas are related by the equation: PV = nRT, where n is the number of gas molecules and R is the gas constant.

When a gas is compressed by a piston, the volume of the gas decreases while the number of gas molecules remains constant. According to the ideal gas law, if the volume decreases (V decreases) while the number of molecules (n) and the gas constant (R) stay the same, the pressure (P) must increase to maintain the equilibrium.

The increase in pressure leads to an increase in the kinetic energy of the gas molecules. The gas molecules collide more frequently and with greater force as the space available to them becomes smaller. These collisions result in a transfer of kinetic energy between molecules, causing an increase in their average kinetic energy, which corresponds to a higher temperature.

In summary, when a gas is compressed, its volume decreases, causing an increase in pressure. The increase in pressure leads to more frequent and energetic collisions between gas molecules, resulting in an increase in their average kinetic energy, which is manifested as a higher temperature.