Any school board may install in the school buildings under its care the necessary apparatus and appliances, and purchase the necessary food to enable it to provide and sell lunches to children attending the schools. Lunches shall not be sold for a less price than the cost of the food, exclusive of the cost of the necessary apparatus and appliances and exclusive of costs necessary and incidental to the purchase of the food and the preparing and serving of the lunches; except that in cities which have five hundred thousand inhabitants or more, any surplus fund derived from the sale of lunches may, in the discretion of the board of education of the city, be used to furnish lunches at less than cost to the public school pupils of compulsory school age who would otherwise be unable, by reason of insufficient nutrition, to attend school and to pursue the courses of study prescribed.