Relative atomic mass

Why are atomic masses given in the periodic table not whole numbers?
The atoms of an element In its naturally-occurring form, are usually a mixture of its various isotopes. For example hydrogen atoms are a mixture of 1H and 2H.  The mass of a large number of naturally-occurring H atoms depends on the percentage of 1H and 2H present in the sample

How do we know what isotopes are present and how much of each is present?
 
The relative abundance of the isotopes of an atom can be determined experimentally using an instrument known as a mass spectrometer. 

Mass spectrometers use both electric and magnetic fields to sort the atoms by atomic mass. 

The relative abundance of atoms with the various mass numbers are recorded on a graph in which the height of the peak for each isotope depends on its relative abundance.

The relative mass of a naturally-occurring sample of an element depends on the relative abundance of the isotopes in a naturally-occuring sample of the atoms.. 
 
Neon has three isotopes: neon-20, neon-21 and neon-22.  If these were are present in equal numbers (have equal abundance), the relative mass of naturally-occurring neon would be 21.

As the mass spectrum of neon shows, it is common for one isotope (neon-20 in this case) to be predominant in the mixture, and the relative mass of a naturally-occurring sample will be closest to the mass number for that sample.
 
The actual distribution of isotopes shown for neon means that the relative atomic mass of neon will be close to, but not equal to, 20 amu (atomic mass units).

It will be slightly higher than 20 amu due to the presence of the isotopes having a mass numbers of 21 and 22.