A

Admin • 833K Points
Coach

Q. What will be the output of following python code?

Code:
a=[1,2,3,4]
b=[sum(a[0:x+1]) for x in range(0,len(a))]

print(b)
  • (A) 10
  • (B) [1,3,4]
  • (C) 4
  • (D) [1,3,6,10]
  • Correct Answer - Option(D)
  • Views: 28
  • Filed under category Python
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.