Name:     ID: 
 
Email: 

Python Programming - Assessment 2

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

 1. 

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=True)
b.
tests.sort(reverse=False)
 

 2. 

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

 3. 

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

 4. 

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

 5. 

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.count(“Jim”)
b.
friends.insert(“Jim”)
d.
friends.index(“Jim”)
 

 6. 

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

 7. 

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
 

 8. 

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

 9. 

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

 10. 

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”)
 



 
         Start Over