+ 3
mySum = sum (range (5)) ?
mySum contain 10 how, explain working principle?
3 Answers
+ 8
range(5) creates a range object, that contains all integers from 0 to 4, if you convert it to a list you'll get [0, 1, 2, 3, 4].
sum() function summarizes all elements of iterable, so in your case it'll be 0+1+2+3+4=10
+ 2
"range(5)" generates the integers 0, 1, 2, 3, 4
"sum" sums them up, thus 0+1+2+3+4 = 10
- 1
Podem me arranjar um scratch de jeito!