How many valence electrons are in an atom of magnesium?
Magnesium has two valence electrons.
Also, the electron configuration of Mg is 1s² 2s²2p⁶ 3s² or [Ne]3s². Since the 3s² electrons are the outermost electrons, magnesium has two valence electrons.
The electron configuration for magnesium is shown below.
The valence elctrons are the electrons in the third energy level (3s sublevel has two electrons in an atom of Mg)
Here is a video which discusses how to determine the electron configuration of magnesium.