write_sagews function below creates a Sage worksheet with any desired input. It does not yet let you specify the output, though you can put %auto at the start of a cell to evaluate it when the user opens the worksheet (thus generating output).
write_sagews is pure Python (except %auto); you can copy it into any Python script to generate worksheets.
Test this out -- if it is useful to people, I'll make a more general version just be built into SMC.
Try it out: