Name:     ID: 
 
Email: 

Python Programming - Assessment 2

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

 1. 

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]
 

 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. 

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

 4. 

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

 5. 

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

 6. 

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)
 

 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. 

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

 9. 

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

 10. 

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



 
         Start Over