Name:     ID: 
 
Email: 

Python Programming - Assessment 3

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

 1. 

Which of the following creates an empty elements dictionary?
a.
elements = ( )
c.
elements = { }
b.
elements = [ ]
 

 2. 

What will be the output of the following?
tup = (1, 2, 4, 3)
print(tup[1:3])
a.
(2, 4)
c.
(1, 2, 4)
b.
(2, 4, 3)
 

 3. 

Which of these collections defines a DICTIONARY?
a.
{“name”: “apple”, “color”: “green”}
c.
(“apple”, “banana”, “cherry”)
b.
{“apple”, “banana”, “cherry”}
d.
[“apple”, “banana”, “cherry”]
 

 4. 

Method used to retrieve and output “Mustang” from the following dictionary.
car = {"brand": "Ford",  "model": "Mustang", "year": 1964}
a.
print(car.get(“model”))
c.
print(car.values(“model”))
b.
print(car.keys(“model”))
 

 5. 

Method used to remove the last key/value element from a dictionary.
a.
get( )
c.
popitem( )
b.
pop( )
 

 6. 

Which of the following print statements will print Jill’s position?
dictTeam = {“name”: “Jill”, “age”: 17, “position”: “catcher”}
a.
print(dictTeam)
c.
print(dictTeam[“position”])
b.
print(dictTeam(“position”))
 

 7. 

Which of these collections defines a TUPLE?
a.
{“name”: “apple”, “color”: “green”}
c.
(“apple”, “banana”, “cherry”)
b.
{“apple, “banana”, “cherry”}
d.
[“apple”, “banana”, “cherry”]
 

 8. 

Method used to output  “Ford”, “Mustang”, 1964 from the following dictionary.
car = {"brand": "Ford",  "model": "Mustang", "year": 1964}
a.
print(car.get( ))
c.
print(car.values( ))
b.
print(car.keys( ))
 

 9. 

Which of these collections defines a LIST?
a.
{“name”: “apple”, “color”: “green”}
c.
(“apple”, “banana”, “cherry”)
b.
{“apple”, “banana”, “cherry”}
d.
[“apple, “banana”, “cherry”]
 

 10. 

Suppose list1 is [3, 4, 5, 6, 20, 25, 1, 3]. What is the output of print( len(list1))?
a.
7
c.
8
b.
3
 



 
         Start Over