| CPSC 115L: Introduction to Computing | Fall 2010 |
Writing and running a Python script. In the interactive mode, a Python interpreter does not allow you to save your code in a file. Everything you wrote will be lost when you exit from your interactive session. Alternatively, in the script mode, you can save your code in a file, called a script. Before working on a script, you should first create a directory to save today's work. Using the File Browser, inside your cpsc115 directory, create a subdirectory named lab1 (in general, at the beginning of each laboratory, you should create a unique subdirectory for it). Now, in the blank tab Untitled 1, type againprint 'Hello, World!'
as follows:print 'Hello, World!'
Save your file and execute it. Do you see a different result? This script is permanently saved in your own personal file space, and it will remain there as long as you wish, until you delete it.print 'Hi there!' print 'How are you?'
Following this example, put a header in the file helloworld.py.# # File: helloworld.py # Author: Takunari Miyazaki # # Created: 01/26/10 # Modified: 01/26/10 #
|
|
CPSC 115L home page |
|
|