How to write this program in Python?
<pre><code>def scaleImage(image):
    """
    A function that takes an image and makes each pixel grayscale:
    the red, blue, green components are the average of the respective
    components in each original pixel.
    """

    pix = image.getPixels()

    # How can I condense the following loop?

    newimage = Image()
    for pixel in pix:
        newpixel = ((int(pixel[0]) + int(pixel[1]) + int(pixel[2]))/3,
                    (int(pixel[0]) + int(pixel[1]) + int(pixel[2]))/3,
                    (int(pixel[0]) + int(pixel[1]) + int(pixel[2]))/3,
                     int(pixel[3]))
        newimage.setPixels(newpixel)

    return newimage
</code></pre>

<p>My task is to write a function showScale() that asks the user for an image filename, then displays both that image and its grayscale version in a window.</p>

<pre><code>def showScale():

    filename = raw_input("The name of the image file? ")
    picture = Image.open(filename)
    newpicture = Image.open(scaleImage(picture))
    newpicture.show()
</code></pre>

<p>Question1. Should I use cs1graphics module to make it work?</p>

<p>Question2. How should I change my code to answer my task?</p>
