It shall be unlawful for any person to discharge any firearm in the corporate limits of the city except in defense of person. This section shall not apply to authorized officers of the law in their official capacity, nor to the discharge of firearms at licensed or municipally operated pistol ranges or at ceremonial functions for which a permit for the discharge of firearms has been obtained.