Programming, Data Structures and Algorithms Using Python - Unit 10 - Week 4 Quiz
Programming, Data Structures and Algorithms Using Python - Unit 10 - Week 4 Quiz
Week 4 Quiz
The due date for submitting this assignment has passed.
Due on 2022-08-24, 23:59 IST.
Score: 10/10=100%
def mystery(l):
if l == []:
return(l)
else:
return(mystery(l[1:])+l[:1])
What does mystery([22,14,19,65,82,55]) return?
Feedback:
Elements are moved from the beginning of the list to the end, so the list gets reversed.
Accepted Answers:
(Type: Regex Match) [ ]*[[ ]*55[ ]*,[ ]*82[ ]*,[ ]*65[ ]*,[ ]*19[ ]*,[ ]*14[ ]*,[ ]*22[ ]*][ ]*
What is the value of pairs after the following assignment? 2.5 points
Feedback:
All pairs (i,j) with i ∈ {4,3,2}, j ∈ {5,4.3,2} such that i + j is a multiple of 3,
Accepted Answers:
(Type: Regex Match) [ ]*[[ ]*\([ ]*4[ ]*,[ ]*5[ ]*\)[ ]*,[ ]*\([ ]*4[ ]*,[ ]*2[ ]*\)[ ]*,[ ]*\([ ]*3[ ]*,[ ]*3[ ]*\)[ ]*,[ ]*\([ ]*2[ ]*,[ ]*4[ ]*\)[ ]*][ ]*
Consider the following dictionary. 2.5 points2.5 points
wickets = {"Tests":{"Bumrah":[3,5,2,3],"Shami":[4,4,1,0],"Ashwin":[2,1,7,4]},"ODI":{"Bumrah":[2,0],"Sham
i":[1,2]}}
wickets["ODI"]["Ashwin"][0:] = [4,4]
wickets["ODI"]["Ashwin"].extend([4,4])
wickets["ODI"]["Ashwin"] = [4,4]
wickets["ODI"]["Ashwin"] = wickets["ODI"]["Ashwin"] + [4,4]
Yes, the answer is correct.
Score: 2.5
Feedback:
Direct assignment to a new key adds a value. All other updates result in KeyError.
Accepted Answers:
wickets["ODI"]["Ashwin"] = [4,4]
Assume that hundreds has been initialized as an empty dictionary: 2.5 points
hundreds = {}
Feedback:
Dictionary keys must be immutable values.
Accepted Answers:
hundreds[["Tendulkar","international"]] = 100
https://onlinecourses.nptel.ac.in/noc22_cs70/unit?unit=57&assessment=126 1/1