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 Department's Portal

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.)

Objective: Introduction to Python Programming

Objective: Write your Own Programs

Your programs will be graded on both correctness and style.

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

  1. Write a Python program called info.py that prints out information about yourself. The info printed should list your name, favorite sports team (could be professional, college, or other), favorite color, and favorite dwarf (Sleepy, Sneezy, Happy, Grumpy, Dopey, Bashful, or Doc). Don't forget to document your program appropriately!

    The output should looks something like:

    Example Output:
    Name: Sara Sprenkle
    Favorite team: Duke
    Favorite color: purple
    Favorite dwarf: Doc

    After you are sure that your program works and you have saved your program, start or restart IDLE. (This is an ugly, inefficent way to do things if you were using IDLE to develop your program, but you want a "clean" shell to demonstrate that your program is working correctly.) Execute your program to demonstrate that your program works. Save the output from the shell in a file called info.out.

  2. Copy second.py into a file called trianglearea.py. Modify the program so that it computes the area of a circle. Your program should take as input the circle's radius and then prints out the area of the circle.

    Example Output:
    Enter the radius: 3
    The area is 28.27431 square units.

    After you are sure that your program works and you have saved your program, start (or restart) IDLE. Execute your program several times to demonstrate that your program works. Save the output from the shell in a file called trianglearea.out.

  3. Create a printable version of your lab assignment using the command: /home/courses/cs111/handouts/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 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. 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.

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. 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 2:25 p.m. on Friday.

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

Grading (110 pts)