1. Home
  2. Data Science
  3. Python
  4. What is the output of print(dict(a=1, b=2)) in Python?

Added 25 Nov 2026

What is the output of print(dict(a=1, b=2)) in Python?

print(dict(a=1, b=2))
  1. {'a': 1}
  2. {'b': 2}
  3. Error
  4. {'a': 1, 'b': 2} Correct answer

Correct answer

D. {'a': 1, 'b': 2}

8 views

MCQSEXAM

Explanation

dict(a=1, b=2) builds a dictionary from keyword arguments.

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 D? 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