Skip navigation.

CS 135 Programming Logic

Urn World Tutorial

Printing Output for your Homework

For your homework, you need to figure out how to print both the program source code and the output when you run your program. Printing the source code is easy. With your Python program in focus, go to File -> Print and then select some flavor of printing. For example, File -> Print -> Print Preview will show you what the source code printout will look like. Another way is to click on the printer icon in the toolbar. However, printing program output requires some preparation.

First, create a template file named PRINT.txt, or some other name that suggests output. It does not have to be a text file, but it will be easier to find if it is. You will reuse this file for all your output printing.

Create a template print file

Here is a list of keyboard combinations that you will use. These are called shortcuts (you do not need to capitalize).

Shortcut Meaning
Ctrl+A Select All
Ctrl+C Copy selected to the clipboard
Ctrl+R Run program
Ctrl+S Save file
Ctrl+V Paste from the clipboard
Ctrl+Z Undo the last change

To print the output of a program:

  1. Run your program: Select your program file and type Ctrl+R. This assumes that you have set up the Ctrl+R shortcut for the run command. However you do it, you want your program output to show up in the Command Output tab.
  2. Copy the output: Click anywhere in the Command Output panel and then type the following sequence to copy all the output to the clipboard.
    1. Ctrl+A
    2. Ctrl+C
  3. Paste the output into a printable file: Click at the top of the printer template file and type a Ctrl+V. This copies your output into the printer template file.
  4. Print the output: Print the the printer template file. Use either File -> Print ..., or click on the printer in the toolbar.
  5. Undo the paste: Make sure the printer template file has the focus and then type Ctrl+Z. This undoes the previous Ctrl+V so your printer template is empty again and return for another print sequence.

Picture illustrating the steps in output printing

Printing the results of the output of a program that was run in a new command window is a little touchier. You have to right-click on the title bar and then use the mouse to Edit -> Select...  After selecting everything, click on the title bar and select Edit -> Copy. Once copied into the clipboard, proceed as above with steps three, four and five.

All of this sounds imposing, but it is easy once you have done it a few times.