© 2016 the Owner Societies. The electronic structure of single walled nitrogen-doped carbon nanotubes is calculated by first principles using density functional theory within the supercell approach with periodic boundary conditions. The effect of the adsorption of hydrogen atoms on different sites, relative to the position of the nitrogen atom, is explicitly taken into account. Both non-chiral and chiral geometries are analyzed. The obtained band structure shows that the non-chiral (6,0) nanotube is a semimetal under all different doping and adsorption configurations treated. The non-chiral (10,0) nanotube behaves mostly as a semiconductor, with the band gap width modulated by nitrogen doping and the relative position of the adsorbed hydrogen atom. The increase of substitutional N doping from one to three atoms per cell turns a (6,5) single-walled carbon nanotube from a semiconductor into a semimetal at zero temperature. Optical absorption related to carrier transitions between the calculated states is investigated from the imaginary part of the dielectric function, constructed with the use of the calculated Kohn-Sham states. The importance of the variation of the relative position of the adsorbed hydrogen atom on the chemical and physical properties investigated is particularly highlighted.