Question 4
Back to Exercise
What is the output of the following Python program?
d = {1: "int", True: "bool", 1.0: "float"}
print(d, len(d))
- A {1: 'float'} 1 Correct
- B {1: 'int', True: 'bool', 1.0: 'float'} 3
- C {True: 'bool'} 1
- D {1.0: 'float'} 1
Correct Answer: Option A
The three keys are equal with equal hashes, so they are one key. The first key object (1) is kept and each assignment replaces the value, ending with "float".
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!