CS8, Fall 2010

lab00: ("lab zero")
Orientation to Python, CSIL, the Cooper Lab,
and submitting assignments via the turnin program.


Each indvidual student should complete this lab for himself/herself.

Goals for this lab

By the time you have completed this lab, you should be able to

That's a bit general, so let's get more specific...

This assignment is designed to make sure you are comfortable working in the Python environment and know how to submit your work. So, this lab is mostly about mechanics, not concepts. As a result, this assignment is not particularly intellectually challenging. I hope that will not be the case in future labs!

Step by Step Instructions

Step 0: If you haven't created your College of Engineering Account", do so now.

Ideally, before this lab begins, you will have been instructed to visit the link below, and create your "College of Engineering" computer account:

If you already did that, then wonderful! Proceed to step 1.
Otherwise, if you've arrived at your lab session without having already done this:

If it doesn't work

If you try to create a College of Engineering account, and it doesn't work, then send email to support@cs.ucsb.edu. In your email,

Note that if you are not enrolled in the course on GOLD, you normally cannot get a College of Engineering account unless you get an invitation from your instructor. If there is some problem with your GOLD registration, but you still need to start the work in the course speak with your instructor about this.

Step 1: Locate a computer in CSIL or Cooper lab

The purpose of this lab is to orient you to the computers in CSIL and Cooper.

So while, in future weeks, you may be able to do some of your work on your own PC, Mac or Linux computer, this particular lab must be completed in Cooper or CSIL.

Finding Cooper Lab: Cooper Lab is located in the Engineering Science Building, room ESB1003. ESB is located at the corner of campus closest to the airport, furthest away from Isla Vista. ESB is divided into two parts, with a pedestrian bridge overhead. ESB1003 is in the part of the building closest to the bike path. The door to ESB1003 is on the ground floor, at the corner of that faces the airport.

Finding CSIL: CSIL is located in Harold Frank Hall (HFH). You enter from an outside door. To locate CSIL, find the "main front entrance" to Harold Frank Hall, on the side of the building that faces the ocean. Stand outside the double glass doors, with your back to the building, facing the ocean. The entrance to CSIL is now on your left.

Step 2: Logging on

When you sit down at a terminal in CSIL or Cooper lab, you'll see a prompt that asks you for your username. Enter the username that you created for your College of Engineering computer account. This is probably the same as your UCSBNetID (your umail account.)

When you are asked for a password, enter the password you chose for your College of Engineering account (which is not necessarily the same as your umail password.)

Don't worry if nothing appears on the screen while you are typing your password.

You should find that your username and password are accepted, and you get a "desktop" that looks similar to the Windows or Mac OS desktop. In fact, what you get is neither—the systems in Cooper and CSIL use "Linux", which is a different operating system.

In the rest of this lab, we'll walk you through a few of the basics of using this desktop. Most things, though will likely be pretty familiar to you, because they aren't that different from Windows or Mac.

If you got in, move on to Step 3.

If your username/password does not work

If your username/password is not accepted then:

Note: DO NOT include your password in your email to support. In fact, NEVER send your password through email, and NEVER tell anyone else your password, not even the support staff. Real support staff will NEVER ASK YOU FOR YOUR PASSWORD—not over email, and not in person. They won't need it to help you.

If someone is asking for your password over email, it is a scam called a "phishing attack"—don't be fooled by these dastardly villains.

Step 3: Bring up a web browser

To bring up a web browser:

Here's what selecting the menu looks like:

Applications, Internet, Firefox

 

Step 4: Find these instructions online

You should now be able to find these instructions online at this link:

Note that the ~ symbol (called "tilde", or "squiggle") in front of pconrad is located at the upper right hand corner of the keyboard—and it requires a shift, otherwise you'll get ` which is called the "backtick".

If you received a paper copy of these instructions, this is where the printed copy will end—to save paper, the rest of the instructions can be found online.

Step 5: Bringing up a terminal window

On the Linux systems, there are a lot of things we can do with pointing and clicking with the mouse, just like on Windows or Mac. But there are also many things we can only do with the command line, or can do more easily with the command line.

So, one of the first steps will often be to bring up a "Terminal Window", which is the Linux "command line".

Here's how:

Here's what it should look like (click on a thumbnail to bring up a bigger image)

Selecting the menu option Result
Applications, Internet, System Tools Terminal Window

Step 6: Making sure your username/password work on both Cooper and CSIL

If you are working in the Cooper lab, before we go any further, we need to make sure that your username/password also work on the CSIL computers.

If you are working in CSIL (e.g. because you missed the first week's lab and are making it up by working in CSIL), we need to make sure your username/password also work on the Cooper computers.

This is just a "check" to see if there are any problems with your account.

What we are going to do

We will try your username/password over the internet using a program called ssh, which stands for secure shell.

Here's how to do it (if you are in Cooper)

In the Terminal Window that you brought up in the previous step, enter the following command:

ssh csil.cs.ucsb.edu

When you type this at the Unix command line, you may see something like this:

-bash-3.00$ ssh csil.cs.ucsb.edu
The authenticity of host 'csil.cs.ucsb.edu (128.111.43.14)' can't be established.
RSA key fingerprint is 90:ab:6a:31:0b:81:62:25:9b:11:50:05:18:d3:1a:b5.
Are you sure you want to continue connecting (yes/no)?

Answer the question by typing yes, and pressing "enter" (or "return")

Then, you'll be prompted for your password.

Don't worry if nothing appears on the screen while you are typing your password.

If it worked, here's what you'll see something like this:

pconrad@csil.cs.ucsb.edu's password: 
Last login: Thu Aug  6 08:09:04 2009 from linux32.engr.ucsb.edu

Welcome to Computer Science's Remote Access server -- csil.cs.ucsb.edu

You may run your graphically intensive programs on specific workstations in CSIL.
-bash-3.2$

At this point, we know that you can connect to CSIL. We'll need to do again later, at the step where you are ready to submit your work for grading. But for now, we can exit from our session on CSIL by typing the word exit, like this:

-bash-3.2$ exit
logout
Connection to csil.cs.ucsb.edu closed.
-bash-3.2$ 

If you are ever not sure whether you are logged in to CSIL or not, you can type the command hostname at the command prompt. If you are logged into CSIL, it will look like this:

-bash-3.00$ hostname
csil.cs.ucsb.edu
-bash-3.00$ 

If you just have a plain terminal window in Cooper, it will look like this:

-bash-3.00$ hostname
_____.engr.ucsb.edu
-bash-3.00$ 

If you are in CSIL instead

If you are working in CSIL (e.g. because you missed the first week's lab and are making it up by working in CSIL), we need to make sure your username/password also work on the Cooper computers.

The instructions are exactly the same as those for Cooper, except the command you use is this one:

ssh linux.engr.ucsb.edu

Please follow the instructions above, and make sure that everything works properly.

Step 7: Creating some directories

At the command prompt, we are going to type several commands to create folders (called "directories") on Linux in which you can store your programs. The commands are shown in the box below—but first, a little explanation.

Each of the cd commands shown below is a command to "change directory"—that is to move into a different folder on the hard drive.

Each of the mkdir commands "makes a new directory" (i.e. a new folder).

Each of the pwd commands "prints the working directory", i.e. it tells you where you are on the hard drive.

At the command prompt, type each of these commands. What you type is shown in bold. You should get back exactly the output shown, (except that the part in italics may be different—each user will have something different show up there.)

-bash-3.00$ cd
-bash-3.00$ pwd

/cs/student/yourusername
-bash-3.00$ mkdir cs8
-bash-3.00$ cd cs8
-bash-3.00$ pwd

/cs/student/yourusername/cs8
-bash-3.00$ mkdir lab00
-bash-3.00$ cd lab00
-bash-3.00$ pwd

/cs/student/yourusername/cs8/lab00
-bash-3.00$ cd

-bash-3.00$ pwd

/cs/student/yourusername

Checking if it worked

To see if it worked, you can use the file manager on the desktop. Drag any windows that might be covering up the little icon that says "home" on your desktop—it should be near the upper left hand corner of the screen, and looks like this:

Home Directory

When you double click on this, it will bring up your home directory. You should see inside a folder called cs8. If you double click on that, you should see inside of it, a folder called lab00

Note that you could also use mouse clicks and menu options to create these folders, instead of the command line. If you have trouble with the command line, then for today, its ok to do it that way.

Eventually, though, we want you to learn some of the Unix commands also—the reasons its important to know both will become more clear as you move deeper into the study of programming and Computer Science.

Step 8: Bring up the program called IDLE

The preliminaries are done—we are now ready to really start working with Python!

IDLE is a piece of software that you use to interact with the Python programming language.

Prof. Conrad has configured a special version of IDLE that is pre-loaded with the cTurtle module used in the cs8 textbook (Python Programming in Context, by Miller/Ranum). You can bring up that version of IDLE by typing the following at the IDLE prompt:

	~pconrad/cs8/cs8idle

Note from August 2010: sometimes the first time you type this, you get an error "no such file or directory". If that happens, repeat the command—sometimes it works the second time. This is a known problem that is being worked on by support.

When you do, you should see the IDLE program come up. You can click on the thumbnail below to see what this should look like:

Typing the ~pconrad/cs8/cs8idle command The IDLE window appearing
Typing the cs8idle command IDLE Python Shell Appearing

The window that appears should have the Python Command prompt (>>>) in it.

When you have the IDLE window up, you are ready for the next step.

Step 9: Loading a file of functions into IDLE

In this step, you'll load a file into IDLE with a few of the function definitions we've talked about in lecture.

In IDLE, select "File=>New Window" to open a new "untitled" window for Python code.

When it comes up, click and drag the window by its title bar over to the right of your Python Shell window.

Here's what that looks like:

Selecting File=>New Window The "untitled" window appearing Dragging the windows so they are side-by-side
Selecting File => New Window in IDLE New window appears New windows side by side

Then, open a web browser to the link below.

http://www.cs.ucsb.edu/~pconrad/cs8/10F/labs/lab00/someFunctions.py

The contents of that file are Python code for some function definitions. You should be able to copy and paste that code into the new "untitled" window.

Now, to load those function definitions into Python, select "Run=>Run Module" (or hit F5).

Here's what that looks like:

Selecting Run=>Run Module
Run Module

 

You'll have to save the file. Save the file with the name someFunctions.py inside the cs8/lab00 folder you created in the previous step.

That will look something like this (though your screen probably wont be cluttered with quite so many folders and files):

Find cs8 and double click.
Your screen won't show /cs/faculty/pconrad; it will show your home directory instead, which will probably only have cs8 inside
Selecting cs8
Find lab00 and double click
Select lab00
Then, enter the filename you want to save as, i.e. someFunctions.py Then click Save.
Save As someFunctions.py in IDLE

Now, those functions are loaded into Python. You should see "RESTART" in the Python Shell window.

You are ready to test the functions!

Step 10. Testing the functions

To test these functions, you can type in lines like this in the IDLE window with the Python prompt (>>>).

>>> square(5)
25
>>> CtoF(100)
212.0
>>> CtoF(0)
32.0
>>> CtoF(68)
154.39999999999998
>>> CtoF(20)
68.0
>>> distance(0,0,3,4)
5.0
>>> distance(0,0,10,10)
14.142135623730951
>>> 

Then, while you are in the IDLE window, not the window with your function definitions:

You should now have two files inside your lab00 directory. You are ready to submit these for grading.

Step 11. Submit your assignment using the turnin program on CSIL

To submit your assignment, you need to bring up a terminal window on CSIL.

To start this process, we use two steps that we practiced earlier:

Next, we use the cd command that we practiced earlier:

-bash-3.00$ cd 
-bash-3.00$ pwd 
/cs/student/yourusername 

-bash-3.00$ cd cs8 
-bash-3.00$ pwd 
/cs/student/yourusername/cs8 
-bash-3.00$ 

When you are in inside your cs8 directory, you are ready for the turnin step.

Type the following at the prompt:

turnin lab00@cs8 lab00

You should be asked if you want to turn in this program. Respond "yes", and then you should get a message indicating that your efforts were successful!


Evaluation and Grading (50 pts total)

Due Date:

You should try to complete this in class today (Friday 09/24)

If you are unable to, you may submit it anytime before next Friday 10/01 at 5pm
without penalty.

If you are unable to do that, please contact your instructor to explain why. It is important to get off to a good start in the course by being familiar with how to use the basic tools.

What to do if you finish early

 


Copyright 2010, Phillip T. Conrad, CS Dept, UC Santa Barbara. Permission to copy for non-commercial, non-profit, educational purposes granted, provided appropriate credit is given; all other rights reserved.