MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the output of the following code?a={"a":1, “b":2, “c":3}b=dict(zip(a.values(), a.keys()))b
A
{‘a’:1, ‘b’:2, ‘c’:3}
B
Error
C
{’a’, ‘b’, ‘c’}
D
{1:‘a’, 2:‘b’, 3:‘c’}
Explanation: 

Detailed explanation-1: -You can use the get() method of the dictionary ( dict ) to get any default value without an error if the key does not exist. Specify the key as the first argument. The corresponding value is returned if the key exists, and None is returned if the key does not exist.

Detailed explanation-2: -What type of data is: a=[(1, 1), (2, 4), (3, 9)]? Explanation: The variable a has tuples enclosed in a list making it a list of tuples. 9.

Detailed explanation-3: -Keys are unique within a dictionary while values may not be. The values of a dictionary can be of any type, but the keys must be of an immutable data type such as strings, numbers, or tuples.

Detailed explanation-4: -3. Which of the following Python statements will result in the output: 6? Explanation: The output that is required is 6, that is, row 2, item 3. This position is represented by the statement: A[1][2].

There is 1 question to complete.