ExamVeda
Login
Home
Python Built In Functions
?

What is the output of the following code:
my_list = [1, 2, 3, 4]
print(sum(my_list))

Answer & Solution
Correct Answer: Option A
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.
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.