Lab 1: Getting Started

3 September 2021

The instructor will provide instructions to log into your Linux accounts on the classroom workstations and set your passwords.

The purpose of this initial lab. exercise is to acquaint you with

  • your new CS Linux account,
  • using the code.pyret.org (CPO) programming environment, and
  • the procedure for submitting your work electronically.

If you have trouble, raise your hand – we're here to help!

  • Use your CS account to log in to one of the Linux workstations in the classroom.
  • To open a web browser, click on the menu in the upper left corner, select Internet, and open Firefox (or the browser of your choice).
  • Enter code.pyret.org in the address bar.
  • Click “Sign in” and follow the prompts to link it with a Google account. You can use the same account you use for your Vassar email or, if you prefer, you can make a new account just for Pyret by going to google.com and clicking “Sign in” and then “Create account”.
  • Click “Open Editor”.

Getting used to the Pyret Editor can be a bit tricky. Let us help you navigate your way through it!

When CPO loads, you'll be presented with a screen that's divided into two windows: the definitions window (left) and the interactions window (right).

The definitions window is where you'll provide Pyret the program you want it to run. The program could consist of definitions (assignment of variables to expressions or functions), or expressions, or both.

The interactions window is where the results of running your program are displayed and where you can experiment.

  • In the interactions window, type:
    ››› 1

    and press enter. This gets evaluated and – fascinatingly – the result is also the number 1!

  • Let's be slightly more interesting and try the following:
    ››› 1 + (2 + 3)

    Hopefully the answer is 6!

  • Before we continue, you might want to customize CPO a bit: Click on the View menu and you can adjust the font size or change the colors CPO will use. Make yourself comfortable or stick with the defaults!

For this lab, you'll create a program by copy-and-pasting the following code into CPO's definitions window. In future labs and assignments, you will type in your own code, but for the purposes of this lab, we thought we'd give you a head start!

The lines below that start with number signs (#) are not evaluated by the computer – they're for human readers only.

The lines that do not start with # are expressions that are evaluated by Pyret.

Okay, now copy-and-paste the following lines of code into CPO's definitions window (on the left):

# CMPU 101 Lab 1
# Evaluating different types of data expressions
# <YOUR NAME>

# Numbers are a type of data.
# - The following expression adds numbers.
# - Add expressions that subtract, multiply, and divide numbers.
(40 + 1) + 1

# Strings (of characters) are a type of data.
# - The following expression appends strings
# - Add another expression that appends two or more strings
string-append("Computer ", "Science")

# Images are a type of data
# - Add another circle expression
# - Add two different rectangle expressions
circle(10, "solid", "red")

# Images may be combined
# - The following expression overlays a circle on a square
# - The result is another image
overlay(
  circle(20, "solid", "red"),
  rectangle(40, 40, "solid", "blue"))

# Give a name to a friendly rectangle
fred = rectangle(100, 20, "solid", "black")
# Display fred
fred
  • Don't worry if you don't understand everything you just pasted into CPO! For today we just want to play around.

  • Fill in your name with <YOUR NAME> appears in the comments at the top of the program.

  • Run your program by click the Run button at the top (or use the shortcut Ctrl+enter)

  • If there is a syntax error somewhere in your code, Pyret will generate a syntax error.

    To see what a syntax error looks like, remove the right parenthesis from the end of one of the lines and click Run again.

  • Read Pyret's explanation of the error. In this case, you already knew what was wrong, but when you don't, carefully reading the error messages will help.

  • Experiment! Change some of the expressions in the program.

  • The comments describe what the expressions do, so read carefully, then play around by changing the expressions, save, and re-run.

  • See if you get the results you expect. Be daring! In the worst case, you can always copy-and-paste the original again.

  • When your modified program successfully runs, show it to the professor or and follow the submit procedure below.
  • Save your program by clicking FileSave a copy and giving it a name.

  • CPO sometimes auto-saves. Do not rely on this! Make sure you frequently save your work! You can click FileSave or use the keyboard shortcut Ctrl+s.

  • Now if you click on FileMy Programs, you'll be shown a list of all your programs including the one you just saved. These are stored in Google Drive.

  • When you look at your Google Drive account, you'll see your Pyret files in a folder called code.pyret.org.
  • To submit your work so the instructor can see it, you first need to download a copy of your work to the computer. Click FileDownload.

  • Now we'll upload it to Gradescope. In your browser, go to gradescope.com and log in.

    You should have received an email inviting you to sign up for Gradescope. If you didn't, check your junk mail folder, and then let the professor know.

  • You'll see a list of courses you're enrolled it. Click on “CMPU 101 04/05”.

  • Now you'll see a list of assignments for the course. For now the only one is “Lab 1”. Click on it.

  • Click on the prompt (“Click to browse”) and select your lab file.

  • Click Upload.

  • Note that you can submit new versions of your work on Gradescope up until the deadline.

Log out by clicking the gear icon next to the date in the top panel and selecting “Log Out…” and follow any remaining prompts.

Always remember to log out when you are done using the system, to ensure that no one else uses your account.

That's it! 🎉

This lab includes material adapted from Kathi Fisler and colleagues at Brown University.