On this page:
1 Finger exercises
2 Images
3 Animation
6.10.1

Lab 1: Getting Started

This lab will introduce using DrRacket and Beginning Student, using the Handin Server, and designing simple functions.

1 Finger exercises

Start DrRacket. Make sure that the language level is set to "Beginning Student" (Note: if you change the language level, it will not take effect until you hit the "Run" button).

Exercise 1: Experiment using DrRacket’s Interactions Window as a calculator. See what operations you can use to calculate. Make sure to try big numbers and fractions.

Exercise 2: Design a function that when given an integer that represents distance in miles will return the time (in hours) it takes to travel that distance when going 60 MPH. Write your function in the Definition Window, click Run, then use the Interactions Window to test your function.

Exercise 3: Design a function that given an integer representing time (in minutes) will return the distance traveled when going 70 MPH, rounding up to whole miles.

Hint: DrRacket comes with a help system called Help Desk. Open the Help Desk and click "How to Design Programs Languages", then click "Beginning Student". You will get a reference for the Beginning Student language. You can also highlight the name of a function and press F1, this will search Help Desk for the highlighted text.

Exercise 4: There are three kinds of errors you can make when writing a program in DrRacket. Come up with examples of each and try them out. Examine any error messages you get back.

2 Images

Access the 2nd edition HTDP "universe" and "image" libraries in DrRacket. Put the following magic text at the top of your definitions window:

(require 2htdp/image)
(require 2htdp/universe)

Libraries come with documentation. In the Help Desk, search for "universe". Also have a look at the documentation of the image library titled "2htdp/image".

Exercise 5: Download an image off the web and insert it into your Definition window. Use define to give it a descriptive name. Examples: cars, boats, planes etc.

Exercise 6: Use place-image and empty-scene to create scenes with your image.

Exercise 7: Create rectangles with the following dimensions

Exercise 8: Design the function my-rectangle that given a number produces a rectangle with the given number as the height, and twice the number as the width.

3 Animation

Exercise 9: Design a function which given a number, places a circle with that radius in the middle of an empty scene.

Exercise 10: Use the function you just created, along with animate, to produce an animation.

Exercise 11: Change the animation to use the my-rectangle function instead.

Exercise 12: Create your own animation, using any functions that you want from the 2htdp/image library.