UPDATE TO ANSWER OF QUESTION 1 : PLEASE CHECK

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

x = [[7,8],3,”hello”,[6,8],”world”,17] # Line 1
z = [x[0],x[3]] # Line 2
y = x[0:50] # Line 3
w = x # Line 4
w[0][1] = 7 # Line 5
a = z[0][1] + z[1][1] # Line 6
x[0] = “ping” # Line 7
y[2] = y[2][1] + y[4][2] # Line 8
y[0][1] = 7 # Line 9
w[0][1] = 7 # Line 10

Answer(s) : Line 10

2) What is the value of mystring after the following lines are executed?

def mystery(s):
for i in range(len(s),1,-2):
s = s[1:]+s[0];
return(s)

mystring = “siruseri”
mystring = mystery(mystring)

a) x[1][1] == 14, y[1][1] == 14, u[1][1] == 15, v[1][1] == 15
b) x[1][1] == 17, y[1][1] == 15, u[1][1] == 14, v[1][1] == 15
c) x[1][1] == 17, y[1][1] == 15, u[1][1] == 17, v[1][1] == 15
d) x[1][1] == 14, y[1][1] == 15, u[1][1] == 14, v[1][1] == 15

Answer(s) : serisiru

Consider the following lines of Python code.
a = ‘nptel’
b = [12,14,16]
c = 72

x = [a,b,c]
y = [a,b[:],c]
u = x[:]
v = y

b[1] = 17
v[1][1] = 15

Which of the following is correct?

(a) x[1][1] == 14, y[1][1] == 14, u[1][1] == 15, v[1][1] == 15
(b) x[1][1] == 17, y[1][1] == 15, u[1][1] == 14, v[1][1] == 15
(c) x[1][1] == 17, y[1][1] == 15, u[1][1] == 17, v[1][1] == 15
(d) x[1][1] == 14, y[1][1] == 15, u[1][1] == 14, v[1][1] == 15

Answer(s) : (c)  x[1][1] == 17, y[1][1] == 15, u[1][1] == 17, v[1][1] == 15


a = ‘nptel’
b = [12,14,16]
c = 72

x = [a,b,c]
y = [a,b[:],c]
u = x[:]
v = y

b = [12,17,16]
v[1][1] = 15

Which of the following is correct?

(a) x[1][1] == 14, y[1][1] == 14, u[1][1] == 15, v[1][1] == 15
(b) x[1][1] == 17, y[1][1] == 15, u[1][1] == 14, v[1][1] == 15
(c) x[1][1] == 17, y[1][1] == 15, u[1][1] == 17, v[1][1] == 15
(d) x[1][1] == 14, y[1][1] == 15, u[1][1] == 14, v[1][1] == 15

Answer(s) : (d) x[1][1] == 14, y[1][1] == 15, u[1][1] == 14, v[1][1] == 15
Categories: NPTEL solution

4 Comments

Kuldeep bairwa · February 20, 2018 at 12:41 PM

Thanks a lot for these all kind of help 😉

    Yash Sodha · February 20, 2018 at 4:29 PM

    Thank you! Keep supporting!

      Kuldeep Bairwa · February 20, 2018 at 5:08 PM

      I think 1st question’s answer is line 10 not line 5

Kuldeep Bairwa · February 20, 2018 at 5:08 PM

I think 1st question’s answer is line 10 not line 5

Leave a Reply

Your email address will not be published. Required fields are marked *