First find the mean of the returns, then take differences from the mean and square them. Add the squared differences and divide by n-1 to find the variance, and take the square root of the variance to find the standard deviation.
For Stock A: (16 + 20 + 12)/3 = 48/3 = 16% average return.
(16 – 16)2 = 02 = 0
(20 – 16)2 = 42 = 16
(12 – 16)2 = -42 = 16
0 + 16 + 16 = 32; 32/(3-1) = 16; 161/2 = 4.0%
For Stock B: (20 + 24 + 10) = 54/3 = 18% average return.
(20 – 18)2 = 22 = 4
(24 – 18)2 = 62 = 36
(10 – 18)2 = -82 = 64
4 + 36 + 64 = 104; 104 / (3 − 1) = 52; 521/2 = 7.2%