Q:

What will be the output of the following Python list comprehension?

0

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)]

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.

 

 


  1. A list of prime numbers up to 50
  2. A list of numbers divisible by 2, up to 50
  3. A list of non prime numbers, up to 50
  4. Error

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Correct Answer:

A list of non prime numbers, up to 50

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python Multiple Choice Questions And Answers

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
The function pow(x,y,z) is evaluated as:... >>
<< Read the information given below carefully and wri...