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 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: -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-3: -The correct syntax to create a Python Dictionary is storing values in the form of key:value pairs. On the left of colon, we store keys and on the right, values i.e. Dictionary is enclosed by curly bracket and do not allow duplicates. According to the 3.7 Python update, dictionaries are now ordered.

Detailed explanation-4: -A Dictionary in python is declared by enclosing a comma-separated list of key-value pairs using curly braces(). Python Dictionary is classified into two elements: Keys and Values. Values can be a list or list within a list, numbers, etc.

There is 1 question to complete.