Nptel The Joy Of Computing Using Python | NPTEL Week 5 Quiz Assignment | NPTEL Assignment Solutions

NPTEL The Joy Of Computing Using Python Week 5 Quiz Assignment | NPTEL Swayam Assignment Answers


nptel the jot of computing using python


MCQs (multiple choice questions) Nptel Week 5 Quiz Answers:

Q.1: What is the correct way to initialize a dictionary? Options are:

(a) D = {a-10, b-20, c-30}
(b) D = {‘a’-10, ‘b’-20, ‘c’-30}
(c) D = {a:10, b:20, c:30}
(d) D = {‘a’:10, ‘b’:20, ‘c’:30}

Answer is (d) D = {‘a’:10, ‘b’:20, ‘c’:30}


Q.2: What is the correct syntax to get all the keys only from a dictionary d? Options are:

(a) d.key()
(b) d.item()
(c) d.value()
(d) d.keys()

Answer is (d) d.keys()


Q.3: Which of the following statements are true about dictionaries in python? Options are:

(a) The keys of a dictionary must be unique values.
(b) The keys of a dictionary can or cannot be unique.
(c) The values of a dictionary must be unique values.
(d) The values of a dictionary can or cannot be unique.

Answer is (a) The keys of a dictionary must be unique values.
                    (d) The values of a dictionary can or cannot be unique.


Q.4: State True or False: In the monte hall problem, swapping the choice does not increase the chance of winning. Options are:

(a)  True
(b)  False

Answer is (b) False


Q.5: In dictionaries, d.items() will return _. Options are:

(a) Pairs of all (key, value) together.
(b) All (keys) and (values) separately.
(c) All (values) and (keys) separately.
(d) Pairs of all (value, key) together.

Answer is (a) Pairs of all (key, value) together.


Q.6: What will be the output of the following program? Options are:

what will be the output of the following program


(a) A dictionary with all letters as keys and 0 as values.
(b) A dictionary with some letters as keys and 0 as values.
(c) A dictionary with all letters as keys and some random numbers as values.
(d) A dictionary with some letters as keys and some random numbers as values.

Answer is (d) A dictionary with some letters as keys and some random numbers as values.


Q.7: Binary search can be applied on ___. Options are:

(a) Sorted list in ascending order.
(b) Unsorted list
(c) Both A and B
(d) Sorted list in descending order

Answer is (a) Sorted list in ascending order.
                   (d) Sorted list in descending order


Q.8: Which error is encountered while accessing a position that is not present in a list? options are:

(a) KeyError
(b) IndexError
(c) RunTimeError
(d) ValueError

Answer is (b) IndexError


Q.9: Which of the following command is correct to delete a key from a dictionary ‘d’? Options are: 

(a) d.pop(‘key’)
(b) d.del(‘key’)
(c) d.remove(‘key’)
(d) d.delete(‘key’)

Answer is (a) d.pop(‘key’)


Q.10: Which of the following is/are correct regarding dictionaries?
1) One can make a dictionary inside a dictionary in python.
2) Keys in the dictionary are mutable.

(a) Option 1 is correct, option 2 is correct. Option 2 is the correct explanation for option 1.
(b) Option 1 is correct, option 2 is incorrect. Option 2 is not the correct explanation for option 1.
(c) Option 1 is correct, option 2 is correct. Option 2 is not the correct explanation for option 1.
(d) None of these

Answer is (b) Option 1 is correct, option 2 is incorrect. Option 2 is not the correct explanation for option 1.


If you are facing any queries regarding this assignment solutions, then please drop comment in comment section.



Post a Comment

0 Comments