For each math expression below, translate it to Racket.
Example:
Expression: \(3 + 2\cdot 5^{2}\)
With Parentheses: \((3 + (2\cdot (5^{2})))\)
In Racket: (+ 3 (* 2 (expt 5 2)))
Test Case: (check-expect (+ 3 (* 2 (expt 5 2))) 53)
You just need to write the Test Case line, but make sure it’s right!
For each function defined below, create a T-chart for the domain values -2, -1, 0, 1, and 2. (You can put the function and chart in a comment between #| and |#.) Then write the function and five test cases to make sure you translated it correctly.
For example, if the problem were \(f(x) = 3x^2 - 1\), you would write:
#| f(x) = 3x^2 - 1 x | f(x) ----+------ -2 | 11 -1 | 2 0 | -1 1 | 2 2 | 11 |# (define (f x) (- (* 3 (expt x 2)) 1)) (check-expect (f -2) 11) (check-expect (f -1) 2) (check-expect (f 0) -1) (check-expect (f 1) 2) (check-expect (f 2) 11)
Here’s the starter code for animating a circle.
(define (circle-pic t)
(place-image (circle 20 "solid" "yellow")
t 100
(empty-scene 200 200)))
(animate circle-pic)This makes a yellow circle move from left to right in the middle of a 200 pixel by 200 pixel scene. For each description below, change the function so that the animation changes as described.
You can just name each function with its number: circle-pic-1, circle-pic-2, etc. Don’t forget to add the right number in the animate function or nothing will change.