Lab 0

Welcome

The purpose of this first lab is to familiarize you with the environment you will be using in this course. In particularly, this lab will introduce you to the Linux operating system.

The computer workstations in our lab can run both Windows and Linux operating systems. We will use the Linux operating system in this course.

Note: Outside of lab, you may access your Linux account from any computer connected to the Internet, provided you have the right access software, e.g., a secure shell client program. Some work for this course you can do from any computer, but most work you will have to do directly on the Linux machines.

Goals for Lab Zero

This lab is a "warm up" for the semester. We want to make sure that you are comfortable with the environment before you start to program.

After the lab, you should know how to

  1. log in and out of the Linux machines, and set up your account for this course
  2. access the Web on the Linux machines
  3. access the CS111 home page
  4. using the Department's Portal
  5. create a text file with a text editor
  6. write basic HTML files and display them online
  7. create a Python program, run it, create output files, print, and submit it

If you can do all those things, you are all set for the course!

Objective: Learning to Use the Linux Machines

For this part of the lab, work through this document and do the exercises. Hand in the worksheet before you leave lab.

Objective: Using the CS Department's Portal

We will use the CS Department's Portal for submitting write-ups for the "Broader Issues in Computer Science" part of the course.

Note: If you took CS101 and logged into the system before you can continue using the same password for the system. Login and then skip to step 3.

  1. Use your W&L username and the password given by the instructor to log in to the Department Portal.
  2. Change your password after logging in by selecting "User Profile" under "Member Options" on the right.
  3. Navigate to the "Blogs" from the top menu bar.
  4. Select the blog for this course and read over the existing entries.

Objective: Using the Text Editor and Creating an HTML File

For this part of the lab, we're going to create a web page using a simple text editor. Creating web pages isn't what a computer scientist usually does. However, the Web is a great venue for a computer scientist to share her work with the world! (Or to create resources and information for her amazing students.)
  1. Open a terminal using the shortcut icon you made earlier.
  2. Go into your public_html directory. This is where you will put files that you want others to see on the Internet.
  3. Copy the example.css, example.html, and example.gif files from /home/courses/cs111/handouts/lab0 into your public_html directory. (Recall: what is the special name for the current directory?)
  4. Open another tab in your browser so that you can switch between the lab instructions and your work. Point your browser at the location: http://www.cs.wlu.edu/~yourusername/example.html You should see the example web page. If you get an error message in the browser window, ask for help.
  5. Point your browser at the location: http://www.cs.wlu.edu/~yourusername/
    What do you see?
  6. Copy example.html into a file named index.html. Now, point your browser to the location: http://www.cs.wlu.edu/~yourusername/
    What do you see?

    (We can talk about what's going on here more later in the course, but for now, just realize that index.html hides the contents of your web directory.)

  7. Type jedit index.html &

    The "&" (called the "ampersand") is a special command to let the terminal know that you want the program to open in a new window and let you keep using the terminal window too. I will also refer to the ampersand as saying that you want the command to "run in the background".

    jEdit is a "text editor", i.e., a program that helps you create files. jEdit looks similar to a Word Processor. Look through some of the menus and you'll notice a lot of functionality that you'd see in a typical Word Processor, such as save, open, copy, and paste.

  8. Edit the file so that the title (inside the <title> tags) and the top-level heading (inside the <h1> tags) say <Your Name>'s Web Page. Save the file. Reload the page in the browser... How cool is that?

    Note that the page has several links to other online documents in it. The HTML Help link is useful if you want to develop more web pages after this brief introduction.

  9. You will add two more links to the page. The first link will be to some online article about computer science. See the Extra Credit page for ideas on how to find such an article. You may want to search for an article after lab, depending on your time constraints, because we still have a lot to do in this lab.
    The second link will be to the CS111 student sitting to your right. If you're in the rightmost chair, you'll link to the leftmost person in the row behind you. If you're the back, rightmost person, you'll link to the leftmost person in the first row. Find out the person's full name and username to create the link. The text for the link should include the person's year, e.g, first-year, sophomore, too. We'll create a "ring" of CS111 students.

    Note the pattern of the links in the HTML file. How would you create a link to CNN? (You will perform similar activities throughout the course. You'll look at example code that does something similar to what you want to do, copy the code, and modify the code to do what you want.)

  10. Next, add an image to your web page. Find an image from the web. Save the image into the appropriate directory. Change the image (img) tag in your web page to display this image.
  11. Don't forget to update the information at the bottom of the page as well, to give yourself credit for your work.

    Note that you didn't need any fancy software to be able to create a nice web page. I create my web pages for the course in a similar manner.

Objective: Introduction to Python Programming

Objective: Write your Own Programs

Your programs will be graded on both correctness and style. Style will become more important as the semester continues.

Note that the convention is that the names of Python scripts end in ".py".

Finishing up: What to turn in for this lab

  1. Turn in your UNIX worksheet to the instructor before leaving lab.
  2. Copy your lab0 directory into the turnin directory. (Review the UNIX handout if you don't remember how to do that.)
  3. Create a printable version of your lab assignment using the command: printLab.sh <labdirpath>
    In this case, your lab directory path is the path to "lab0". If you're currently in the lab0 directory, it's easiest to "go up a level" to the parent directory and use the script.

    The script printLab.sh creates a condensed version of your lab in a postscript file called lab0.ps. To save paper, the script puts two pages on a piece of paper. The script also highlights the Python code appropriately.

  4. View your printout using the command gv lab0.ps
    gv is short for "ghostview" and allows you to view postscript files, which are suitable for printing. Your file should not be more than a few pages. Otherwise, you're printing too much. See the instructor or student assistant if you're having trouble.
  5. Print the assignment using the command lpr -P<printername> lab0.ps
    The printer name is cslab when you're in P405 or advlab if you're in P413.
    The command lpr means to print the file. The option 'P' says which printer to use (one of the CS lab printers), and the argument says which file to print--in this case lab0.ps.

    Turn in your printed lab assignment.

Labs are due at the beginning of Friday's class. You should hand in the printed copy at the beginning of class, and the electronic version should be in the turnin directory before 1:20 p.m. on Friday.

Ask well before the deadline if you need help turning in your assignment!

Grading (100 pts)