Answer
The value of q is negative when the system loses heat to its surroundings. The value of w is negative when the system does work on its surroundings.
Work Step by Step
$\Delta E=q+w$
This formula tells us that a system can lose energy by losing heat or by doing work.