An element X (atomic number 17) reacts with an element Y (atomic number 20) to form a compound

An element X (atomic number 17) reacts with an element Y (atomic number 20) to form a compound.
(a) Write the position of these elements in the modern periodic table.
(b) Write the formula of the compound formed. Justify your answer in each case.

(a) Element X (atomic number 17) belongs to p-block. Period 3, Group 17.
Electronic configuration of X: 2, 8, 7
Valence shell electrons = 7
So, Group number = 17
Period to which the elements belongs = 3
Element Y (atomic number 20) belongs to s-block. Period 4, Group 2.
Electronic configuration of Y: 2, 8, 8, 2
Valence shell electrons = 2
So, Group number = 2 Period to which this belongs = 4

(b) X has 7 valence electrons so, it needs 1 more electron to complete its octet and Y has 2 valence electrons so it will give its 2 electrons to acquire octet configuration. Hence, X will gain 1 electron and Y will lose 2 electrons, so the chemical reaction is:
X2 + Y → YX2
Specifically, X = Cl and Y = Ca
So, Cl2 + Ca → CaCl2