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 our 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).
code.pyret.orgin the address bar.
Click Sign in and follow the prompts to link it with a Google account. You can use your Vassar Google account 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".
Interactions and definitions
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) 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), expressions, or both.
The interactions window (right) is where the results of running your program are displayed and where you can experiment.
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. You can make yourself comfortable or stick with the defaults.
Now you're ready to begin programming!
In the interactions window, type:
and press enter. This gets evaluated and -- fascinatingly -- the result is also the number 1!
Let's be slightly more interesting. Try the following:
››› 1 + (2 + 3)
Hopefully the answer is 6!
Your first program
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.
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 # Your final exercise is to create a image of your choosing. The only requirement is that you have three different shapes and three different colors.
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 clicking the Run button at the top (or use the shortcut
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 expressions 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.
Saving your work
Save your program by clicking File -> Save a copy and giving it a name.
Note: CPO sometimes auto-saves. Do not rely on this! Make sure you frequently save your work! You can click File -> Save or use the keyboard shortcut
Now if you click on File -> My 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
Submitting on Gradescope
To submit your work, you first need to download a copy to the computer. Click File -> Download.
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".
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.
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.