T Thê Hy New member Sep 20, 2021 #1 What will be the output of the following Python code? Code: def change(var, lst): var = 1 lst[0] = 44 k = 3 a = [1, 2, 3] change(k, a) print(k) print(a) A. 3 [44, 2, 3] B. 1 [1,2,3] C. 3 [1,2,3] D. 1 [44,2,3]
What will be the output of the following Python code? Code: def change(var, lst): var = 1 lst[0] = 44 k = 3 a = [1, 2, 3] change(k, a) print(k) print(a) A. 3 [44, 2, 3] B. 1 [1,2,3] C. 3 [1,2,3] D. 1 [44,2,3]
N Như Quỳnh Lan New member Sep 20, 2021 #2 Answer: a Explanation: A list is mutable, hence it’s value changes after function call. However, integer isn’t mutable. Thus its value doesn’t change. Upvote 0 Downvote
Answer: a Explanation: A list is mutable, hence it’s value changes after function call. However, integer isn’t mutable. Thus its value doesn’t change.