Computer Science, asked by devilak551, 8 months ago

Q. 3 What is the output of the following:
(a)
def increment(a):
a.append([5])
return a
L=[1,2,3,4]
M=increment(L)
print (LM)



plz give answer....​

Attachments:

Answers

Answered by Needthat
2

Answer:

[ 1, 2, 3, 4, [5] ] [ 1, 2, 3, 4, [5] ]

Explanation:

L = [ 1, 2, 3, 4, [5] ]

M = [ 1, 2, 3, 4, [5] ]

In the above program the append statement adds a list containing 5 to the input

Hence the input value changes to the output value.

And the assignment operator moves the same value to the assigned variable.

Therefore the output would be

[ 1, 2, 3, 4, [5] ] [ 1, 2, 3, 4, [5] ]

Hope it helps

Similar questions