Python Dictionaries Quiz: Python Dictionaries Multiple Choice Questions

Python Dictionaries Quiz with answers and explanations for placement tests and job interviews. This solved Python Dictionaries Quiz is useful for the campus placement for all freshers including Engineering Students, MCA students, Computer and IT Engineers, etc.

Our Python Dictionaries Quiz focuses on all areas of Python and its concept. We will regularly update the quiz and most interesting thing is that questions come in a random sequence. So every time you will feel new questions.

We have already published a blog post that contains short questions on Python If you want you can also see this blog post “Python interview questions“.

 

There are several Python courses that you may have come across during your search for learning Python. Our team of experts has carefully analyzed some Python courses for you. You can check the courses, Trial of some courses is free.

 

Guideline of Python Dictionaries Quiz:

This Python Dictionaries Quiz is intended for checking your Python knowledge. It takes 40 minutes to pass the Python Data Types Quiz. If you don’t finish the Python Dictionaries Quiz within the mentioned time, all the unanswered questions will count as wrong. You can miss the questions by clicking the “Next” button and return to the previous questions by the “Previous” button. Every unanswered question will count as wrong. MCQ on Python Data Types has features of randomization which feel you a new question set at every attempt.

In this Python Dictionaries Quiz, we have also implemented a feature that not allowed the user to see the next question or finish the quiz without attempting the current Python Dictionaries Quiz.

0 votes, 0 avg

You have 40 minutes to take the Python Dictionaries MCQs

Your time has been Over.


Python Dictionaries Quiz

Python MCQ

Python Dictionaries Quiz: Python Dictionaries Multiple Choice Questions and Answers

1 / 32

What is the output of the following Python Programs?

D = {1 : 1, 2 : '2', '1' : 1, '2' : 3} 
D['1'] = 2
print(D[D[D[str(D[1])]]])

 

2 / 32

Find the output of the following program: Which of these about a dictionary is false?

3 / 32

Consider this dictionary:

d = {'foo': 100, 'bar': 200, 'baz': 300}

What is the result of this statement:

d['bar':'baz']

 

4 / 32

What is the output of the following Python Programs?

a = {'Aticleworld' : 1, 'Atic' : 2} 
b = {'Aticleworld' : 2, 'Atic' : 1} 
print (a == b)

 

5 / 32

What is the output of the following Python Programs?

d1 = {"john":40, "peter":45} 
d2 = {"john":466, "peter":45} 
print (d1 > d2)

 

6 / 32

Consider this nested structure definition:

x = [
    'a',
    'b',
    {
        'foo': 1,
        'bar':
        {
            'x' : 10,
            'y' : 20,
            'z' : 30
        },
        'baz': 3
    },
    'c',
    'd'
]

Is the following statement True or False?

'z' in x[2]

 

 

7 / 32

What is the output of the following Python Programs?

dictionary = {'Atic' : 1, 
            'Aticleworld' : 2, 
            'Atic' : 3
            } 
print(dictionary['Atic']);

 

8 / 32

What is the output of the following Python Programs?

dict ={} 
print (all(dict))

 

9 / 32

Here is the same dictionary as in the previous question:

 

What statement will remove the entry in the dictionary for key 'baz'?

Dictionary python

10 / 32

What is the output of the following Python Programs?

a ={} 
a.fromkeys(['a', 'b', 'c', 'd'], 98) 
print (a)

 

11 / 32

What is the output of the following Python Programs?

dictionary1 = {'Aticleworld' : 1, 
      'Facebook' : 2, 
      'Microsoft' : 3
      } 
dictionary2 = {'Atic' : 1, 
      'Google' : 2, 
      'Youtube' : 3
      } 
dictionary1.update(dictionary2); 
for key, values in dictionary1.items(): 
  print(key, values , end=" ")

 

12 / 32

What is the output of the following Python Programs?

dictionary ={1:"Atic", 2:"Love", 3:"World"} 
del dictionary

 

13 / 32

What is the output of the following Python Programs?

counter = {} 
 
def addToCounter(country): 
    if country in counter: 
        counter[country] += 1
    else: 
        counter[country] = 1
 
addToCounter('Aticleworld') 
addToCounter('India') 
addToCounter('Atic') 
 
print (len(counter))

 

14 / 32

Suppose you have a dictionary d1. Which of the following effectively creates a variable d2 which contains a copy of d1:

15 / 32

In Python, Dictionaries are immutable.

16 / 32

What is the output of the following Python Programs?

dictionary = {1:'1', 2:'2', 3:'3'} 
del dictionary[1] 
dictionary[1] = '10'
del dictionary[2] 
print (len(dictionary) )

 

17 / 32

What is the output of the following Python Programs?

D = {1 : [1, 2, 3], 2: (4, 6, 8)} 
D[1].append(4) 
print(D[1], end = " ") 
L = [D[2]]
L.append(10) 
D[2] = tuple(L) 
print(D[2])

 

18 / 32

Select the correct way to print Emma’s age.

student = {1: {'name': 'Emma', 'age': '27', 'sex': 'Female'},
           2: {'name': 'Mike', 'age': '22', 'sex': 'Male'}}

 

19 / 32

Suppose x is defined as follows:

x = [
    'a',
    'b',
    {
        'foo': 1,
        'bar':
        {
            'x' : 10,
            'y' : 20,
            'z' : 30
        },
        'baz': 3
    },
    'c',
    'd'
]

What is the expression involving x that accesses the value 30?

 

20 / 32

You have the following dictionary definition:

d = {'foo': 100, 'bar': 200, 'baz': 300}

What method call will delete the entry whose value is 200?

21 / 32

What is the output of the following Python Programs?

test = {1:'A', 2:'B', 3:'C'} 
del test[1] 
test[1] = 'D'
del test[2] 
print(len(test))

 

22 / 32

Dictionary keys must be immutable

23 / 32

Shown below is a diagram of a simple dictionary:

Which of the following is not a valid way to define this dictionary in Python:

1. 

d = {'foo': 100, 'bar': 200, 'baz': 300}

2. 

d = {}
d['foo'] = 100
d['bar'] = 200
d['baz'] = 300

3. 

d = {
    ('foo', 100),
    ('bar', 200),
    ('baz', 300)
}

4. 

d = dict(foo=100, bar=200, baz=300)

5. 

d = dict([
    ('foo', 100),
    ('bar', 200),
    ('baz', 300)
])

 

 

 

 

 

 

Dictionary python

24 / 32

What is the output of the following Python Programs?

D = dict() 
for i in range (3): 
    for j in range(2): 
        D[i] = j 
print(D)

 

25 / 32

What is the output of the following Python Programs?

dict1 = {"key1":1, "key2":2}
dict2 = {"key2":2, "key1":1}
print(dict1 == dict2)

 

26 / 32

Which of the following are true of Python dictionaries:

27 / 32

What is the output of the following Python Programs?

a ={} 
a['a']= 1
a['b']=[2, 3, 4] 
print(a)

 

28 / 32

What is the output of the following Python Programs?

D = dict() 
for x in enumerate(range(2)): 
    D[x[0]] = x[1] 
    D[x[1]+7] = x[0] 
print(D)

 

29 / 32

What is the output of the following Python Programs?

D = {1 : {'A' : {1 : "A"}, 2 : "B"}, 3 :"C", 'B' : "D", "D": 'E'} 
print(D[D[D[1][2]]], end = " ") 
print(D[D[1]["A"][2]])

 

30 / 32

What is the output of the following Python Programs?

a = {i: i * i for i in range(6)} 
print (a)

 

31 / 32

What is the output of the following Python Programs?

temp = dict() 
temp['key1'] = {'key1' : 44, 'key2' : 566} 
temp['key2'] = [1, 2, 3, 4] 
for (key, values) in temp.items(): 
    print(values, end = "")

 

32 / 32

Which of the following could be a valid dictionary key:

Your score is

The average score is 0%

0%

Recommended Articles for you:

Leave a Reply

Your email address will not be published. Required fields are marked *