The main purpose of this initial laboratory exercise is to acquaint you with
You will create your first program within the cs101 course directory of your CS account. The program you cut and paste will itself be very simple, because the goal of this lab is to learn to use your CS account to create, run, print, and submit your work electronically for grading.
How to get started
): cd cs101 mkdir lab1 drracket & Choose Language.... In the left column, make sure the arrow head to the left of How to Design Programs is pointing downwards. If the arrow is not pointing downwards, click on it. This will cause a list of language levels to appear. Click on Beginning Student Language. Click the OK button bottom right to save this selection.Welcome to DrRacket, version 5.0.1 [3m]. Language: Beginning Student. >
Now you are ready to begin programming! Note that you will need to follow steps 7-8 when setting up DrRacket on your own computer, too.
Your first program
For this lab, you will create a program by copy/pasting the following code into the definitions pane of DrRacket. In future labs and assignments, you will type in your own code, but for the purposes of this lab you are given a head start. The lines below that start with semicolons (;;) are not evaluated by the computer...they are comments, intended for human readers only. The lines that do not start with ;; are expressions that are evaluated by DrRacket.
Copy and paste the following lines of code into the DrRacket Definitions pane:
(require 2htdp/universe) (require 2htdp/image) ;; CS101 Lab 1 ;; Name: <YOUR NAME> <==== Type your own name here in place of the text in <>s ;; Description: evaluating different types of expressions, keeping in mind that ;; primitive function invocations are expressions ;; All the primitive (atomic) data types are expressions that evaluate to ;; themselves: "1. Numbers are a type of atomic data:" 2 4.678 3/5 " " "2. Strings are any sequence of characters enclosed in quotation marks:" "Hello world" "cat" "45 plus three is 48" " " "3. Symbols are any sequence of non-space characters preceded by an apostrophe:" 'thisisasymbol '34 '() " " "4. Booleans are the sequence of letters (NOT in quotation marks) true or false:" false true " " "5. The empty list, represented by the word empty:" empty " " "6. Built-in (aka primitive) functions evaluate to themselves:" + * < " " "7. Images are a type of primitive data inserted as .gif or .jpg files or shapes drawn using primitive functions defined in the image library:" "images must be inserted within DrRacket" ;; Function invocations are expressions that begin with an open parenthesis, ;; followed immediately by the function name, followed by the appropriate ;; number and type of arguments. ;; ;; --the following function invocation (+ ...) adds multiple numbers from ;; left to right, producing a single number (+ 40 1 1) ;; --the following function invocation (string-append ...) appends multiple strings ;; from left to right, producing a single string (string-append "Computer " "Science") ;; --the following function invocation (> num num) compares two numbers, ;; producing a boolean (true or false) (> 42 9) ;; --the following function invocation draws a filled-in, red circle ;; --the result is a shape (a type of image) (circle 10 "solid" "red"); ;; Images may be combined ;; --the following function invocation draws a circle on top of a square ;; --the result is an image (overlay (rectangle 20 20 "solid" "blue") (circle 5 "solid" "red")) ;; Scenes are a type of data, an image of an empty window on the screen ;; --the following function invocation creates an empty window (an image) (empty-scene 100 100) ;; Images may be placed within scenes ;; --the following function invocation places a circle on top of an empty scene ;; --the result is another scene containing a red circle (place-image (circle 10 "solid" "red") 25 25 (empty-scene 100 100))
lab1.rkt. Submitting your work
You are being asked to submit this lab so that you know how to submit assignments in the future. No lab other than lab1 will be submitted, you will only get credit for the lab if you are checked off by a coach or your professor. From a terminal window, type the following commands at the Linux prompt:
cd cs101
submit101 lab1
Log out
When you are done, close DrRacket by choosing Quit from the File menu, and then locate the logout button on the menu bar. Click on the logout button (red arrow pointing through an open door). Choose “Logout...” and then click “Yes” when prompted. Always remember to log out when you are done using the system, to ensure that no one else uses your account.