Answer:
Let us arrange this data in ascending order.
2, 15, 16, 29, 31, 40.
x has to be in the middle if it is the median.
So it becomes 2, 15, 16, x, 29, 31, 40.
There are seven numbers. The median is the 4th one.
The median is given as 21.
So x = 21.
HOPE IT HELPS YOU, PLS MARK IT AS THE BRAINLIEST :D