Municipalities having a population of more than five thousand and less than one hundred thousand inhabitants may pass ordinances prohibiting gambling and provide penalties for the violation of any ordinances passed under this authority.