Data & Code Practice

We can check if two values are equal using the = operator. These practice problems gradually get more difficult.

(= 4
   (+ 2 2))

Modify the following code examples, replacing the underscores with values, so the editor prints true.

(= 10
   (+ 3 _))

(= 30
   (* 5 _))

(= _
   (/ 36 9))

(= _
   (+ (* 3 4)
      (/ 40 5)))

(defn times-five
  [x]
  (* 5 x))

(= _
   (+ (times-five 4)
      5))

(defn square
  [x]
  (* _ _))

(= 9
   (square 3))

Challenge problem time! Hint: you can reference a variable within a function, even if that variable isn't part of the function's input.

(def pi 3.14)

(defn circle-circumference
   [radius]
   (* _ _ _))

(= 12.56
   (circle-circumference 2))