What is the output of the following code:
my_list = [1, 2, 3, 4]
print(sum(my_list))
print(sum(my_list))
A. 10
B. [1, 2, 3, 4]
C. 24
D. 6
Answer: Option A
Solution (By Examveda Team)
The correct answer is Option A: 10.The sum() function in Python is used to sum up all the values in an iterable, such as a list. When you pass the list [1, 2, 3, 4] to the sum() function, it adds up all the elements in the list and returns the total sum, which is 10.

Join The Discussion