#### 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.

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

Exercise 5: Design 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. You can also highlight the name of a function and press F1, this will search Help Desk for the highlighted text.

Exercise 6: 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

logical error, when your program produces an answer, but it’s the wrong answer

##### 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 7: 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 8: Use place-image and empty-scene to create scenes with your image.

Exercise 9: Create rectangles with the following dimensions

10x25

20x50

30x75

40x100

50x125

60x150

Exercise 10: 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 11: Design a function which given a number, places a circle with that radius in the middle of an empty scene.

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

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

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