Answer: Metal A (sodium, 2,8,1) is more reactive than metal B (magnesium, 2,8,2).
Reason: Metals react by losing their valence electrons. Atom A has only 1 valence electron, which it loses very easily to form \(\mathrm{Na^{+}}\). Atom B has 2 valence electrons, and more energy is needed to remove two electrons to form \(\mathrm{Mg^{2+}}\). Also, in a period, the tendency to lose electrons decreases from left to right as the nuclear charge increases. So A reacts more readily than B.
Reactions with dilute hydrochloric acid (both give hydrogen gas):
\[\mathrm{2Na + 2HCl \rightarrow 2NaCl + H_2\uparrow}\]
\[\mathrm{Mg + 2HCl \rightarrow MgCl_2 + H_2\uparrow}\]
The reaction of sodium is very vigorous (it is dangerous and is not done in the laboratory), while magnesium reacts steadily with effervescence.