IT 116: Introduction to Scripting
Answers to Class 23 Ungraded Quiz
-
Write a Python expression that creates a slice containing the second through the fourth elements
of the list l1.
l1[1:4]
-
Write a Python expression that evaluates to True if the list l1
contains the value 4.
4 in l1
-
Write a Python statement to add 6 to the list l1.
l1.append(6)
-
Write a Python expression that concatenates the lists l1
and l2.
l1 + l2
-
Write a Python statement that prints the LAST element in the list l1.
print(l1[-1])
-
Write a Python statement that removes the first element in the list l1.
del l1[0]
-
Write a Python statement that sorts the list l1.
l1.sort()
-
Write a Python statement that sorts the list l1 in reverse order.
l1.reverse()
-
Write a Python expression that gives the largest value in the list l1.
max(l1)
-
Write a Python expression that gives the smallest value in the list l1.
min(l1)