Assignment 1

Python Hello World


Introduction

When learning any new programming language, one is supposed to encounter the stock example of an easy program: one that prints out ``Hello, world!''

The Task

  1. Install ActivePython (from ActiveState) ready-to-install distribution of Python.
  2. Start the ActivePython development environment.
  3. Enter File | New | Python Script. This will open a script window.
  4. Copy and paste "The Code" below into the script window. Save the file as MP01.py.
  5. Run the script file MP01.py (). Make sure the scipt file executes properly.

What You'll Turn In

Using a zip-utility, zip up the following items into a single archive (call it mp01.zip) and submit it to the homework submission system.

  1. The MP01.py file you created.
  2. A read.me file which gives a brief description of what you learned from this assignment and any probelms you had.

The Code

# filename - mp01.py
# assignment number - mp01 
# author's name - Harry Palms 
# due date - XX/XX/XX 
# course number - CS220, 
# semester - Fall, 2006 
# programming language dialect/IDE - Active State Python - ActivePython 2.4.3.12 
# description of contents of file - The Python Hello World Program. 

# example source: http://www.penzilla.net/tutorials/python/intro/
# Example of some needlessly complicated loops and other control
# structures to illustrate how indentation is used to make
# blocks of code.
# Indentation works like { and } in C or Java.

if "hello" != "world": #Colons are used at the end of control statements a lot
    # Notice the indent here
    print "hello" + " " + "world" + "!!!"
elif type(a) == type(1):
    newlist = []
    while a < 100: # Everything below here is part of this while
        list.append(a)
        for value in list: # Everything below here is part of this for
            try:
                newlist.append[math.sqrt(value)]
            except:
                print "crap!  value just happened to be negative!!!"
                print "I'm melting!"
        # The for loop ends here
        a += 1
    # The while loop ends here
    print newlist
# The if else structure (and in this case, the "program") ends here.