The city council of every city of the second class may contract for supplying the city with water, light, power, and heat for municipal purposes; and within or without the city may acquire, construct, repair, and manage pumps, aqueducts, reservoirs, plants, or other works necessary or proper for irrigation purposes or for supplying water, light, power, or heat or any by-product thereof for the use of the city and any person within the city and dispose of any excess of its supply to any person without the city.