How could you convert heat energy into mechanical energy?

for example an expanding gas that pushes a flask. that's basically what's happening inside your car all the time

For example, if a heated gas expands, it can make things move.Please note that you can't convert ALL heat energy into mechanical energy or other types of useful energy; the maximum theoretical amount of heat you can convert is limited by the Carnot formula.