Certified Python Developer Learning Resources The Prompt

Learning Resources
 

The Prompt


The Interpreter Prompt

Start the interpreter on the command line by entering python at the shell prompt.

GNU/Linux and BSD users who have installed Python 3.x alongside Python 2.x may have to start the Python 3.x interpreter by entering python3 at the shell prompt.

For Windows users, you can run the interpreter in the command line if you have set the PATH variable appropriately. In order to open the command line in Windows, open the start menu and click 'Run'. In the dialog box, type 'cmd' and press enter; you now have everything you need to get started with python in the DOS prompt.

If you are using IDLE, click on StartProgramsPython 3.0IDLE (Python GUI).

Now enter print('Hello World') followed by the Enter key. You should see the words Hello World as output.

   $ python
   Python 3.2.2 (default, Sep 14 2011, 09:07:29) [MSC v.1500 64 bit (AMD64)] on win32
   Type "copyright", "credits" or "license()" for more information.
   >>> print('Hello World')
   Hello World
   >>>

Notice that Python gives you the output of the line immediately! What you just entered is a single Python statement. We use print to (unsurprisingly) print any value that you supply to it. Here, we are supplying the text Hello World and this is promptly printed to the screen.

How to Quit the Interpreter Prompt
If you are using IDLE or are using a GNU/Linux or BSD shell, you can exit the interpreter prompt by pressing ctrl-d or entering exit() (note: remember to include the parentheses, '()') followed by the enter key. If you are using the Windows command prompt, press ctrl-z followed by the enter key.
 
-Swaroopch
 For Support