# lab00 : Getting Started

lab00 true Getting Started Tue 10/03 08:00AM Fri 10/06 05:00PM

# Introduction

Your first lab for this week is an introduction to programming on CSIL and in the Computer Science lab. You will write your first Python program that will print a specific text output on your computer display.

## Goals for this lab

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

• use the computers in Phelps 3525 (and other labs like CSIL) to do basic things such as:
• perform basic management of directories and files
• create Python progams in IDLE
• submit an assignment using the submit.cs system

This assignment is designed to make sure you are comfortable working in the computing environment and know how to submit your work. It is mostly about mechanics, not concepts. As a result, this assignment is not particularly intellectually challenging. Future labs will require quite a bit more thought!

# Step by Step Instructions

## Step 1: Verify your College of Engineering Account(s)

The Gauchospace message that welcomed you to the course invited you to create a College of Engineering account (also known as a ECI account, or a CSIL account) at this link:

https://accounts.engr.ucsb.edu/create/

We hope you did that—if so, you should be able to use that account to login on the computers in Phelps 3525, as well as the computers in the CSIL lab.

If you ever forget the password to your ECI/CSIL account, you can reset it here:

https://accounts.engr.ucsb.edu/maintain/

Phelps 3525 is only available during your weekly scheduled discussion section and during Fall 2017, on Tuesdays 1-2:00pm, and Wednesdays 8-1pm.

At other times during the week, you can work in CSIL, the "Computer Science Instructional Lab".

The CSIL lab, by the way, is on the ground floor of Harold Frank Hall. The glass front doors of Harold Frank Hall look out towards the ocean. Stand just outside those doors with your back towards the ocean. The doors to the CSIL lab are just on your right. (If you can’t look over your shoulder and see an great big tree, with the ocean just behind it, you are on the wrong side of the building.) Hours vary–its open almost all the time during the regular school year

## Step 2: Bring up a “terminal”

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—a window that gives us access to the Linux “command line”.

Here’s how:

• Find the Applications Menu at the top left of the screen
• Select System Tools, then Terminal (the icon should look like the image shown at right)
• A Terminal Window should pop up, looking something like the one shown below

## Step 3: Create 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.

• When you type cd by itself, it takes you to your ‘home directory’.
• cd followed by a directory name (e.g. cd cs8) moves you into a directory under the current one

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

• For example, mkdir cs8 creates a new directory called cs8 inside the current directory.

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

• Your home directory is something like /cs/student/jsmith or /engr/student/mdiaz
• Under that, you might have a directory cs8—that would show up as /cs/student/jsmith/cs8, or /engr/student/mdiaz/cs8

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

NOTE: your prompt may not be exactly like the one shown here. Instead of -bash-4.2$, you might have something like [cgaucho@cstl-15 ~]$ . The cgaucho here is your username, the cstl-15 is where you are logged in, and the ~ is your current directory. Don’t be distracted by this detail.

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


## Step 4: 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 "Home" icon on your desktop—it should be near the upper left hand corner of the screen. When you double click on this icon, 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, it is ok to do it that way.

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

## Step 5: Bring up the program called IDLE

The preliminaries are done—now we are ready to start saving files for Python!

IDLE is a piece of software that you use to interact with the Python programming language. As we are using Python version 3 in this class, we also use IDLE version 3.

Type the following at the command prompt:

-bash-4.2\$ idle3


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

• This is sometimes called the "Python Command Prompt" window.
• This is also called the "Python Shell" window.

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

## Step 6: Save a file in IDLE

In IDLE, select “File=>New File” 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.

For this lab, there is one goal: write a Python 3 program that prints the string Hello, World! as its output.

In this sense, we are following a long tradition: for more than 40 years it has been a tradition to make printing Hello, World! be the first thing you do when learning a new programming language.

In Python 3, this program is very short. It looks like this:

print ('Hello, World!')


We will save the file under the name hello.py—it is important that is has exactly that name, or the submit.cs system will not accept your submission.

That’s it! Now, you can also add, on the first line, a comment with your name, and information about the course, for example:

# Chris Gaucho, for CMPSC 8, Fall 2017
print ('Hello, World!')


You are encouraged to do that, because it helps someone looking at your code know that you wrote it. But, other than that, it isn’t necessary. In general, in computer programming, a comment is something that is intended only for human readers of the code, and is otherwise “ignored by the system”. Nearly every programming language has some way to express comments, though the exact rules for formatting of comments–that is, the syntax of comments–differs from one language to another.

In Python, a # starts a comment. Everything from the # to the end of that line is part of the comment.

Enter this program in IDLE, then save it under the name hello.py

## Step 7: Running your program.

To run your program, select the “Run” option from the menu. You should see the “Hello World!” message.

I’ll demonstrate the use of Idle in lecture, since its much easier to just follow along than to try to explain everything in a text document. If you need a further demonstration, you can find one on YouTube. For example: This video starting at 4:53 (That video is for Python 3.1, but the stuff shown in the video is the same across all versions of Python 3.x).

Next, we’ll try submitting our program to submit.cs, which is an autograder system used by many Computer Science department courses at UCSB. You’ll get some immediate feedback on whether you did it properly.

You may have already done the steps in this section–an email was sent out through Gauchospace inviting you to do so. If you have, you may skip this section.

1. Navigate to the following website: https://submit.cs.ucsb.edu
2. Click on the “Create User” button, and enter your Umail address.
4. Go back to the website: https://submit.cs.ucsb.edu and login with your account.
5. Select “Join Class”, and click on the link for CS8_f17

At that point, you should be good to go.

The page for submitting lab00 is here: https://submit.cs.ucsb.edu/form/project/824/submission

Navigate to that page, and upload your hello.py file.

Note that if you try to upload a file with a name that does not match EXACTLY the name hello.py, the system will not allow you to do it. The name cannot be, for example, Hello.py, or HelloWorld.py, or hell0.py (note the zero as in ‘007’ instead of the letter ‘o’ as in octopus.) Only hello.py is permitted. This will always be the case with submit.cs: it is very picky about the filename that it wants.

Once you upload it, you should get a page that shows your submission is pending.

Refresh that page, and you should get one that indicates with either red, or green, whether the test cases for your code passed or failed.

If you got all green, and 100 points, then you passed, and you are finished with lab00!

## Final Step: Log Out

Actually, this is the final step of every lab, but we probably won’t remind you again after this one.

In fact, you should do this every time you walk away from a lab computer, either in Phelps 3525 or CSIL.

Here’s how:

• Find the System Menu at the top of the screen.
• Select Log Out