Step 1 : Convert grams of magnesium to moles using n = m/MM.
MM is found in periodic table if you don't know it yet.
So we get : n(Mg) = 25.5 g ÷ 24.305 g/mol. = 1.0491... mol.
Step 2: Look at the stoichiometric ratios in the formula. Mg : O = 2:1.
Therefore, the moles of oxygen is half the number of moles of Magnesium.
n(O2) = 0.5 x 1.0491... mol = 0.52458... mol
Step 3: Now convert moles of Oxygen to grams using m = n x MM. Hey presto you have your answer!
m(O2) = 0.52458... x 2(15.999) = 16.7856... grams.
To 3 significant figures this is 16.8grams.
Let me know if you are confused about anything.