(a) This section does not apply to:
(1) a law enforcement officer in the regular course of the officer’s duty;
(2) an off–duty law enforcement officer or a person who has retired as a law enforcement officer in good standing from a law enforcement agency of the United States, the State, or a local unit in the State who is a parent, guardian, or visitor of a student attending a school located on the public school property, provided that:
(i) the officer or retired officer is displaying the officer’s or retired officer’s badge or credential;
(ii) the weapon carried or possessed by the officer or retired officer is concealed; and
(iii) the officer or retired officer is authorized to carry a concealed handgun in the State;
(3) a person hired by a county board of education specifically for the purpose of guarding public school property;
(4) a person engaged in organized shooting activity for educational purposes; or
(5) a person who, with a written invitation from the school principal, displays or engages in a historical demonstration using a weapon or a replica of a weapon for educational purposes.
(b) A person may not carry or possess a firearm, knife, or deadly weapon of any kind on public school property.
(c) (1) Except as provided in paragraph (2) of this subsection, a person who violates this section is guilty of a misdemeanor and on conviction is subject to imprisonment not exceeding 3 years or a fine not exceeding $1,000 or both.
(2) A person who is convicted of carrying or possessing a handgun in violation of this section shall be sentenced under Subtitle 2 of this title.