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

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

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

#### Week 2 Quiz

Question 1)

One of the following 10 statements generates an error. Which one? (Your answer should be a number between 1 and 10.)

• x = [“slithy”,[7,10,12],2,”tove”,1]  # Statement 1
• y = x[0:50]                                   # Statement 2
• z = y                                            # Statement 3
• w = x                                           # Statement 4
• x = x[:5] + ‘ery’                    # Statement 5
• y = 4                                       # Statement 6
• z = 42                                     # Statement 7
• w[:3] = ‘fea’                            # Statement 8
• x = 5555                            # Statement 9
• a = (x == 1)                       # Statement 10

ANS: 8 (i chose it on the occurence of error i.e statement 8 gave error first)

Question 2)

Consider the following lines of Python code.

• b = [23,44,87,100]
• a = b[1:]
• d = b[2:]
• c = b
• d = 97
• c = 77

ANS: a == 87, b == 77, c == 77, d == 97

Question 3)

What is the value of endmsg after executing the following lines?

startmsg = “python”

endmsg = “”

for i in range(1,1+len(startmsg)):

endmsg = startmsg[-i] + endmsg

ANS: ‘python’

Question 4)

What is the value of mylist after the following lines are executed?

def mystery(l):

l = l[1:]

return()

mylist = [7,11,13]

mystery(mylist)

ANS: [7,11,13]