In Class: Week 1 Monday

Complete lab 0 before trying this.

If you want to try out a python program do the following (we will do something like this in class on Wednesday, so if you do not get through this, that is okay):

  1. create a subdirectory class in your cs21 directory:
          % cd 
          % cd cs21
          % mkdir class
          % cd class
          % pwd
  2. create a week01 subdirectory of your class directory
          % mkdir week01        # do this from your cs21/class subdirectory
          % cd  week01
          % pwd
  3. open a new file named in vim and type in the following python code (indentation is important), save and exit vim (:wq):
      def main():
          print "hello there!"
  4. at the Unix prompt run the python interpreter on your program and you should see it print the message "hello there!" to the terminal:
      % python
        hello there!
    you can also run this program on the python interpreter in interactive mode:
      # runs in interactive mode:
      % python -i
    >>> is the python interpreter prompt, at this prompt you can enter other python code that the interpreter will interpret:
      >>> print "hello, who are you?"
    To exit the python interpreter hold down the control and the D keys together (CNTL-D)

    you can also just start the python interpreter in interactive mode without giving it a python code file to run:

      % python