Yliopiston etusivulle In English
Helsingin yliopisto
clt230: Introduction to Programming - lukuvuosi 2009-2010


Yleisen kielitieteen laitos

PL 24 (Unioninkatu 40)

Puhelin +358 (09) 1911 (vaihde)
Faksi +358 (09) 191 28313

7. Importing Modules. Program Design.

  • Lecture notes
  • Further reading
  • Practical work
    • Add Python to your PATH
      In the Start menu, right-click "My Computer" and select "Properties".
      In System Properties, select "Advanced" and "Environment Variables".
      In Environment Variables, create a new user variable with name "PATH" and with value "C:\Python26". Click "OK" 3 times.
      Start a command prompt window and type "python". Check that the Python interpreter starts, with the ">>>" prompt. Type "exit()" followed by "exit".
    • Download Swampy
      Create a folder "My Documents\clt230" under your username.
      Download swampy.1.1.zip and save it in "My Documents\clt230".
      Unzip it (7-Zip: Extract here) giving "My Documents\clt230\swampy.1.1".
      Check that the folder swampy.1.1 includes the file TurtleWorld.py.
    • Run the TurtleWorld GUI
      Start a command prompt window. Change directory (cd) to get to the swampy folder. Start the TurtleWorld GUI by typing "python TurtleWorld.py".
      Swampy: Installation Instructions shows how to use the TurtleWorld GUI.
    • Add Swampy to your PYTHONPATH
      Go to Environment Variables again, and create a new user variable "PYTHONPATH" with value "C:\Documents and Settings\username\My Documents\clt230\swampy.1.1" (with your own username).
      Now you can import TurtleWorld without being in the swampy folder.
    • Program design
      In your folder "My Documents\clt230", create a script polygon.py using a programming text editor such as jEdit or IDLE.
      Work step-by-step through the examples in Case study: interface design.
© 2001-2009 Graham Wilcock