list = [1,2,3,4,5,6,7,8,9,10] l = sum(list[::2]) print(l)
Answers
Answered by
17
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