The style of ordinances of a city of the primary class shall be: Be it ordained by the city council of the city of ........ . All ordinances shall be published within fifteen days after passage thereof, such publication to be sufficient if published in one issue of a legal newspaper in or of general circulation in the city, or posted on the official bulletin board of the city at the city hall, or in book, pamphlet, or electronic form, as may be provided by ordinance, to be distributed or sold in the city. Ordinances fixing a penalty or forfeiture for the violation thereof shall not take effect until fifteen days after passage, and in no case before one week after the publication thereof in the manner prescribed in this section, except that in case of riots, infectious or contagious diseases, or other impending danger or other emergency requiring immediate operation of the ordinance, such ordinance shall take effect immediately upon the publication thereof as prescribed in this section. All ordinances, except as otherwise provided in this section, shall take effect fifteen days after passage.