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
If you have trouble, raise your hand – we're here to help!
code.pyret.org
in the address bar.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.
››› 1
and press enter. This gets evaluated and – fascinatingly – the result is also the number 1!
››› 1 + (2 + 3)
Hopefully the answer is 6!
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
<YOUR NAME>
appears in the comments at the top of the program. Ctrl+enter
) Ctrl+s
. code.pyret.org
.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.