INQ241B
Mobile Apps

Review 1

A Miniature Practice Test

  1. What are variables useful for?

  2. Draw what the following script would draw when run.

    function main()
      var n := 0
      for 0 ≤ i < 4 do
        turtle→forward(50)
        turtle→left turn(n)
        n := n + 90
      end for
    end function
  3. Draw what the following script would draw when run.

    function do something(
      a: Number)
    do
      turtle→left turn(a)
      turtle→forward(100)
      turtle→right turn(a)
    end function
    
    function main()
      do something(90)
      turtle→forward(100)
      do something(45)
    end function
  4. Create a script with a function called draw square with one parameter size. The function should draw a square with the side length specified by the parameter size.