Testing Your Installation
To ensure that you have a usable installation, you need to test it. It’s impor- tant to know that your installation will work as expected when you need it. Of course, this means writing your first Python application. To get started, open a copy of IDLE. As previously mentioned, IDLE automatically displays the Python version and host information when you open it (refer to Figure 2-6).
To see Python work, type print(“This is my first Python program.”) and press Enter. Python displays the message you just typed, as shown in
Figure 2-9. The print() command displays onscreen whatever you tell it to display. You see the print() command used quite often in this book to dis- play the results of tasks you ask Python to perform, so this is one of the com- mands you work with frequently.
The print() command displays whatever information you tell it to print.
Notice that IDLE color codes the various entries for you so that they’re easier to see and understand. The colors codes are your indicator that you’ve done something right. Four color codes are shown in Figure 2-9 (although they’re not visible in the print edition of the book):
- Purple: Indicates that you have typed a command
- Green: Specifies the content sent to a command
- Blue: Shows the output from a command
- Black: Defines non-command entries
You know that Python works now because you were able to issue a command to it, and it responded by reacting to that command. It might be interesting to see one more command. Type 3 + 4 and press Enter. Python responds
by outputting 7, as shown in Figure 2-10. Notice that 3 + 4 appears in black type because it isn’t a command. However, the 7 is still in blue type because it’s output.
Figure 2-10: Python sup ports math directly as part of the interactive environment.
It’s time to end your IDLE session. Type quit( ) and press Enter. IDLE may display a message such as the one shown in Figure 2-11. Well, you never intended to kill anything, but you will now. Click OK, and the session dies.
Figure 2-11: IDLE seems to get a little dramatic
about ending a session!
Notice that the quit() command has parentheses after it, just as the print() command does. All commands have parentheses like these two. That’s how you know they’re commands. However, you don’t need to tell the quit() command anything, so you simply leave the area between the paren- theses blank.