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 Lab Guide

This guide explains the most important things you need to know to get started working on CS1120 problem sets.

Labs

You may work on CS1120 problem sets anywhere you choose, including at home. You are highly encouraged, however, to work in the designated CS1120 lab so you will benefit from the staffed lab hours there as well as the presence of your fellow classmates.

Personal Machines

If, after reading this entire guide and trying things out in the official lab, you want to try things on your own Windows, Mac or Linux machine:

  1. Download and install Python 2.7.2 on your own machine.
  2. Download and install PyCharm on your own machine.
    • Click "30-Day Free License" when you run PyCharm. We'll provide a license after the drop deadline.
    • If you have previous computing experience and want to use something like Eclipse or Emacs instead of PyCharm to develop Python files, that's fine.
  3. Remember, you must follow this entire guide in the official Lab once before installing these things on your own machine.
The TAs and the instructor only officially support the official Windows Lab Machine, but every semester dozens of students use personal Mac or Linux machines and it works fine.

Files and Folders

You will need a way to store your files — the programs you modify or create as part of the problem sets in this class. We recommend three options:

  1. Store the files on your own USB flash drive or thumb drive (strongly recommended).
  2. Use the socrates storage provided by the CS department (second choice).
  3. Use your eservices Home Directory (last resort).

Store Your Files on Your USB Flash Drive

Simply purchase a USB flash drive with at least 4 gigabytes of storage space and bring it to the lab.

This approach allows you to work easily from any lab machine or any personal machine simply by moving the USB flash drive. Remember to safely eject the drive before you physically remove it to ensure that changes to your files are saved.

In all of the lab instructions we assume that your flash drive is called J:\ under Windows — if it has another name, just mentally substitute that name instead.

or Store Your Files on socrates

socrates.cs.virginia.edu is the name of a computer server that you can use to store files. It is provided by the CS department for free to all CS 1120 students.

As a security measure, you cannot use socrates until you change your CS 1120 lab computer password away from the default one we sent you via email.

To use it, find the Computer or My Computer icon and right click on it, then choose Map network drive ... from the menu.

Next, change the Drive: option so that J: is selected. Then write \\socrates.cs.virginia.edu\your_uva_id in the Folder: field. For example, if your UVA ID is mst3k, you would write \\socrates.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: Computer Science
University of Virginia
weimer@virginia.edu
Using these Materials