0

nums = [i**2 for i in range(5)] print(nums) [1, 4, 9, 16] "..what will this create..?" "Correct" answer was: "A list of even numbers between 0 and 18." 9 is not an even number tho. Is this a typo or am i missunderstanding/missinterpreting?

28th Aug 2016, 6:33 PM
Andrew4200
Andrew4200 - avatar
3 odpowiedzi
+ 3
Yes, but once the list is filled after the operations the list is a list of numbers again. However, working with integers the Max number/square is 16. Don't understand why it says 18. And other doubt... range excludes the last number (5), but it doen't includes the zero as the first iterable?
28th Aug 2016, 10:27 PM
Carlos Sacanell
Carlos Sacanell - avatar
0
i*2 would be even numbers, i**2 are squares
28th Aug 2016, 6:45 PM
Demeth
Demeth - avatar
0
nums = [i**2 for i in range(5)] print(nums) will give [0,1,4,9,16]
29th Aug 2016, 3:19 AM
Sagar Pohekar