# What will be the output of the following Python code >>> a={'B':5,'A':9,'C':7} >>> sorted(a)

1.  [‘A’,’B’,’C’]

2.  [‘B’,’C’,’A’]

3.  [5,7,9]

4.  [9,5,7]

4

[‘A’,’B’,’C’]

Explanation :
No Explanation available for this question

# What will be the output of the following Python code >>> a={i: i*i for i in range(6)} >>> a

1.  Dictionary comprehension doesn’t exist

2.  {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6:36}

3.  {0: 0, 1: 1, 4: 4, 9: 9, 16: 16, 25: 25}

4.  {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25}

4

{0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25}

Explanation :
No Explanation available for this question

# What will be the output of the following Python code >>> a={} >>> a.fromkeys([1,2,3],"check")

1.  Syntax error

2.  {1:”check”,2:”check”,3:”check”}

3.  “check”

4.  {1:None,2:None,3:None}

4

{1:”check”,2:”check”,3:”check”}

Explanation :
No Explanation available for this question

# What will be the output of the following Python code >>> b={} >>> all(b)

1.  { }

2.  False

3.  True

4.  An exception is thrown

4

True

Explanation :
No Explanation available for this question

# If b is a dictionary, what does any(b) do

1.  Returns True if any key of the dictionary is true

2.  Returns False if dictionary is empty

3.  Returns True if all keys of the dictionary are true

4.  Method any() doesn’t exist for dictionary

4

Returns True if any key of the dictionary is true

Explanation :
No Explanation available for this question

# What will be the output of the following Python code >>> a={"a":1,"b":2,"c":3} >>> b=dict(zip(a.values(),a.keys())) >>> b

1.  {‘a’: 1, ‘b’: 2, ‘c’: 3}

2.  An exception is thrown

3.  {‘a’: ‘b’: ‘c’: }

4.  {1: ‘a’, 2: ‘b’, 3: ‘c’}

4

{1: ‘a’, 2: ‘b’, 3: ‘c’}

Explanation :
No Explanation available for this question

# What will be the output of the following Python code >>> a={i: 'A' + str(i) for i in range(5)} >>> a

1.  An exception is thrown

2.  {0: ‘A0’, 1: ‘A1’, 2: ‘A2’, 3: ‘A3’, 4: ‘A4’}

3.  {0: ‘A’, 1: ‘A’, 2: ‘A’, 3: ‘A’, 4: ‘A’}

4.  {0: ‘0’, 1: ‘1’, 2: ‘2’, 3: ‘3’, 4: ‘4’}

4

{0: ‘A0’, 1: ‘A1’, 2: ‘A2’, 3: ‘A3’, 4: ‘A4’}

Explanation :
No Explanation available for this question

# What will be the output of the following Python code >>> a=dict() >>> a[1]

1.  An exception is thrown since the dictionary is empty

2.  ‘ ‘

3.  0

4.  1

4

An exception is thrown since the dictionary is empty

Explanation :
No Explanation available for this question

# What will be the output of the following Python code >>> import collections >>> a=dict() >>> a=collections.defaultdict(int) >>> a[1]

1.  1

2.  0

3.  An exception is thrown

4.  ‘ ‘

4

0

Explanation :
No Explanation available for this question

# What will be the output of the following Python code >>> import collections >>> a=dict() >>> a=collections.defaultdict(str) >>> a['A']

1.  An exception is thrown since the dictionary is empty

2.  ‘ ‘

3.  ‘A’

4.  0

4