7.0

#### Lab 1: Getting started

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

##### 1Finger 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 fractions.

Exercise 2: Define a variable big-number to be a big number. Then, define another variable bigger-number to be the result of multiplying big-number by itself. Finally, define a number that is bigger than bigger-number.

Exercise 3: 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.

• syntax error, when you write something that DrRacket doesn’t recognize as a program

• run-time error, such as when you provide the wrong kinds of inputs to an operation

##### 2Functions

Exercise 4: Define 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 Definitions Window, click Run, then use the Interactions Window to test your function.

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

Exercise 6: Define a function that converts a temperature in Fahrenheit to a temperature in Celsius. Here is the formula.

Exercise 7: Define a function that converts a temperature in Celsius to a temperature in Fahrenheit. In the Interactions Window, apply this function to an integer and apply the function from Exercise 4 to the result and see that you get the same number back.

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.

##### 3Images

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 8: Download a tiny image off the Web and insert it into your Definitions Window. Use define to give it a descriptive name. Examples: cars, boats, planes, etc.

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

Hint: DrRacket comes with a help system called Help Desk. Open the Help Desk and click "How to Design Programs Teachpacks", scroll down to "HtDP/2e Teachpacks", then click "Basic Images". You will get a reference for the 2htdp/image library.

Exercise 10: Create rectangles with the following dimensions.
• 10x25

• 20x50

• 30x75

• 40x100

• 50x125

• 60x150

Exercise 11: Create an image that resembles the Indianapolis flag: