Test Index

Python Revision Tour Get it on Google PlayDownload on the App Store CBSE Board Videos

© examsnet.com
Question : 86 of 102
Marks: +1, -0
Which function returns the sum of all elements of a list ?
[CBSE 2023 Set 4]
Solution:  
Concept:
sum(list) is a built-in function that adds all the (numeric) elements of a list or tuple.
Explanation:
L = [10, 20, 30]
print(sum(L)) # 60
count(x) counts how many times x occurs; total() and add() are not built-in functions for lists.
Answer:
Option B (sum())
© examsnet.com
Advertisements
Go to Question: