How does thermal energy in a system do mechanical work? Explain that a system with thermal energy has the capacity to do
mechanical work. Also, in addition to this what are the differences between work and mechanical work? 
 A: Explain that a system with thermal energy has the capacity to do mechanical work. 
First of all, one should avoid talking about the “thermal energy” of a system, since it is often confused with the terms “heat” and “temperature”.  The proper term is internal energy, which is the sum of the kinetic and potential energies of a system.
Work is energy transfer due to force acting through distance, done either by the surroundings on the system (e.g., compression of a gas) or by the system on the surroundings (e.g., expansion of a gas). In the absence of heat transfer, that energy transfer either adds to or subtracts from the internal energy of the system, respectively, according to the first law.
Bottom line, the internal energy of a system does work by transferring some of its internal energy to the surroundings. In the case of an ideal gas in a piston/cylinder, the gas molecules give up kinetic energy when they impact the face of the the piston creating pressure (force) that does work on the surroundings, according to the equation given you by Steeven. If the work is done adiabatically (no heat transfer) that loss in kinetic energy is reflected by a decrease in the temperature of the gas. 
Also, in addition to this what are the differences between work and mechanical work?
All work involves force acting through distance. You can call it electrical work if the force is due to an electrical field, gravitational work if a gravitational field does it, or mechanical work if the force is due to physical contact between things. The distinction is one of convenience in order to identify the agent doing or receiving the work, but there is no fundamental difference. They all involve force acting through distance. They can all be simply called “work”.
Hope this helps.
