English, asked by thakurmaninder3317, 2 months ago

What is the output of following?
list = [1,2,3,4,5,6,7,8,9,10]
l = sum(list[::2])
print(l)

Answers

Answered by saikiranshrivatsan
2

Answer:

OUTPUT:

25

explanation:

[::2] means beg value is subscript 0,end value is subscript [-1]. Step value is 2.

so the reqd. values are 1,3,5,7,9

The sum of these are 25, which is now stored in l.

So print sum will give 25

:)

Answered by poojan
15

25 is the output.

Explanation:

  • list = [1,2,3,4,5,6,7,8,9,10] is a list that consists 1 to 10 numbers within it.

  • list[::2] takes out the list of values with an slice difference of 2 between successors, starting from index 0, then 0+2 = 2, 2+2=4 and so on. So, it results list[::2] = [1, 3, 5, 7, 9]

  • sum(list[::2]) sums the elements present in the sliced list, i.e., sum( [1, 3, 5, 7, 9] ) = 25 and it is stored into variable l.

  • So, on printing the variable l using print(l), we get 25 as output.

Learn more:

1) Printing all the palindromes formed by a palindrome word.

brainly.in/question/19151384

2) Indentation is must in python. Know more about it at :

brainly.in/question/17731168

Similar questions