A heat engine is a device that converts the energy from heat into mechanical work. It operates by taking in thermal energy from a high-temperature source, converting a portion of that energy into mechanical work, and then exhausting the remaining energy to a low-temperature sink.