On this page:
1 Welcome!
2 Practicing computer science
3 Download and install Dr  Racket
4 Dr  Racket as a calculator
5 Chaining operations
6 The definitions window
7 Comments
8 Stepping
9 Images
10 Making images
11 Definitions
8.14

Lecture 1: DrRacket and arithmetic🔗

1 Welcome!🔗

This here Web site is where we post most information about the course, including all assignments. Before each lecture, you will prepare by studying a Web page like this one. There are several sections on the page, each with videos for you to watch. After each video, there are some quick exercises to check your understanding. Do the exercises before moving on to the next video.

You don’t need to submit anything for this lecture. But starting with the next lecture, you are required to submit the online exercises, so that we can confirm that you are keeping up. This is due by midnight on Tuesday and Sunday before each in-person lecture. We do not accept late homework.

Exercise 1. Watch Abbey describe her experience in this course. She is interviewed by Niyati, an undergraduate instructor who also took the course.

Then, answer these questions:
  • What will happen in this course?

  • How will you succeed in this course?

Exercise 2. We will use Discord to ask and answer questions, make announcements, and hang out. Sign up with the link we announced on Canvas when the course started. Change your nickname on Discord to the full name you’d like us to use in this class. Then, introduce yourself in the #introductions channel.

If you would like to talk to only instructors on Discord, type /breakout (with a forward slash at the beginning of the message) then hit Enter. This should create a “breakout channel” that only you and the staff can see.

Two safety tips on Discord (actually, on any network): First, enable two-factor authentication (next to your password setting). Second, don’t open any download you receive through a private message.

2 Practicing computer science🔗

This course doesn’t just teach you some programming language. Our goal is to train you in a systematic way to write programs in any language (past and future), and to introduce you to the discipline of computer science. This can be a joy:

Just as with learning to do something with your body like playing a new sport, in order to learn computer science, it is not enough to watch other people play or to photocopy the sweat stains they leave behind. You have to practice yourself. You have to sit in front of a computer and make mistakes, as well as talk to people, read articles, write. This course will require you to do all of these things.

Every week, we will have:
  • Two lecture assignments, due online at midnight on Tuesday and Sunday. (To prepare for some lectures, there is an additional reading assignment that requires you to read articles that are many pages long.)

  • Two lecture sessions on Monday and Wednesday. Lectures will meet in person.

  • One problem set, due online at midnight on Wednesday. Start early.

  • One lab, on Thursday or Friday. Each lab will come with a set of exercises to practice what you learned that week. Labs will meet and be graded in person.

During the semester, there will be three exams: two midterm exams and a final exam. The problems on the exams will be very similar to what you do in labs and problem sets. However, it will be on paper, not on any computer.

3 Download and install DrRacket🔗

If you’ll be using your own computer for any of the work in this course, you need to install DrRacket. Follow the instructions on this page to download and install DrRacket. It’s available for any platform you might want.

Start DrRacket (not Racket). In the lower-left corner, choose the language Beginning Student, because that is the language we will be using. In the upper-right corner, click the Run button, so that the change takes.

4 DrRacket as a calculator🔗

Exercise 3. Use the Beginning Student language to add the numbers 123 and 456 together.

Exercise 4. Use the Beginning Student language to add the numbers 123, 456, and 789 together. (Hint: the + operation can take more than 2 inputs at once.)

5 Chaining operations🔗

Exercise 5. Use the Beginning Student language to multiply 10 by the sum of the numbers 123 and 456.
Exercise 6. Use the Beginning Student language to add the numbers 123, 456, and 789 together, but do not give the + operation more than 2 inputs at once. Instead, use the + operation twice, each time with just 2 inputs.

Exercise 7. What is wrong with each of the following formulas?
  • (3 + 2)

  • (5)

  • ((+ 3 2))

6 The definitions window🔗

Exercise 8. Put the 4 formulas you made above in the Definitions Window. Make sure that when you click the Run button, the Interactions Window shows exactly 4 results
579
1368
5790
1368
in that order.

7 Comments🔗

Exercise 9. In the Definitions Window, put the comments
; Exercise 3
; Exercise 4
; Exercise 5
; Exercise 6
above each of the 4 formulas, so that it is easy for people to see which formula is for which exercise above. These comments should be ignored by DrRacket, so make sure that when you click the Run button, the Interactions Window shows the same 4 results as before.

8 Stepping🔗

Exercise 10. Show step-by-step calculations for your formula for Exercise 5. Show step-by-step calculations for your formula for Exercise 6. Use the Stepper to confirm that your step-by-step calculations are correct.

The code written in the videos above is available for your reference. To download it, don’t use “Save Page As” or “Save As”; use “Save Link As” or “Download Linked File” in your Web browser. If you can’t find the command, try right-clicking or two-finger-tapping or long-pressing.

9 Images🔗

Exercise 11. In the Definitions Window, put
(require 2htdp/image)
to access the 2htdp/image library.

Copy two images from the Internet, and combine them using one of the following functions provided by the 2htdp/image library.
; overlay : Image Image -> Image
; underlay : Image Image -> Image
; above : Image Image -> Image
; beside : Image Image -> Image
; place-image : Image Number Number Image -> Image
Only overlay and place-image are shown in the video above, but you can learn about the other functions by experimenting with them, or by watching this additional optional video about images. By the way, all these operations except place-image can actually take more than 2 inputs at once.

Add your formula for combining the images to the bottom of your Definitions, so that when you click the Run button, the Interactions Window shows 4 numbers followed by 1 composite image.

10 Making images🔗

Exercise 12. Combine some images with an image that is not copied from the Internet but made from scratch. To make an image from scratch, you can either use the text function described in the video above, or use the circle, square, or rectangle function described in this additional optional video about images. When you click the Run button, the Interactions Window should show 4 numbers followed by 2 composite images.

Exercise 13. Show step-by-step calculations for your formula for Exercise 12. Use the Stepper to confirm that your step-by-step calculations are correct.

11 Definitions🔗

The code written in the videos above is available for your reference. To download it, don’t use “Save Page As” or “Save As”; use “Save Link As” or “Download Linked File” in your Web browser. If you can’t find the command, try right-clicking or two-finger-tapping or long-pressing.

That’s it for this lecture!

Optional: Read the Prologue and Chapter 1 of the textbook.