Whenever a gas expands it does work on its' surroundings. If the pressure of the gas is changing, then calculating the work done can be complex. On the other hand, if the gas pressure is constant then finding the work done is especially simple.
Suppose the piston is pushed back or upwards a distanceby the gas.
The pressurepushing down on the piston exerts a force
To force the piston back a distance x against a forcean amount of work equal tomust be done by the gas.is the increase in volumeof the gas so we can writeThis equation is general and applies not only to pistons. It must be noted however in general an expanding gas cools down. The work supplied to expand the gas generally comes from the internal energy of the gas.
For example if a gas expands fromtoat atmospheric pressure, the work done is