As saidstated in other answers, the internal energy $U$ depends on other variables, e.g. volume, if internal interactions are not negligible.
On the other hand, there's a simple experience thatsimple experiment which shows that for nearly ideal gases, such as air in ordinaryat standard conditions, $U$ is a function of only the temperature $T$. (andIt is therefore assumed that for ideal gases, that $U$ is exactly a function of $T$). We)
In the experiment, we have an adiabatic container with a wall that divides it in two comparts,compartments: one side is filled with air at atmospheric pressure, while inand the other is made thea vacuum. NowThen, we remove the wall and let the gas expand. If we measure the temperature of the gas during the process, what we observe is that itthe temperature practically stays constant. Now
Now let's look at the whole process: since. Since the gas is thermally insulated, it doesn't exchange heat with the sourroundingssurroundings: $$Q=0.$$ The work done on the gas during the process is zero, since there's no force that keeps the gas from expanding:$$W=0.$$ So, by the conservation of energy: $$\Delta U = Q+W=0.$$ The net result is a change in the volume occupied by the gas (with an inverse change in pressure), while $\Delta U =0$. So, we conclude that the internal energy is independent fromof the volume, for ideal gases.