Examveda

What is the output of the following code:
my_list = [1, 2, 3, 4]
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.

This Question Belongs to Python Program >> Python Built In Functions

Join The Discussion

Related Questions on Python Built In Functions