Mini-Lab: Getting Started with JES



The objective of this mini-lab is to become familiar with the programming environment JES (Jython Environment for Students) which will be used in COMP107.

Becoming familiar with JES

  1. Start JES (Start -> All Programs -> JES). It may take a little while to start.
  2. To start becoming familiar with the JES graphical user interface, type some simple Python commands into the command area. (This is the bottom half of the JES window.) Try typing in the various examples from Exercise 1 in the reading (Programming in Python and JES). The first few examples should look like these simple commands:
    print 3 + 4
    print "Hello class"
    print "Hello" + "class"
  3. Look at the Follow-up Analysis questions from Exercise 1 in the reading. Make sure you understand these.
  4. Click on the Help menu, and browse through Sections 2 (Getting started with JES) and 3 (Programming in Jython).

Working with picture files

Some of the following exercises will have questions to be answered and turned in at the end of the mini-lab.
  1. In the JES command area, type the following command (make sure upper/lower cases are exactly as given here):
    myFile = pickAFile()
    A file selector will open. Choose a JPEG (.jpg) file from the \My Documents\My Pictures\Sample Pictures folder. (Or, if you prefer a wider selection of images, copy several images from the MediaSources directory to your own M: drive, or a folder on your own hard drive.)
  2. Type the same command in the program area of JES. Highlight the text pickAFile (without the parenthesis), then click on the Explain pickAfile button on the bottom of the JES window. What is this function pickAFile() doing? Write down your answer in a complete sentence on a new sheet of paper.
  3. Type the command print myFile into the command area. What is printed? Using sentences, write down the result and explain what this command is doing.
  4. Now type in the command myPict = makePicture(myFile). Again, type the same command in the program area, highlight makePicture, then click on the Explain makePicture button on the bottom of the window. Write down what this function is doing.
  5. Type the command print myPict. What is printed? Write down your result.
  6. Type the command show(myPict). A new window should appear with your picture displayed.
  7. Go to the JES menu item MediaTools, select Picture Tool..., and choose the picture myPict. After clicking OK, another window will pop open which shows the picture.
  8. Experiment with the features provided by the picture tool: change the zoom level and look at the color values at different points of the picture by clicking on those points. (Note that color values may not display correctly unless the picture is zoomed at 100%.) Write down which image file you used, and the highest and lowest values you find for red, green, and blue.

Working with sound files

Complete the following exercises if you have time.
  1. Use the pickAFile function to select a sound file from the MediaSources directory:
    soundFile = pickAFile()
    The sound files have a .wav extension.
  2. Now type in the command sound = makeSound(soundFile).
  3. Try playing the sound using the play function: play(sound). If nothing happens, make sure that the volume isn't turned all the way down on your computer.
  4. Turn in your answers to the questions in these exercises.