What is the output of print(sum(x for x in range(5))) in Python?
print(sum(x for x in range(5)))
Correct answer
C. 10
7 views
C. 10
7 views
sum() works with generator expressions.
Asked in: Python Interview Advanced
https://docs.python.org/3/library/index.htmlNot sure why the answer is C? Ask here and get an explanation.