Game Development Reference
In-Depth Information
3 - Strings
lists the differences between Python 2 and 3 that you will need for this topic.
Opening The Programs You've Saved
To load a saved program, choose File > Open . Do that now, and in the window that
appears choose hello.py and press the Open button. Your saved hello.py program should
open in the File Editor window.
Now it's time to run our program. From the File menu, choose Run > Run Module or
just press the F5 key on your keyboard. Your program should run in the shell window that
appeared when you first started IDLE. Remember, you have to press F5 from the file
editor's window, not the interactive shell's window.
When your program asks for your name, go ahead and enter it as shown in Figure 3-5:
Figure 3-5: What the interactive shell looks like when running the "Hello World" program.
Now, when you push Enter, the program should greet you (the user ) by name.
Congratulations! You've written your first program. You are now a beginning computer
programmer. (You can run this program again if you like by pressing F5 again.)
How the "Hello World" Program Works
How does this program work? Well, each line that we entered is an instruction to the
computer that is interpreted by Python in a way that the computer will understand. A
computer program is a lot like a recipe. Do the first step first, then the second, and so on
until you reach the end. Each instruction is followed in sequence, beginning from the very
top of the program and working down the list of instructions. After the program executes
the first line of instructions, it moves on and executes the second line, then the third, and so
on.
We call the program's following of instructions step-by-step the flow of execution , or
just the execution for short.
Now let's look at our program one line at a time to see what it's doing, beginning with 23
Search WWH ::




Custom Search