Go to: Na-Rae Han's home page  

Python 3 Notes

        [ HOME | LING 1330/2330 ]

Tutorial 1: 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

Video Tutorial


Python 3 Changes

print(x,y) instead of print x, y

input() instead of raw_input()

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.
  • To open an editor screen, "File -> New File"
  • print('hello world!') in script hello.py. Note the parentheses ( ), which was not used in the video, because it uses Python 2.7. We are using Python 3, therefore the syntax is print(...) for us.
  • "File -> Save As", name your file "hello.py".
  • F5 to run
  • Shell restarts and prints out 'hello world!'
  • 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.
  • input() (raw_input() in Python 2.7) 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