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

File Uploading in PHP

  File Uploading in PHP PHP allow you to upload any type of a file i.e. image, binary or text files.etc..,PHP has one in built global variab...