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
Math,
3 months ago
English,
3 months ago
Computer Science,
6 months ago
Science,
6 months ago
Physics,
10 months ago
India Languages,
10 months ago