U = internal energy = it is dependent on the kinetic energy of the gas molecules.. Their collisions among themselves determines the temperature. The other way mentioned, the temperature of the gas determines the speed of the molecules, and the collisions of them. The components of internal energy is translational, rotational, and vibrational energy associated with the molecules.

The entire effect is summarized in terms of temperature.

U = k_B T internal energy of a molecule at abs. temperature T.

k_B Boltzmann's constant

U = n Cv T where n = number of moles

Cv = heat capacity at constant volume

since U depends only on T, for any isothermal process, ΔU = 0. and the heat supplied ΔQ = ΔU + W = W

===========================

Since (P, V, T) change to (P- dP, V+dV, T)

There is work as the volume changed. If the gas expanded, then system has done work. That work = W = n R T Ln (1+ dV/V)

If dV is positive, then W is positive, and so during isothermal expansion, the gas (system) absorbs heat ΔQ and does positive work with that energy.

if dV is negative, then W is negative, and so during isothermal compression, the environment does work on the system and the energy supplied ΔQ goes into making the gas compress. Then heat is released from the system.