Valency-Number of protons present in the outermost shell of an atom is known as Valency or The combining power of a element with a atom is also known as Valency.
Taking oxygen as Example-
1.Atomic number of Oxygen is8.
3.According to the electronic configuration the valency is 6 but it is easy for oxygen to gain 2 protons instead of loosing 6 protons.So, The valency of oxygen is 2.
Taking silicon as example-
1.Atomic number of silicon is 14.
3.According to the electronic configuration the valency is +4 or -4 because silicon can either gain 4 electrons or loose 4 electrons because it is a noble gase.