Firstly, you must write down the chemical reaction and balance it.
Then, find the moles of the substance, which you are given the most information about. Be careful to correctly find the number of moles of the PURE substance, not the solution or mixture.
Finally, use those moles to find the remaining information about a different molecule in the reaction.
My working out:
NaOH + HCl = NaCl + H2O (balanced)
n = c * V
moles of HCl = 0.5mol/dm3 * 0.050 dm3 = 0.025 mol
moles of NaOH = 0.025 mol.
n = m / RFM
0.025 = mass of pure NaOH / 40
mass of pure NaOH = 1g
Percentage purity = mass of pure NaOH / mass of impure sample
Percentage purity = 1 / 1.2 * 100 = 83.3%