For A), you need the equation first, which would be Mg + 2HCl --> MgCl2 + H2
Then, you need the moles of magnesium and the moles of hcl
n(Mg) = m(Mg) / mm(Mg) = 2.40 / 24.305 = 0.0987
n(HCl) = cV = 0.5 * 0.4 = 0.2
As question states it's difficult to see if magnesium is present, you can assume that it's been used up completely. If 0.0987 moles of magnesium is completely used up, there would be 1/2 the moles of HCl used up; i.e 0.2 / 2 = 0.1 ... as n(Mg) is less than n(HCl), you can infer that Magnesium is limiting reagent in this situation.
For B), using the reference sheet, at 25oC and 100kPA, the volume of 1 mole of an ideal gas is 24.79L. Thus, using the moles of magnesium to calculate the moles of gas produced (as Mg is limiting reagant), the equation tells us that the ratio of moles of Mg to H2 is 1:1 ... thus, n(H2) = 0.0987, and so the volume of gas would be 24.79L x 0.0987 = 2.44789138L = 2.48L (3s.f)