NPTEL Programming, Data Structures And Algorithms Using Python Week 4 Quiz Assignment | NPTEL Swayam Assignment Answers
MCQs (multiple choice questions) Nptel Week 4 Quiz Answers:
Note:
(1) If the question asks about a value of type string, remember to enclose your answer in single or double quotes.
(2) If the question asks about a value of type list, remember to enclose your answer in square brackets and use commas to separate list items.
Q.1: Consider the following Python function.
What does mystery([22,14,19,65,82,55]) return?
Answer is: [55, 82, 65, 19, 14, 22]
Q.2: What is the value of pairs after the following assignment?
Answer is: [(4, 5), (4, 2), (3, 3), (2, 4)]
Q.3: Consider the following dictionary.
Options are:
(a) wickets["ODI"]["Ashwin"][0:] = [4,4]
(b) wickets["ODI"]["Ashwin"].extend([4,4])
(c) wickets["ODI"]["Ashwin"] = [4,4]
(d) wickets["ODI"]["Ashwin"] = wickets["ODI"]["Ashwin"] + [4,4]
Answer is (c) wickets["ODI"]["Ashwin"] = [4,4]
Q.4: Assume that hundreds has been initialized as an empty dictionary:
hundreds = {}
Which of the following generates an error?
Options are:
(a) hundreds["Tendulkar, international"] = 100
(b) hundreds["Tendulkar"] = {"international":100}
(c) hundreds[("Tendulkar","international")] = 100
(d) hundreds[["Tendulkar","international"]] = 100
Answer is (d) hundreds[["Tendulkar","international"]] = 100
0 Comments