NPTEL Week 4 Quiz
1. Consider the following Python function.
def mystery(l, v):
if len(l) == 0:
return v
else:
return mystery(l[:-1], l[-1] + v)
What does mystery([22,14,19,65,82,55],1) return?
2. What is the value of triples after the following assignment?
triples = [(x, y, z) for x in range(2, 4) for y in range(2, 5) for z in range(5, 7) if 2*x*y > 3*z]
3. Consider the following dictionary.
runs = {"Test": {"Rahul": [90, 14, 35], "Kohli": [3, 103, 73, 42], "Pujara": [53, 15, 133, 8]},
"ODI": {"Sharma": [37, 99], "Kohli": [63, 47]}}
Which of the following statements does not generate an error?
4. Assume that inventory has been initialized as an empty dictionary:
inventory = {}
Which of the following generates an error?
⚠️Disclaimer: The provided solutions are offered for reference purposes only, and we cannot guarantee their absolute accuracy. Students are encouraged to use these solutions as a learning aid and to verify their work independently. We emphasize the importance of understanding the concepts and completing assignments on your own.
No comments:
Post a Comment