Flyhiee

Introduction to python IDLE

By Amit Pratap Singh , India
Introduction to python IDLE

 Before you Write and run Python code , you need to make sure the Python interpreter is on your computer.

Let's check your computer for Python 3. Open up a command-line prompt:

If you are using Mac OS X or Linux, Type:

python3 -V (That's an UPPERCASE "V")

On windows , Type: c:\Python31\Python.exe -V

Without the UPPERCASE "v" you are taken into the Python interpreter.

Use the quit() Command to exit the interpreter and return to your OS prompt.



Use IDLE to help learn Python



 IDLE lets you write code in its full-featured code editor as well as experiment with code at the Python Shell

When you first start IDLE, you are presented with the "triple chevron" prompt (>>>) at which you enter code.

To open idle , open terminal and type idle.

The print() BIF (Built-in function) displays messages to standard output (usually the screen).

Unlike other C-based languages, which use { and } to delimit blocks, Python uses indentation instead.

TAB completion



Start to type in some code, and then press the TAB key. IDLE will offer suggestions to help you complete your statement.



Recall code statements



 Press Alt-P to recall the previous code statement entered into IDLE or press Alt-N to move to the next code statement (assuming there is one). Unless you’re ona Mac, in which case it’s Ctrl-P and Ctrl-N.



Create simple Python lists



 names = [“Amit”, “Ankit”, “Aditya”]
To turn the human-friendly list into a Python-friendly one, follow this four-step process:

1. Convert each of the names into strings by surrounding the data with quotes.

2. Separate each of the list items from the next with a comma.

3. Surround the list of items with opening and closing square brackets.

4. Assign the list to an identifier (movies in the preceding code) using the assignment operator (=).