heet" type="text/css" href="style.css" title="style1"> CS1120: Lab Guide
cs1120  Fall 2012

cs1120: Introduction to Computing: Explorations in Language, Logic, and Machines

Instructor
Westley Weimer

Email Address
cs1120-staff@cs.virginia.edu

Class Meetings
Tuesdays and Thursdays, 3:30-4:45pm in Olsson 011
Office & Lab Hours
Mo 15:00-17:00 Stacks (J, L)
Mo 17:00-19:00 Olsson 001 (C, M)
Tu 13:00-15:00 Stacks (D, M)
We Noon-13:00 Rice 423 (Weimer)
We 13:00-14:00 Olsson 001 (C, J, M)
We 14:00-16:00 Olsson 001 (C, J, L)
We 16:00-17:00 Olsson 001 (C)
Fr 13:30-15:30 Olsson 001 (C, M, J)
Su 13:00-15:00 Olsson 001 (C, L)
Su 15:00-17:00 Olsson 001 (C, D)
Su 17:00-19:00 Olsson 001 (D, J)

Located in Thornton Stacks
or Olsson 001
or Rice 423 (We Noon-13:00)
ates.cs.virginia.edu\mst3k next to Folder.

Then click Finish. You'll see a folder that you can use to store your class files:

Reminder: this process won't work until you change your password on these machiens as least once!

or Store Your Files on your eservices Home Directory

To open your home directory, click on the house icon on your desktop and enter in your eservices user id and password. (Your eservices password is likely different from your CS department password.)

Downloading and Installing Problem Set Files

Now that you have a place to store your files, we will create a cs1120 sub-folder in it. To create a cs1120 sub-folder, right click in your folder and select New Folder. Rename the New Folder cs1120.

To avoid confusion with multiple files, each problem set should use its own folder. If you follow these instructions, Problem Set 1 will end up inside a separate folder within the cs1120 folder.

For most problem sets, we will distribute a zip file containing what you need to get started on the problem set. To download the needed files, go to the current problem set on the course web page and click on the link for the files within the text:

When you are prompted to Open or Save the file, select Open. Then drag the ps1 folder into the cs1120 folder you made in the last step (you may have to minimize your Web Browser to find the cs1120 folder).

Now that you have the Problem Set files, let's get started with Python.

Running PyCharm

To open PyCharm, which allows you to write and execute Python programs, double-click on the PyCharm Shortcut link on the Desktop.

After a brief splash screen, you will see the main PyCharm interface. We need to tell PyCharm which Problem Set you are working on. Click on Open Directory on the left side of the screen:

A window called Select Path will appear. Find your cs1120 folder and then your ps1 folder inside it. Double-click on ps1 or click OK.

Working On Problem Sets — Interpreter

Some Problem Sets as you to use the Python Interpreter or Python Console to try out Python expressions or programs. For example, the Question 2 in Problem Set 1 asks you to do so. Let's do it now! To open the Interpreter (or Console), click on the Tools menu and select Run Python Console ..

The Interpreter appears at the bottom of your PyCharm screen:

Click just to the right of the >>> prompt. That's where you tell the Interpreter what to do by writing Python code. For example, if we type 70 + 80 and then press Enter, Python will perform the addition and indicate that the result is 150:

Now let's copy-and-paste the "good move" sub-question from Problem Set 1 into the Interpreter. Just select it in your web browser, choose Copy, then past it into the Interpreter window (e.g., Ctrl-V or right-click and Paste). Once you've pasted it, you may have to press Enter a few times to tell the Interpreter that you're done entering Python code:

We see that the result of that expression is the string 'good move' (because 12 is, in fact, greater than 10). Good job! You now know how to use the Python Interpreter.

Working On Problem Sets — Coding

Not all work is done with the interactive Interpreter. Most code is written first and then run later. Let's try that! Double-click on ps1.py on the left of the PyCharm screen to bring up the Problem Set 1 code that we provide for you:

If you've been reading along in the Problem Set 1 description, you know that we're working on colors and photomosaics. (If that doesn't sound familiar, you should stop now and read the Problem Set 1 description.) Let's display a bright Yellow, which is made out of 255 units of red and 255 units of green (but 0 units of blue). Edit the Python code so that the show_color(yellow) line is present and is not a comment (comments start with # and are ignored by Python):

Because we're not using the interactive Interpreter, we need to tell Python when we want to run the program. There are two ways to do this in PyCharm. Either click on the Run menu and select Run.. or click on the green arrow (if available):

or

The first time you Run a Python program, PyCharm may give you a choice to either Run ps1 or do some Configuration. If you get that choice, just click to run the ps1 program. If you've done everything correctly, you'll see a yellow circle in a new window.

Just click on that window to close it and return to PyCharm. That's it! Now you can work on the Problem Set.

Please make sure that what you turn in for a problem set clearly marks the questions you are answering.

Credits: This guide was developed by Katie Winstanley and David Evans for CS200 Spring 2003 and revised for CS150 Fall 2005 by David Evans. It was revised for CS 150 in Spring 2009 by Westley Weimer, and then revised again for CS 1120 in Fall 2012 by Westley Weimer.

CS1120: Lab Guide
cs1120  Fall 2012

cs1120: Introduction to Computing: Explorations in Language, Logic, and Machines

Instructor
Westley Weimer

Email Address
cs1120-staff@cs.virginia.edu

Class Meetings
Tuesdays and Thursdays, 3:30-4:45pm in Olsson 011
Office & Lab Hours
Mo 15:00-17:00 Stacks (J, L)
Mo 17:00-19:00 Olsson 001 (C, M)
Tu 13:00-15:00 Stacks (D, M)
We Noon-13:00 Rice 423 (Weimer)
We 13:00-14:00 Olsson 001 (C, J, M)
We 14:00-16:00 Olsson 001 (C, J, L)
We 16:00-17:00 Olsson 001 (C)
Fr 13:30-15:30 Olsson 001 (C, M, J)
Su 13:00-15:00 Olsson 001 (C, L)
Su 15:00-17:00 Olsson 001 (C, D)
Su 17:00-19:00 Olsson 001 (D, J)

Located in Thornton Stacks
or Olsson 001
or Rice 423 (We Noon-13:00)

cs1120: Computer Science
University of Virginia
weimer@virginia.edu
Using these Materials