Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following Python list comprehension?
[j for i in range(2,8) for j in range(i*2, 50, i)]

What will be the output of the following Python list comprehension?
[j for i in range(2,8) for j in range(i*2, 50, i)]
a) A list of prime numbers up to 50
b) A list of numbers divisible by 2, up to 50
c) A list of non prime numbers, up to 50
d) Error

Answer: c
Explanation: The list comprehension shown above returns a list of non-prime numbers up to 50. The logic behind this is that the square root of 50 is almost equal to 7. Hence all the multiples of 2-7 are not prime in this range.

Join The Discussion