Q. Consider the following similar codes (carefully go through these) and predict their outputs.


(i)

NList = [60, 32, 13, 'hello' ]
print (NList[1], NList[-2])
NList.append( 15 )
print(len (NList))
print( len(NList[3]))
NList.pop(3)
NList.sort()
NList.insert(2, [14, 15])
NList[3] += NList[4]
NList[3] += NList[2][1]
print (NList[3])
NList.pop()
NList[2].remove(14)
print (NList)

(ii)

NList = [ 60, 32, 13, 'hello']
print (NList[1], NList[-2])
NList.append( 15 )
print(len (NList) )
print(len (NList[3]))
NList.pop(3)
NList.insert (2, [14, 15])
NList[3] += NList[4]
NList[3] += NList[2][1]
print (NList[3])
NList[2].remove (14)
print (NList)

Answer :-

(i)

Output :-

32 13
5
5
107
[13, 15, [15], 107]

>>>

(ii)

Output:-

32 13
5
5
43
[60, 32, [15], 43, 15]

>>>

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post