?
What is the output of the following code:
What is the output of the following code:
my_list = [1, 2, 3, 4]
print(sum(my_list))
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.
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
Login to post a comment or share your explanation.
Login