MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Which symbol surrounds a Python dictionary?
A
{
B
(
C
[
D
:
Explanation: 

Detailed explanation-1: -In Python, a dictionary is one of the core data structures. It is a sequence of key-value pairs separated by commas and surrounded by curly braces.

Detailed explanation-2: -The dict() function creates a dictionary. A dictionary is a collection which is unordered, changeable and indexed.

Detailed explanation-3: -Sets: Set class is used to represent the collection of elements without duplicates, and without any inherent order to those elements. It is enclosed by the and each element is separated by the comma(, ) and it is mutable.

Detailed explanation-4: -A dictionary item has a key/value pair. A colon (:) separates each key from its value, commas divide the elements, and curly braces surround the entire thing. Keys are distinct within a dictionary, although values may or may not be.

Detailed explanation-5: -When we call , we execute a Python statement, so Python immediately knows what to do-build a dictionary. In comparison, when we call dict(), Python has to find the dict() function and call it. That’s because nothing stops you from overriding the dict() function.

There is 1 question to complete.