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
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
Social Sciences,
4 months ago
English,
4 months ago
Math,
4 months ago
Computer Science,
8 months ago
Science,
8 months ago
Physics,
1 year ago