Find the output of the following code:-
result = 0
numList = [10,20,30]
numList.append(40)
result = result+numList.pop()
result = result+numList.pop()
print(result)
Find the output of the following code:-
result = 0
numList = [10,20,30]
numList.append(40)
result = result+numList.pop()
result = result+numList.pop()
print(result)
Solution
✅ Correct Option: 1
append(40) makes the list . pop() with no index removes and returns the last element.
The first pop() returns , so .
The second pop() returns , so
print(result) shows a single number, not a pair like "40, 30", because result holds only the running sum.
Related questions:
2025: 16 May Shift 1