Computer Science, asked by ananyaachandak999, 1 year ago

Python, what is returned when evaluating [n for n in range(10) if n % 2]?

Answers

Answered by Anonymous
1
a list.

[1,2,3,5,7]

It's because it will append those values which are not 0 (False)..

Ex.

when n = 2

then 2 % 2 = 0 so it becomes False.
Answered by vanis2016
0

Answer:

[1, 3, 5, 7, 9]

Explanation:

It's basically a List Comprehension which is using the python range() function to generate a list of integers. Ref:- https://www.techbeamers.com/python-range-function/

Similar questions