There are a couple of ways to start using Python. One is called IDLE, and that’s the one we will use for now. In the Start menu, under Python 2.5, you will see IDLE (Python GUI). Click this option, and you will see the IDLE window open up. It should look something like the window below.

Let’s give Python our first instruction. Type print “e0w p0whz!” in the end of the “>>>” prompt.
In programming, print often means to display text on the screen, instead of printing it on a piece of paper using your printer. Let’s try another one. Type print 4 + 6 in the end of the “>>>” prompt.
Python can do addition, subtraction, multiplication and division. Try these. Type print 1234567898765432123456789 * 9876543212345678987654321 in the end of the “>>>” prompt.
The examples we’ve looked at so far are single Python instructions (in interactive mode). While that’s great for checking out some of the things Python can do, those examples are not really programs. As I mentioned before, a program is a number of instructions collected together. So let’s make our first Python program. First, you need a way to type in our program. If you just type it in the interactive window, Python won’t “remember” it. You need to use a text editor (like Notepad for Windows or TextEdit for Mac OS X) that can save the program to the hard drive. IDLE comes with a text editor that is much better for what you need than Notepad. To find it, select File > New Window from IDLE’s menus. You will see a window like in the figure below. The title bar says “Untitled” because you haven’t given it a name yet.
Try this example.
Click “f5” to run your program, but make sure you save your project first. Add *.py to the name of your project. This will be the output.
This is your intro to your programming experience. Be back for other lessons.
No comments:
Post a Comment