practicepython.in
python exercises
171 exercises

Daily #11 · 9 October 2026

Three keys, one entry Hard

What does this print?

d = {1: "one", True: "yes", 1.0: "float"}
print(d)
  1. A{1: 'one', True: 'yes', 1.0: 'float'}
  2. B{1: 'float'}
  3. C{1.0: 'float'}
  4. D{True: 'float'}
Show the answer

B: {1: 'float'}

Why: 1, True and 1.0 are equal and hash the same, so a dict treats them as one key. The first spelling of the key is kept; the last value wins.

Play today’s puzzle →