Python IDLE and Shell

Python IDLE and Shell are both ways of compiling Python scripts, and have quite different uses. This short tutorial explains how to use them.

Using IDLE

1. Open your Terminal (on Ubutnu or Mac) or Windows Shell (on Windows). You should get a Window like this:

Terminal.jpg

2. Type in Python to enter the IDLE mode:

PythonIDLE.jpg

3. Now you can paste in your code, starting at a new prompt(">>>"). Press Ctrl-Z when you want to quit:

IDLEUSE.jpg


Using Terminal

Using Terminal is more convenient if you have longer programs, or you cannot copy with indentation. 1. Open your Terminal (on Ubutnu or Mac) or Windows Shell (on Windows). You should get a Window like this:

Terminal.jpg

2. Suppose I've saved my file in A directory called Desktop/AoPS/Intro to Programming. So I type ('change directory'): cd Desktop/AoPS/Intro to Programming

EnterDir.png

3. The file that I want to run is called test.py. So I run it with the command: python ./test.py (Note: depending on your operating system, you may have to omit the "./" before the filename)

TerminalResult.jpg

Benefits

Benefits of IDLE

  • Compile short bits of code
  • Don't need to re-save
  • Test your ideas out

Benefits of Shell

  • Test longer scripts
  • Save well developed programs for later
  • Easily manipulate indentation