Page 42 -
P. 42

starting to code


           Prepare and run your code


           The next step is to prepare your program code for execution. To do this,   If you choose File → Save
           select File → Save from the menu to save your program code to a file.   from the menu, you can save
           Choose an appropriate name for your program.                       your code in a file.









            Python program
            filenames usually
            end with “.py".




                                                                                  Click the Save button to
                                                                                  create and save the file.
           Python programs are usually saved in files that end with .py, so let’s call
           this program game.py.
           It doesn’t really matter to IDLE which directory you save the file in. Some
           coders like to create special directories for each new programming project.
           But for now, just save the code in some directory that’s easy to remember.

           Now, let’s see what happens when we run the program.






                                                              In the IDLE edit window,
                                                              go to the “Run" menu and
                                                              choose “Run Module."


















                                                                                         you are here 4    7
   37   38   39   40   41   42   43   44   45   46   47