Programming, Data Structures And Algorithms Using Python Week 4 Quiz

Consider the following Python function.
  def mystery(l):
     if l == []:
        return (l)
     else:
        return (l[-1:] + mystery(l[:-1]))
What does mystery([31,32,71,18,51]) return?


Ans: [51,18,71,32,31] 
2.5 points
What is the value of pairs after the following assignment?
 pairs = [ (x,y) for x in range(3,0,-1) for y in range(2,0,-1) if (x+y)%3 == 0 ]


Ans: [(2,1),(1,2)] 
2.5 points
2.5 points
Consider the following dictionary.
   marks = {"Quizzes":{"Mahesh":[3,5,7,8],"Suresh":[9,4,8,8],"Uma":[9,9,7,6]},"Exams":{"Mahesh":[37],"Uma":[36]}}
Which of the following statements does not generate an error?

2.5 points
Assume that d has been initialized as an empty dictionary:
  d = {}
Which of the following generates an error?


You may submit any number of times before the due date. The final submission will be considered for grading.

No comments

JavaFX Scene Builder

  This is an article about the JavaFX Scene Builder. You will get a short introduction about the installation and usage of the software. The...