First of all, we need to write the First Law of thermodynamics assigning the correct sign convention:
![\Delta U = Q+W](https://img.qammunity.org/2020/formulas/physics/high-school/3wudyxecp7et99hdgpq2tcdqnjnxzfoern.png)
where
is the change in internal energy of the system
Q is the heat absorbed/released
W is the work done
and the signs are assigned based on whether there is an increase in the internal energy or not. Therefore:
Q is positive if it is absorbed by the system (because internal energy increases)
Q is negative if it is released by the system (because internal energy decreases)
W is negative if it is done by the system on the surrounding (because internal energy decreases)
W is positive if it is done by the surrounding on the system (because internal energy increases)
Using these definitions, we can now fill the text of the question:
When a system is heated, heat is ABSORBED by the system. The amount of heat added is given a POSITIVE sign. When a system is cooled, heat is RELEASED by the system. The amount of heat is given a NEGATIVE sign. If a gas expands, it must push the surrounding atmosphere away. Thus, work is done BY the system and is given a NEGATIVE sign. If a gas is compressed, then work is done ON the system. This work is given a POSITIVE sign.