Go to: Na-Rae Han's home page  

Python 2.7 Tutorial

With Videos by mybringback.com

#2: Intro to Python and IDLE

                          << Previous Tutorial           Next Tutorial >>
On this page: how to run commands in Python IDLE shell, writing and saving a Python script file, executing a script via F5, command-line history shortcuts

Get Started

Video Summary

  • We will be using Python's own IDLE as the GUI
  • Python IDLE opens up in a shell. You can type code in get the result out. (shell output)
  • To open an editor screen, "File -> New Window"
  • print 'hello world!' in script hello.py
  • "File -> Save As", name your file "hello.py". YOU MUST INCLUDE .py IN THE NAME.
  • F5 to run
  • Shell restarts and prints out 'hello world!' (shell output)
  • Open an already-written script lesson01.py
  • Take a look at "Options" and configure IDLE if you wish

Learn More

  • On Macs, the shortcut for running your script is Fn + F5. In some Windows systems, it may be Fn + F5 or Ctrl + F5.
  • Another important set of IDLE shortcuts are the ones for accessing command-line history: Alt + p/n (p for previous, n for next) in Windows, and Ctrl + p/n in Mac. These shortcuts let you scroll through the list of previously entered commands. You can even edit them before pressing ENTER. This is handy because you no longer have to type everything from scratch! See this and this FAQ for details.
  • raw_input() is a built-in function for accepting a keyboard input. It will be explained in a later tutorial.
  • IDLE stands for Integrated DeveLopment Environment (for Python), but there is another, widely accepted, theory behind the naming.

Explore