IT 116: Introduction to Scripting
Answers to Class 24 Ungraded Quiz

  1. If l1 is a list, what is l2 after the following statement is executed?
    l2 = l1
    a new list variable pointing to the same list as l1
  2. Write a Python statement that creates a new list, l2, that has all the elements of the list l1 in the same order.
    l2 = l1[:]
  3. Can a function that is given a list as a parameter and does not have a return statement change the list given as a parameter?
    yes
  4. If l1 and l2 are list variables, write a Python statement that creates the new list l3 that consists of all the elements in l1 followed by all the elements in l2.
    l3 = l1 + l2
  5. Write a loop that increases the value of all the integers in the list l1 by 2.
    for i in range(len(l1)):
    	l1[i] += 2