Answer
See the detailed answer below.
Work Step by Step
First, we need to find the number of moles, or the number of molecules, of each gas.
We know that
$$n=\dfrac{m}{M}$$
where $m$ is the total mass of the given gas sample and $M$ is the atomic mass of the molecule in the sample.
Hence,
$$n_{He}=\dfrac{m_{He}}{M_{He}}=\dfrac{2}{4}=\bf 0.5\;\rm mol$$
$$n_{O_2}=\dfrac{m_{O_2}}{2M_{O}}=\dfrac{8}{2(16)}=\bf 0.25\;\rm mol$$
---
a) The thermal energy of a monatomic gas is given by
$$E_{th}=\frac{3}{2}nRT$$
Hence,
$$(E_{i,th})_{He}=\frac{3}{2}(0.5)(8.31)(300)=\color{red}{\bf 1870}\;\rm J$$
And we know that the thermal energy of a diatomic gas is given by
$$E_{th}=\frac{5}{2}nRT$$
Hence,
$$(E_{i,th})_{O_2}=\frac{5}{2}(0.25)(8.31)(600)=\color{red}{\bf 3116}\;\rm J$$
____________________________________________________
d) To find the final thermal energy of each gas, we need to find their final temperatures.
Let's assume that the two gases are well isolated from surroundings which means that any heat loss from one gas will be absorbed by the other.
This means that the total thermal energy is conserved.
Hence,
$$ (E_{i,th})_{He}+(E_{i,th})_{O_2}=(E_{f,th})_{He}+(E_{f,th})_{O_2}$$
And since both gases, after a long time, will reach thermal equilibrium, their final temperatures are the same.
Hence, plugging from part (a) above;
$$1870+3116=\frac{3}{2}n_{He}RT_f+\frac{5}{2}n_{O_2}RT_f$$
Thus,
$$T_f=\dfrac{1870+3116}{R[\frac{3}{2}n_{He} +\frac{5}{2}n_{O_2}]}=\dfrac{1870+3116}{(8.31)[\frac{3}{2}(0.5)+\frac{5}{2}(0.25)]}$$
$$T_f=\color{red}{\bf 436}\;\rm K=\color{red}{\bf 163}^\circ C$$
____________________________________________________
b) Now we can find the final thermal energy of each gas.
The thermal energy of a monatomic gas is given by
$$E_{th}=\frac{3}{2}nRT$$
Hence,
$$(E_{f,th})_{He}=\frac{3}{2}(0.5)(8.31)(436)=\color{red}{\bf 2717}\;\rm J$$
And we know that the thermal energy of a diatomic gas is given by
$$E_{th}=\frac{5}{2}nRT$$
Hence,
$$(E_{f,th})_{O_2}=\frac{5}{2}(0.25)(8.31)(436)=\color{red}{\bf 2264}\;\rm J$$
____________________________________________________
c) Since the final temperature of the helium increased while the final temperature of the oxygen decreases, the heat transferred from oxygen to the helium.
And its magnitude is given by the change in the thermal energy of any gas of them
$$Q=\Delta E_{th,He}=(E_{f,th})_{He}-(E_{i,th})_{He}$$
Plugging from above;
$$Q= 2717-1870=\color{red}{\bf 847}\;\rm J$$