Lab 1 - Spring 2019

Introducing the Command Line, DrRacket, and GitHub

The main purpose of this initial laboratory exercise is to acquaint you with

  • your new CS account,
  • the new Linux platform in our classroom and the Asprey Lab,
  • GitHub,
  • the DrRacket IDE, and
  • the procedure for submitting your work using GitHub.

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.

Create your GitHub account

  1. Use your new CS account to login to one of the Linux workstations in the classroom.

  2. Point your browser to https://github.com/

  3. Create your github account
    1. use your Vassar email (minus the @vassar.edu) as your GitHub username
      1. it is possible your Vassar username is already taken by an existing github user
      2. if this is the case, append -vassar to your username (that should make it unique)
    2. use a strong password (but be sure you remember your password)
    3. use your Vassar email address as the email address for your GitHub account

  4. Open up a new tab in your browser and copy/paste this URL: https://classroom.github.com/a/JF1f0KGV
    1. Login to Github and you will be prompted to accept this assignment
    2. Note: this will create your own copy of Lab 1 for you to work on, but it's not on your Linux account yet

At the command line:

  1. Bring up a terminal window by right-clicking on the desktop and selecting Open in Terminal from the pop-up menu.

  2. Create a new directory named cs101 in your home directory, and set the permissions so that only you can access the contents of this directory. To do this, type the following commands, pressing return after each command, at the Linux prompt:

    cd
    mkdir cs101
    chmod 700 cs101

  3. Create a new directory for this lab in your cs101 directory by entering the following at the Linux prompt:

    cd cs101
    mkdir lab1
    cd lab1

  4. Type the following commands to pull down a copy of this lab from GitHub:
    $ git init
    $ git remote add origin https://github.com/Vassar-cs101-mlsmith-spr2019/lab-1-yourVassarID
    $ git pull origin master
  5. To launch DrRacket, enter the following command at the Linux prompt:

    drracket &

  6. When DrRacket loads, you will be presented with a window that is divided into two main frames: the definitions window (top half) and the interactions window (bottom half).

  7. From the Language menu along DrRacket's menu bar, select 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.

  8. To make BSL your default language, click on the Run button at the top of the screen. The interactions window will display the lines shown below:

Welcome to DrRacket, version 7.0 [3m].
Language: Beginning Student; memory limit: 256 MB.
> 



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.

Copy/paste the following code into your DrRacket Definitions Pane:

; CS101 Lab 1
; Name: <YOUR NAME>
; Description: evaluating different types of data expressions 
 
(require 2htdp/image)
(require 2htdp/universe)
 
; Numbers are a type of data
; --the following expression adds numbers
; --add expressions that subtract, multiply and divide numbers
(+ 40 1 1)
 
; Strings are a type of data (strings of characters)
; --the following expression appends strings
; --add another expression that appends two or more strings
(string-append "Computer " "Science")
(string-append "Marc " "was here")
 
; Booleans are a type of data (#true or #false)
; --the following expression compares two numbers
; --add some more comparisons using <, >=, <=, and =
; --some expressions should evaluate to #true, some #false
(> 42 9)
 
; Images are a type of data
; --shapes are one type of image; circle is one type of shape
; --add another circle expression
; --rectangle is another type of shape: (see an example below)
;   --instead of one number representing a circle's radius...
;   --a rectangle function takes two numbers, representing width and height
;   --the other inputs are the same as the circle function
; --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 (rectangle 20 20 "solid" "blue")
         (circle 5 "solid" "red"))
 
; Scenes are a type of data; scenes are also a type of image
; --the following expression creates an empty scene
(empty-scene 100 100)
 
; Images may be placed within scenes
; --the following expression places a circle in an empty scene
; --at coordinates (25,25)
; --the result is another scene (but this scene isn't empty!)
; --add another image of a scene, but this one contains a rectangle
(place-image (circle 10 "solid" "red")
             25 25
(empty-scene 100 100))

Your first program

  1. Open the lab1.rkt file in DrRacket by clicking on the File menu option and selecting Open. Then navigate to your cs101/lab1 directory, and double-click on lab1.rkt.
  2. Fill in your name where <YOUR NAME> appears in the comments at the top of the program.

  3. Run your program by clicking the Run button.

  4. If there is a syntax error somewhere in your code, DrRacket will generate a syntax error. To see what a syntax error looks like, remove the right parentheses from the end of one of the expressions (a line that does not start with ;) and click the Run button. Notice how the error message appears in a red font in the interactions pane.

  5. We encourage you to experiment with this 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 start over with a fresh copy.

  6. When your program successfully runs, show it to your lab instructor or one of the lab coaches and follow the submit procedure detailed below.

Submitting your work

From a terminal window, type the following commands at the Linux prompt:

$ git commit -m "finished lab1" lab1.rkt
$ git push -u origin master



Log out

When you are done, close DrRacket by choosing Quit from the File menu, and then locate the logout option on the menu bar (lower right corner). Choose “Logout…” 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.