They have different amounts of neutrons.
Do u know why? Ok, because they are both cacbon, so they have the same amounts of protons : 6.
The complete table is shown in figure
a) NH3 is polar as the bonds between N and H are polar. Due to asymmetry in the molecule the molecule is polar
The shape of molecule is trigonal pyramidal while its electronic geometry is tetrahedral.
b) CO2: it is a non polar molecule with polar bonds. The molecule becomes non polar as the dipole moment cancel each other. [Dipole moment is a vector quantity]
The shape is linear.
When an electron quickly occupies an strength state increased than its ground state, it is in an excited state. An electron can end up excited if it is given greater energy, such as if it absorbs a photon, or packet of light, or collides with a close by atom or particle.