1. Home
  2. Data Science
  3. Python
  4. What is the output of print(len({1: 'a', 2: 'b', 1.0: 'c'…

Added 25 Nov 2026

What is the output of print(len({1: 'a', 2: 'b', 1.0: 'c', 3: 'd'})) in Python?

print(len({1: 'a', 2: 'b', 1.0: 'c', 3: 'd'}))
  1. 3 Correct answer
  2. 2
  3. Error
  4. 1

Correct answer

A. 3

6 views

MCQSEXAM

Explanation

Dict comprehension keys 1 and 1.0 collide because they are equal.

Reference

Asked in: Python Interview Output Prediction

https://docs.python.org/3/reference/datamodel.html

Preparing for an exam?

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs