Exothermic and Endothermic Reactions sorted reactions by whether they release or absorb heat, and Calorimetry measured that heat. To keep exact accounts we need a rule for signs, and the most basic law of energy: it is never created or destroyed.
Key idea
The system is what we study (the reacting chemicals); everything else is the surroundings. The system's internal energy changes by the heat and the work that cross its boundary: $$\Delta U = q + w.$$ Chemistry's signs: $q > 0$ when heat flows into the system, $q < 0$ when it flows out; $w > 0$ when work is done on the system, $w < 0$ when the system does work on the surroundings. Whatever the system gains, the surroundings lose: $\Delta U_\text{surr} = -\Delta U_\text{sys}$.
Why it works
Energy is conserved (the first law of thermodynamics), so the only ways a system's energy can change are by energy crossing its boundary, as heat (driven by a temperature difference) or as work (a force acting through a distance, such as a gas pushing a piston). Choosing every sign from the system's point of view, "in is positive, out is negative", makes the ledger a simple sum. $U$ is a state function: its change depends only on the start and the end, not on how much of the change came as heat and how much as work.
A sign warning. Physics books, and the Science Lab's First Law chapter, write $\Delta U = Q - W$, where $W$ is the work done by the gas. That is the same law: work done by the system is the negative of work done on it ($W = -w$). In this course, $w$ always means work done on the system, so $\Delta U = q + w$.
Worked example: Heat in, work out
A system absorbs $250\ \text{J}$ of heat and does $75\ \text{J}$ of work on its surroundings. Find $\Delta U$.
- Heat in: $q = +250\ \text{J}$. Work done by the system: $w = -75\ \text{J}$.
- $\Delta U = q + w = 250 + (-75) = +175\ \text{J}$.
- Physics check: $Q - W = 250 - 75 = 175\ \text{J}$, the same answer.
Answer: $+175\ \text{J}$
Worked example: Squeezed and cooled
A gas is compressed by $150\ \text{J}$ of work while it gives off $40\ \text{J}$ of heat. Find $\Delta U$ for the gas.
- Work done on the gas: $w = +150\ \text{J}$. Heat out: $q = -40\ \text{J}$.
- $\Delta U = -40 + 150 = +110\ \text{J}$.
Answer: $+110\ \text{J}$: the gas ends with more energy.
Common mistake
Mixing the physics and chemistry conventions for work, or giving $q$ a positive sign when the system loses heat. Decide each sign from the system's point of view before you add: into the system is positive, out of it is negative. Check: if the system both releases heat and does work, $\Delta U$ must be negative.