HTTP/1.0 200 OK Content-type: text/html Test 12 -- Tables

,6/10 19:15 CDT,Due date-->9/20/2000 10:00 CDT

  1. Which of the following are associative lists?
    1) telephone book
    2) dictionary
    3) table of contents
    4) zip codes

  2. For x.name='bob', which part is the key/value pair?
    1) x/name
    2) x/bob
    3) name/bob
    4) syntax error

  3. For x['name']='bob', which part is the key/value pair?
    1) x/name
    2) x/bob
    3) name/bob
    4) syntax error

  4. After x.name='bob' is x.name=3 a legal assignment?
    1) yes 2) no

  5. For x={3,4,5,6,7,name='bob'}, give the table reference for the sixth element.

  6. For x={3,4,5,6,7,name='bob'}, give the table reference for the name property.

  7. For x={3,4,5,6,7,name='bob'}, what is the value of x[3/2]?

  8. For x={3,4,5,6,7} x[7]=9, what is the value of x[6]?

  9. For x={}, what is the value of x[11]?

  10. How do you create an array x of 100 integers initialized from 1 to 100?

  11. For x={3,4,5,6,7} x[7]=9, what is the value of #x?

  12. Check all the legal table references.
    1) x[3] 2) x[x[1]] 3) x[6.7] 4) x[true] 5) x["6"]

  13. For x={3,4,5,6,7} write a for-loop to add 1 to every element.

  14. What is printed for the following code?
    a={'xx', 99, 'yy'} a[57]=9
    for key,value in ipairs(a) do
    print(key,value)
    end

  15. What is printed for the following code?
    a={'xx', 99, 'yy'} a[57]=9
    for key,value in pairs(a) do
    print(key,value)
    end

  16. What is the recommended method to remove the last element of an array, such as x?

  17. If x is the array {10, 20, 30}, after the call table.insert(x, 1, 15), what is the value of the array x?

  18. If x is the array {10, 20, 30}, after the call table.insert(x, 15), what is the value of the array x?