INQ241A
Mobile Apps

Review 1

A Miniature Practice Test

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

    function main()
      var n := 0
      turtle→set heading(180)
      for 0 ≤ i < 3 do
        turtle→forward(50)
        n := n + 90
        turtle→left turn(n)
      end for
    end function
  2. 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)
    end function
  3. Create a script with a function called draw triangle with one parameter size. The function should draw a triangle with the side length specified by the parameter size.