Lab 1: Getting Started

3 September 2021

Linux accounts

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

Today's lab

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

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

Opening CPO

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) 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.

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.

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

Saving your work

Submitting on Gradescope

Log out

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! 🎉

Acknowledgments

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