Difference between revisions of "Python IDLE and Shell"

(Created page with "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 ...")
 
(Using Terminal)
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
=Using IDLE=
 
=Using IDLE=
 
1. Open your Terminal (on Ubutnu or Mac) or Windows Shell (on Windows). You should get a Window like this:
 
1. Open your Terminal (on Ubutnu or Mac) or Windows Shell (on Windows). You should get a Window like this:
 +
 
[[File:Terminal.jpg]]
 
[[File:Terminal.jpg]]
  
 
2. Type in Python to enter the IDLE mode:
 
2. Type in Python to enter the IDLE mode:
 +
 
[[File:pythonIDLE.jpg]]
 
[[File:pythonIDLE.jpg]]
  
 
3. Now you can paste in your code, starting at a new prompt(">>>"). Press Ctrl-Z when you want to quit:
 
3. Now you can paste in your code, starting at a new prompt(">>>"). Press Ctrl-Z when you want to quit:
 +
 
[[File:IDLEUSE.jpg]]
 
[[File: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:
 +
 +
[[File: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
 +
 +
[[File: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)
 +
 +
[[File:TerminalResult.jpg]]
  
 
=Benefits=
 
=Benefits=

Latest revision as of 12:26, 2 April 2012

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