CS 100 - Computer Literacy

Fall 2004

Lab 9

For this lab, you are to write a jython function using JES that will select an image file and display it.

Variables in JES

A variable is a method to store information from one statement so you can use that information in another command. A variable can be any name; however, you can not have any spaces in the name. Often the name will be in lower case except for the first letter of each word used in the variable. You normally want to give the variable a name that somehow reflects the information stored in the variable. For example, if the variable is storing the name of a file, you may give it the name of myFile. Below is a few examples of variable names.
    myFile
    distanceHome
    carSpeed
    boatSpeed
    airSpeed
You store a value in a variable by using acommand called an assignment statement. The syntax of an assignment statement is to For example, let us look at a few assignment statements that will calculate the circumference and area of a circle with radius of 5. For this example, we will use the variable names of radius, circumference and area. This example is shown as if the commands are typed in the command area of JES. The information in bold type is what you would type. The variable of pi is already known by JES.

>>> radius = 5
>>> circumference = pi * 2 * radius
>>> area = pi * radius * radius
>>> print circumference
31.41592653589793
>>> print area
78.53981633974483
>>>

Another good command to know is showVars(). This command will open a window that will list all of the known variables, the values of the variables and the types of the variables. We will discuss types later. Try typing in the above commands into JES.

New JES Commands

Lab 9

Due: Friday 10/29/2004 by 8:00 am

Write a JES function that will do the following things:

The result from the pickAFile() command should be saved in a variable. This variable will be used as the input for the makePicture() command.

The result from the makePicture() command should be saved in a variable. This variable will be used as the input for the show() command.

This function is to be saved to a file and load so it can be executed in the command area of JES.

On the ACCC lab computers, the H: drive is a permanent storage area for you. Saving files to this drive on one computer can be accessed from another computer (even another computer in a different lab). It is suggested that you save your python programs to the H: drive.

You are to submit your lab program using turnin on the icarus machine using the project name of lab9. You will need to transfer your program to the icarus machine so you can turn it in. You can do this by mailing it to your icarus account or by using the file transfer window in SSH. To submit the file in <filename>.py for lab9, the turnin command is entered as:

     turnin -c troy -p lab9 <filename>.py