User:MyOwnLittlWorld/Python/Python: Interactive Mode

From Wikibooks, open books for an open world
Jump to navigation Jump to search
  • What is interactive mode?
  • Why is it useful?

Running Python in Interactive Mode[edit | edit source]

1. Open a terminal (command line) window

  • Windows: Go to "Start" -> "Run" -> "cmd"
  • Linux: See your documentation.
  • Mac OS X: Go to the Applications/Utilities folder and double click "Terminal".

2. Type "python" and hit Return.

If you see something like:

Python 2.3.4 (#2, Aug 29 2004, 02:04:10) 
[GCC 3.3.4 (Debian 1:3.3.4-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

Congratulations, you've got Python working on your system!

If not, python probably isn't installed properly.

Using Interactive Mode[edit | edit source]

  • What does interactive mode look like?

When you start Python in interactive mode, it will start by showing:

>>>

This is Python's way of telling you that you are in interactive mode. In interactive mode, you can type Python commands and see the results once you hit Return. To quit interactive mode, type Ctrl + D.

To try out interactive mode, at the ">>>" prompt, type the following, and then hit Return:

 print "We are the knights who say Ni!"

Congratulations, you've just made your first Python program!