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

[quads id=1]