Question:

Which of the following built-in function/method returns a dictionary?

Show Hint

Use dict() to build a new dictionary,
and use keys(), values(), and items() to access parts of an existing one.
  • dict()
  • keys()
  • values()
  • items()
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is A

Solution and Explanation

In Python, the dict() function is a built-in constructor
that creates a new dictionary object.
It can take key-value pairs or other mappings to create a dictionary.
keys(), values(), and items() are methods that work on an existing dictionary,
but they do not create a new dictionary.
keys() returns a view of the dictionary’s keys,
values() returns a view of its values,
and items() returns a view of its key-value pairs as tuples.
Only dict() actually creates and returns a dictionary object.
Therefore, option (A) is correct.
Was this answer helpful?
0
0

Top Questions on Programming in Python

View More Questions

Questions Asked in CBSE CLASS XII exam

View More Questions