Before you can start on the lab, you need to log in to a lab computer and change your password:
SmithLeeLab1.rkt
If there are others in the class with the same name as yours, you your initial in addition
to your last name: MSmithJLeeLab1.rkt
Even though you will be working in pairs or groups, every person needs to change their password before starting the lab.
The lab is done in groups of 2 or 3. You will use a pair-programming approach: one person is a "driver", i.e. types in program instructions, and the other person is a "navigator", i.e. guides the driver as to what to type and what to do next. The roles are switched every 10-15 minutes. For this lab it will be convenient to switch at the end of each exercise. If you are working in groups of three, the roles are: a "driver", a "navigator", and a "quality control" person. Again, make sure to switch frequently.
Start DrRacket from the Activities list. Make sure that the language is set to "Beginning student". If it's not, go to "Language" menu of DrRacket and set it. Also, if you have troubles accessing image functions (in problem 3) then go to "Language -> Add Teachpack" and add "2htdp\image.rkt" from the middle column.
You may also start DrRacket by double-clicking on a downloaded Racket file, such as first.rkt
If you have accidentally added the teachpack from the first column, you will be getting error messages when using image functions such as rotate, either that the function definition is not found or that a module has been imported twice. If this is happening, clear both image.rkt teachpacks and then add the one in the middle column.
Start your lab by typing a comment in the beginning of the file with the lab number and the names (first and last) of all group members. Recall that Racket comments are lines that start with ; (a semicolon).
You should create a folder for your work in this class, and possibly a subfolder for the lab so that you can keep each lab and each problem set in a separate folder. In order to save a file go to "File -> Save Definitions As..." and navigate to your folder. Make sure to save your file with the extension .rkt. After you've done it once you can just use "Save" (or Ctrl-S) to save the file.
You may do all your work in one file or in separate ones, whichever you find more convenient. Make sure to submit all your files.
At the end of the lab please send me and your group partner(s) all your Racket files as e-mail attachments. My e-mail is elenam at morris.umn.edu. The subject of your e-mail must be "1301 Lab 1" followed by "Final" or "Not final", depending on whether this is a final submission or you are still working on it. If you need to finish it, make sure to set up a time with your group partner(s) to finish the lab.
Due Wednesday, September 6, at 11:59pm. If you submit the final version during the lab, you are done.
Write Racket expressions that correspond to the given math expressions. Check your answers
by running the program, or, even better, by
using check-expect
.
For instance, if are given 3 * (12/4 + 2)
,
you rewrite it as a Racket expression as (* 3 (+ (/ 12 4) 2))
.
Run it to check the answer, or, better yet, figure out the answer before running the code,
and use check-expect
to check:
(check-expect (* 3 (+ (/ 12 4) 2)) 15)
Below are math expressions to write in Racket:
1.5 * 2 + 21/3
(3 + 2 + 7)/(11 - 1 - 4)
(3*(-2 +4))/(8/2 + sqrt(4))
cos(0) + sin(0)
, where cos
and sin
are the cosine and sine functions,
respectively. Racket uses cos
and sin
as
function names.
Find out what the following Racket functions do by testing them on
different arguments:
<=, max, gcd
.
For example, what happens if a function is applied to more than two
arguments? Fewer than two?
Please submit all of the tests that you tried in order to determine
what the function does. Explain your findings in comments. You may
read the function
descriptions here
if you would like, but the
descriptions of the functions that you submit for the lab
must be your own.
Your task is to use functions in image.rkt teachpack to create a red shape that has a side of 200 pixels and looks like this:
There are different ways of creating this shape. Some functions that you may find helpful are: square, triangle, right-triangle, rectangle, rhombus, rotate, overlay, beside, above.
Use variable as you find useful. For example, if you are using an image more than once, you might want to save it in a variable. Good use of variables is one of the criteria used for evaluating your work.
Do not use check-expect for images at this point since it doesn't always work as expected.
Test three "what if" questions of your choice in Racket. For example, you might want to try applying + function to strings. Write down what you think is going to happen, test it, and write down if that was what you expected. If an expression that you test results in an error, comment it out before you move on to the next one.
Make sure that your file is named correctly:
Name your file with the combination of your last names, no spaces, followed by the word "Lab"
and the lab number.
For instance,
if your last names are Smith and Lee, the file name should be SmithLeeLab1.rkt
If there are others in the class with the same name as yours, you your initial in addition
to your last name: MSmithJLeeLab1.rkt
At least one person in the group must submit it via canvas as a file upload (make sure it's that .rkt
file).
Make a comment indicating who you worked with. The other person (or people) in the group may submit the same file and also
indicate who was in the group or just make a comment listing all your group members (note: if you don't submit a note listing
your group members,
your work may not be counted, even if your group partners list you as the group member).