Session #6
Answers
What does Racket ultimately evaluate an expression into?
Which expression correctly follows Racket prefix notation?
What does (substring "012345" 2 4) produce?
Which library is required for primitives such as rectangle and image-width?
What does the text primitive produce?
What happens when Racket evaluates a constant name such as WIDTH?
What is a predicate?
How does an if expression evaluate its branches?
What happens when evaluating (and false (/ 1 0))?
Which statement about or is correct?
Why are parameters useful in a function?
In a function call, what normally happens before parameter values are substituted into the body?
What is the best description of overlay compared with above?
What is a good use of the DrRacket Stepper?
If you know the primitive beside and want a related image-layout primitive, what strategy from the notes is appropriate?
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
Evaluates to "23" takes the 2nd and 3rd "elements" in the string
"23". The start index 2 is included and the end index 4 is excluded.
"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
Image
An Image.
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))
```racket (and (not (= x 0)) (> (/ 10 x) 2)) ```
(and (not (= x 0)) (> (/ 10 x) 2))
(and (not (= x 0)) (> (/ 10 x) 2))
Write a Racket expression in prefix notation that calculates 3 + (4 * 2).
(+ 3 (* 4 2))
(+ 3 (* 4 2))
(+ 3 (* 4 2))
(+ 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))
(define (larger-than-10 n) (> n 10))
(define (larger-than-10? n) (> n 10))
(define (larger-than-10? n) (> n 10))