Coursera Answers

Programming Data Structures And Algorithms Using Python Week 4 Quiz Answer | NPTEL

Programming Data Structures And Algorithms Using Python Week 4 Quiz Answer  NPTEL

Programming Data Structures And Algorithms Using Python Week 4 Quiz Answer | NPTEL

In this article i am gone to share NPTEL Course Programming Data Structures And Algorithms Using Python Week 4 Quiz Answer with you..



Week 4 Quiz



Question 1)

Consider the following Python function.

def mystery(l):

    if l == []:

        return(l)

    else:

        return(mystery(l[1:])+l[:1])

What does mystery([22,14,19,65,82,55]) return?

  • [55, 82, 65, 19, 14, 22]

Question 2)

What is the value of pairs after the following assignment?

pairs = [ (x,y) for x in range(4,1,-1) for y in range(5,1,-1) if (x+y)%3 == 0 ]

  • [(4, 5), (4, 2), (3, 3), (2, 4)]

Question 3)Consider the following dictionary.

wickets = {“Tests”:{“Kumble”:[3,5,2,3],”Srinath”:[4,4,1,0],”Prasad”:[2,1,7,4]},”ODI”:{“Kumble”:[2,0],”Srinath”:[1,2]}}

Which of the following statements does not generate an error?

  •  wickets[“ODI”][“Prasad”][0:] = [4,4]
  •  wickets[“ODI”][“Prasad”].extend([4,4])
  •  wickets[“ODI”][“Prasad”] = [4,4]
  •  wickets[“ODI”][“Prasad”] = wickets[“ODI”][“Prasad”] + [4,4]

Question 4)

Assume that hundreds has been initialized as an empty dictionary:

hundreds = {}

Which of the following generates an error?

  •  hundreds[“Tendulkar, international”] = 100
  •  hundreds[“Tendulkar”] = {“international”:100}
  •  hundreds[(“Tendulkar”,”international”)] = 100
  •  hundreds[[“Tendulkar”,”international”]] = 100