The idea here is that you need to assume that all the magnesium and all the oxygen will combine to produce magnesium oxide as described by the chemical equation
#2"Mg"_ ((s)) + "O"_ (2(g)) -> 2"MgO"_ ((s))#
As you know, mass is always conserved in a chemical equation. This implies that the combined mass of the reactants must be equal to the mass of the product.
Now, you know that your reaction consumes
The difference between the mass of magnesium oxide and the mass of magnesium must be accounted for by the mass of oxygen gas. You can thus say that you have
#underbrace( overbrace("45.0 g")^(color(blue)("mass of Mg")) + overbrace(?color(white)(.)"g")^(color(blue)("mass of O"_ 2)))_ (color(purple)("the mass of the reactants")) = underbrace( overbrace("74.62 g")^(color(blue)("mass of MgO")))_ (color(purple)("the mass of the product"))#
Therefore, the mass of oxygen gas that took part in the reaction is equal to
#"mass of O"_2 = "74.62 g " - " 45.0 g" = color(darkgreen)(ul(color(black)("29.6 g")))#
The answer is rounded to one decimal place, the number of decimal places you have for the mass of magnesium.