1. Home
  2. Data Science
  3. Python
  4. What is the output of print({'a': 1, 'b': 2} | {'b': 3})…

Added 25 Nov 2026

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

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

Correct answer

C. {'a': 1, 'b': 3}

5 views

MCQSEXAM

Explanation

The | operator (Python 3.9+) merges dicts; the right operand wins on conflicts.

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