lab00 : Getting started
|lab00||true||Getting started||Wed 01/09 09:00AM||Tue 01/15 11:59PM|
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.
This lab must be done individually.
Use ic00 to find a partner, then submit it at the end of your section
In the next few labs you will work with a programming partner. In this section the TA will lead you through an activity to help you find a suitable partner. Note down the name of your partner in the last question of ic00 and submit it to the TA in your section.
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 gradescope 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:
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:
If your account doesn’t work, ask a TA for assistance. Please first look through the knowledge base and post on Piazza before contacting ECI. If nothing else works contact the ECI Help Desk at email@example.com.
Note about the labs
Phelps 3525 is only available during your weekly scheduled discussion section and during open lab hours (see the lab and office hours calendars for details).
At other times during the week, you can work in Phelps - 3525 or 2510. Phelps 3525 is the lab that you are currently in. Unlike Phelps 2510 it has computers. So, if you plan to work in Phelps 2510 bring your own laptop if you have one. The TAs and tutors can help you get your laptop setup.
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”.
- 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.
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 /cs/student/yourusername -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 /cs/student/yourusername/cs8/lab00 -bash-4.2$ cd -bash-4.2$ pwd /cs/student/yourusername
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:
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 very important that is has exactly that name, or the gradescope system will not run your program correctly.
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, Winter 2019 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
Step 7: Running your program.
To run your program, select the “Run=>Run Module” 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).
Step 8: Uploading your program to Gradescope
Next, we’ll try submitting our program to Gradescope, which is a new autograder system we will utilize for this course. You’ll get some immediate feedback on whether you did it properly.
Creating your Gradescope account
I have added everyone (using your @umail.ucsb.edu accounts) currently enrolled in the course to the Gradescope system. You should have received an email from the Gradescope system asking you to create a password. Once you follow the instructions to set your password, you should have access to the autograding system. You should see “CMPSC 8” in your Winter 2019 Courses.
The lab assignment “Lab00” should appear in your Gradescope dashboard in CMPSC 8. If you haven’t submitted anything for this assignment yet, Gradescope will prompt you to upload your files. This prompt is shown below:
You either can navigate to your file(s) or “drag-and-drop” them into the “Submit Programming Assignment” window.
If you already submitted something on Gradescope, it will take you to their “Autograder Results” page. There is a “Resubmit” button on the bottom right that will allow you to update the files for your submission.
For this lab, if everything is correct, you’ll see a successful submission passing all of the autograder tests shown below.
If the tests don’t pass, you may get some error message that may or may not be obvious at this point. Don’t worry - if the tests didn’t pass, take a minute to think if your print statement is EXACTLY like stated in the lab instructions (including the same capitalization, spaces, punctuation, etc.) and the file name is EXACTLY
hello.py. If your tests didn’t pass and you’re still not sure why you’re getting the error, feel free to ask your TA.
Final Step: Log Out
Actually, this is the final step of every lab, but we probably won’t remind you again after this one. If you don’t log out, you will not be able to log in from a different machine e.g. in the CSIL labs.
In fact, you should do this every time you walk away from a lab computer, either in Phelps 3525 or CSIL.
- Find the System Menu at the top of the screen.
- Select Log Out