1. Home
  2. Data Science
  3. Python
  4. What is the output of print(dict.fromkeys('ab', 0)) in…

Added 25 Nov 2026

What is the output of print(dict.fromkeys('ab', 0)) in Python?

print(dict.fromkeys('ab', 0))
  1. {'a': None}
  2. {'a': 0}
  3. {'a': 0, 'b': 0} Correct answer
  4. Error

Correct answer

C. {'a': 0, 'b': 0}

5 views

MCQSEXAM

Explanation

dict.fromkeys accepts a value.

Reference

Asked in: Python Interview Dictionaries

https://docs.python.org/3/tutorial/datastructures.html#dictionaries

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? 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