Name:     ID: 
 
Email: 

Python Programming - Assessment 2

Multiple Choice
Identify the choice that best completes the statement or answers the question.
 

 1. 

friends = [“Kevin”, “Karen”, “Jim”, “Jim”, “Oscar”,”Toby”]
List method used to determine how many duplicates of “Jim” are in the friends list.
a.
friends.extend(“Jim”)
c.
friends.index(“Jim”)
b.
friends.insert(“Jim”)
d.
friends.count(“Jim”)
 

 2. 

Suppose a list with name tests, contains 10 elements. You can get the 5th element from the tests list using:
a.
tests[‘4’]
c.
tests[‘5’]
b.
tests[5]
d.
tests[4]
 

 3. 

friends = [“Kevin”, “Karen”, “Jim”, “Oscar”,”Toby”]
List method used to locate the position where “Jim” is located in the friends list.
a.
friends.extend(“Jim”)
c.
friends.index(“Jim”)
b.
friends.insert(“Jim”)
d.
friends.count(“Jim”)
 

 4. 

friends = [“Kevin”, “Karen”, “Jim”, “Oscar”,”Toby”]
Print statement that will print, [“Karen” “Jim”]
a.
print(friends[1:2])
c.
print(friends[1:3])
b.
print(friends[2:3])
 

 5. 

List method used to add “orange” to the end of the fruits list.
fruits = [“apple”, “banana”, “cherry”]
a.
fruits.pop(“orange”)
c.
fruits.append(“orange”)
b.
fruits.clear(“orange”)
d.
fruits.insert(“orange”)
 

 6. 

Change the value from “apple” to “kiwi” in the fruit list.
fruits = [“apple”, “banana”, “cherry”]
a.
“apple”= “kiwi”
c.
fruits[0] = “kiwi”
b.
fruits = “kiwi”
d.
fruits[1] = “kiwi”
 

 7. 

A list with name tests, contains 10 test grades. You can sort the list of test grades in descending order by:
a.
tests.sort(reverse=False)
b.
tests.sort(reverse=True)
 

 8. 

Print the second item in the fruits list.
fruits = [“apple”, “banana”, “cherry”]
a.
print(fruits[1])
c.
print(fruits)
b.
print(fruits[-1])
d.
print(fruits[2])
 

 9. 

List method used to add “lemon” as the second item in the fruits list.
fruits = [“apple”, “banana”, “cherry”]
a.
fruits.index(1, “lemon”)
c.
fruits.index(2, “lemon”)
b.
fruits.insert(1, “lemon”)
d.
fruits.insert(2, “lemon”)
 

 10. 

List method used to remove “cherry” from the fruits list.
fruits = [“apple”, “banana”, “cherry”]
a.
fruits.remove(“cherry”)
c.
del fruits[-1]
b.
fruits.pop( )
d.
All of the above
 



 
         Start Over