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

  1. Write a Python expression that creates a slice containing the second through the fourth elements of the list l1.
    l1[1:4]
  2. Write a Python expression that evaluates to True if the list l1 contains the value 4.
    4 in l1
  3. Write a Python statement to add 6 to the list l1.
    l1.append(6)
  4. Write a Python expression that concatenates the lists l1 and l2.
    l1 + l2
  5. Write a Python statement that prints the LAST element in the list l1.
    print(l1[-1])
  6. Write a Python statement that removes the first element in the list l1.
    del l1[0]
  7. Write a Python statement that sorts the list l1.
    l1.sort()
  8. Write a Python statement that sorts the list l1 in reverse order.
    l1.reverse()
  9. Write a Python expression that gives the largest value in the list l1.
    max(l1)
  10. Write a Python expression that gives the smallest value in the list l1.
    min(l1)