Z gives the number of nuclear protons, and the number of electrons that we have to distribute according to a given scheme......
imgarcade.com
The scheme is not perfect, and it falls down for chromium metal, which is Z=24, and gives 1s^2 2s^2 2p^6 3s^2 3p^6 3d^5 4s^1 rather than but 1s^2 2s^2 2p^6 3s^2 3p^6 3d^4 4s^2, but you can learn this and several other exceptions.......
The features the filling of the "4s-orbitals" BEFORE the "3d-orbitals" begin to be filled.....And thus the first-row transition metals typically have a FULL 4s shell, cf. iron, Z=26, and gives 1s^2 2s^2 2p^6 3s^2 3p^6 4s^2 3d^6
And given the position of the element on the Periodic Table, "s-block", "p-block", "d-block", usually you can define the valence configuration without difficulty.
Anyway, this is the knowledge expected of an undergraduate student. I don't know whether you are there or at A-level.