Purpose The first purpose of this lab is to give you some hands-on experience with the BSL programming language and with the DrRacket programming environment for BSL. The second purpose is to pair you up with a partner (see Pair Programming).
Goals: Read and sign the course contract.
Exercise 1 Follow the instructions on this page to set up an account on the handin server. You will be using the handin server to submit all your homeworks for the semester (including the homework that’s due Thursday!).
Exercise 3 Submit the Exam Conflicts assignment on the handin server.
Exercise 4 If you are using your own laptop, download and install DrRacket on your machine. If you are not, count to 10 in your head to keep things fair and balanced.
In this course you will be completing your assignments with a partner. Your partner will be the person sitting next to you in lab. You should also work with them on the lab. You should have one computer for the two of you. One person can man the keyboard, but both partners should be contributing ideas and code. The two of you will get one grade for any given assignment.
Exercise 5 Exchange contact information with your partner: telephone number, latest-greatest social network scheme, whatever-app.
Agree to a first meeting time and meeting place. At that meeting, agree to next meeting time and meeting place.
Exercise 6 Establish your partnership on the handin server. In order to do that you will both need to request the partnership on the handin server. There are instructions here on how to request teammates. Your TAs will approve the team requests as they go through. Once the request is approved you should see your team on the course homepage under "Current teams".
Your TA will go over this but you might find it helpful to find it written down. Lab writeups consist of three major parts: sample problems, starter code, and exercises.
Sample Problems are exercises whose solution we provide as part of the lab. Your lab’s head TA will go over the sample problem with the class.
Starter Code comes with a brief explanation you are expected to read and understand, and will enable you to complete the following exercises. You should always copy and paste the starter code into your program. Unless otherwise specified, you should make sure to take the time to understand the code you are copy/pasting.
Exercises are exercises you will complete on your own that the head TA will only review with the whole lab if they feel the majority of people are having difficulty with the problem.
Note that for all of these parts, if you are ever stuck or have any questions please raise your hand and a tutor or TA will make their way over to help.
You are free to leave when you have completed the entire lab or the head TA ends lab when time is up.
Goals Write a program in DrRacket’s definitions area. Explore the tools and menus of DrRacket. After running check-syntax, find documentation with "right-click" or by pressing F1.
Sample Problem Define a function that accepts a number of minutes and computes how many hours these minutes represent.
Sample Problem Define the function how-far which consumes the number of minutes you drive at 55mph and produces how far you get in the given time.
Goals: Interact with Dr. Racket’s definitions window, interactions window, and stepper. Create basic expressions and function definitions. Introduce different types of errors.
Exercise 7 Define a function multiple-of-5? that accepts a number and determines if it is a multiple 5. Hint: the function modulo will be helpful to you here.
Exercise 8 Submit your response to the last exercise on the handin server. Note: This is the only exercise you will be submitting in this lab, and it is primarily to make sure you are authenticated with the hand-in server. Either you or your partner can submit, and the submission will be attributed to both of you. So don’t both submit. If you have any trouble submitting this exercise please tell your TA immediately so we can resolve the issue.
Exercise 9 Define a constant GREETING which contains your greeting. Then, use it in a function called greet that takes a name and outputs a full greeting.
Exercise 10 Call these functions in the interactions window. What happens if you call (multiple-of-5? "dog") or (greet #t)?
Exercise 11 Call your functions in the definitions window. Run the stepper on your program. Follow it through to see how it evaluates.
Exercise 12 It has been estimated that fixing the water in Flint, Michigan would cost 55 million dollars. Given someone’s net worth, define a function that will determine what percentage of their net worth it would take to fix the water. Elon Musk’s net worth, for example, is 19.7 billion and Jeff Bezos’ is 140.9 billion.
Goals: Get practice writing conditional functions.
Exercise 13 Define the function absolute which consumes a number and produces the absolute value of that number (do not use abs).
Exercise 14 Define the function letter-grade. It consumes a Score and produces the corresponding letter grade ("A", "B", "C", "D", or "F"). You may be as wishful as desired in choosing your own grading scale.
Exercise 15 Define a function that given a number of hours worked and an hourly wage computes how much money has been earned. Any hours worked over 40 hours must be paid at 1.5 times the given rate.
Exercise 16 Define the function runtime that given a movie title outputs its runtime in minutes. Ensure the function works on a handful of inputs of your choosing, and for any other inputs throws an error.
Goals: Get practice programming with images and writing a simple animation.
Exercise 18 Congratulations, you’ve moved up a tax bracket. Define a constant WINDOW and place two of them on your humble home. Note how in using a constant we only have to draw it once and get to use it twice!
Exercise 20 Launch your animation by pressing run.
Goals: Use math and conditional programming to make the animation better.
Exercise 21 Use cond (or if if you’re feeling cheeky) to make the circle grow and shrink in a loop instead of grow and suddenly disappear and grow again. Since computing the radius is now a somewhat complex computation, it makes sense to write a separate helper function which only computes the radius that scene calls. Hint: quotient, even?.
Make sure you can log into the handin server and sign the course contract if you didn’t already do that. If you have any questions regarding the lab or the course please feel free to ask a TA or tutor.