CS111 Lab 1: Introduction



Image Source

Ephemeroptera, meaning "short-lived", is an order of insects commonly known as mayflies. These insects actually live for as long as several years as larvae, but only live as adults for a few hours or days. For this lab, you will write a program that calculates how many adult mayfly lifespans a person has lived. Use 4 days as a "maximum" lifespan for ephemeroptera. To calculate this result, you will need to first calculate age in days (age should be specified as years, months, and days), and then divide the result by 4. A starting program is given.

This lab is intended to help you become familiar with running programs on Python. It is intended to be completed on Ubuntu Linux in the MLH 310 lab, however if you have a Unix-like environment on your own computer, this will work just fine. OSX probably has Python already installed, and you can obtain a terminal in finder. Windows is somewhat more complicated, and I would recommend using a computer in MLH 310 this week, and either installing Cygwin or using IDLE for the rest of the class.

A demo of the procedure will be given at the beginning of lab. In brief, the series of steps to complete the lab is:

  1. Download the starting program from the class examples area or here. You can either do this from a web browser, or just open a terminal and use this line:
     wget http://isoptera.lcsc.edu/~seth/cs111/examples/lab1start.py 
  2. If you haven't already, open a terminal, and use "cd" to navigate to the directory where you saved the file. If you used the wget line above, skip this step.
  3. Run the program, by entering
     python lab1start.py 
  4. Make a copy of the program, optimistically named lab1finished.py
     cp lab1start.py lab1finished.py 
  5. Open up the program in gedit. The ampersand runs gedit in the background, so you can keep using your terminal.
     gedit lab1finished.py & 
  6. Add to the program so it works. You can test the program at any time by entering
     python lab1finished.py 
  7. Once the program works, show me.
Using OSX on a Mac is similar, but not identical. You probably won't have gedit installed, and might not have wget either. But the principle is the same. Download lab1start.py, save it somewhere you can find it, open a terminal, run it, copy it to lab1finished.py, finish the program, and test it. If you try to open the file, OSX will probably open it in a program you can use to edit it. But, you may prefer TextWrangler.