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:
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!
››› 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.
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.
<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.