Internal energy is the sum of all the energies of a molecule in the frame of reference of the system.
According to $1^{\text {st }}$ law,
$\Delta Q=\Delta U+\Delta W$
where $\Delta U$ is internal energy, $\Delta W$ is the work done and $\Delta Q$ is the heat transferred.
$\Delta U=\Delta Q-\Delta W$
