To answer your first question, "can a nonprofit operate a for-profit," there is nothing that prohibits this and it happens fairly frequently. Depending on the details, the for-profit enterprise can be a wholly- or majority-owned subsidiary of the nonprofit. You will want to be very careful that the for-profit activities of the subsidiary do not overwhelm the nonprofit activities (in which case the IRS will question whether the nonprofit is in fact "organized and operated exclusively" for exempt purposes.) And you would want to structure the relationship between the two to avoid the for-profit seeming to be just an arm of the non-profit.
But your question also raises the question of whether you would need to consider the school to be "for-profit enterprise" at all. One of the "exempt purposes" of Section 501(c)(3) is "educational," so your school does not necessarily need to be structured and run as a for-profit. (For example, the University of Chicago is a 501(c)(3) public charity educational institution, despite the fact that it has more than $15 billion in assets and more than $4 billion per year in revenue. You might consider establishing your 501(c)(3) as the successor to the current for-profit entity, and just keep the school within the structure of the new non-profit. That's not unusual either.
A nonprofit organizations attorney can talk you through some of the details and give advice tailored to the facts of your situation.