Back Summary

Session #6

Multiple choice: 15/15 correct ยท Short answer: 5/5 answered · completed Sep 6, 2026

Answers

What does Racket ultimately evaluate an expression into?

✓ A value

Which expression correctly follows Racket prefix notation?

✓ (+ 3 4)

What does (substring "012345" 2 4) produce?

✓ "23"

Which library is required for primitives such as rectangle and image-width?

✓ 2htdp/image

What does the text primitive produce?

✓ An Image

What happens when Racket evaluates a constant name such as WIDTH?

✓ It replaces the name with its defined value

What is a predicate?

✓ A function or primitive that produces a Boolean

How does an if expression evaluate its branches?

✓ Only the branch selected by the Boolean question evaluates

What happens when evaluating (and false (/ 1 0))?

✓ The result is false without evaluating the division

Which statement about or is correct?

✓ It is true if any expression is true

Why are parameters useful in a function?

✓ They let the same logic operate on different values

In a function call, what normally happens before parameter values are substituted into the body?

✓ Arguments are reduced to values

What is the best description of overlay compared with above?

✓ overlay stacks images in the same space

What is a good use of the DrRacket Stepper?

✓ Seeing the order in which subexpressions reduce

If you know the primitive beside and want a related image-layout primitive, what strategy from the notes is appropriate?

✓ Search the documentation for beside and scroll around related primitives

What value does (substring "012345" 2 4) evaluate to? Briefly explain which character positions are included.

Evaluates to "23" takes the 2nd and 3rd "elements" in the string

not graded

Accepted answer

"23". The start index 2 is included and the end index 4 is excluded.

What kind of value does (text "Hello" 20 "red") produce: a String, Number, Boolean, or Image?

Image

not graded

Accepted answer

An Image.

Write a Racket expression using and that returns false when x is 0 without attempting to evaluate (/ 10 x), and otherwise checks whether (/ 10 x) is greater than 2.

(and (not (= x 0)) (> (/ 10 x) 2))
not graded

Accepted answer

(and (not (= x 0)) (> (/ 10 x) 2))

Write a Racket expression in prefix notation that calculates 3 + (4 * 2).

(+ 3 (* 4 2))

not graded

Accepted answer

(+ 3 (* 4 2))

Write a Racket function named larger-than-10? that consumes a number n and produces true when n is greater than 10 and false otherwise.

(define (larger-than-10 n)
(> n 10))

not graded

Accepted answer

(define (larger-than-10? n) (> n 10))