Vidyalelo
Python · Q22

Python Built

Programming · Python · question 22

Q22

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

A.
10
Answer
B.
[1, 2, 3, 4]
C.
24
D.
6

Answer: Option A

Solution

Answer: Option A
Solution:
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.