Q. Write a list comprehension for producing a list of numbers between 1 and 1000 that are divisible by 3.

  • (A) [x in range(1, 1000) if x%3==0]
  • (B) [x for x in range(1000) if x%3==0]
  • (C) [x%3 for x in range(1, 1000)]
  • (D) [x%3=0 for x in range(1, 1000)]
πŸ’¬ Discuss
βœ… Correct Answer: (B) [x for x in range(1000) if x%3==0]
Explanation: the list comprehension [x for x in range(1000) if x%3==0] produces a list of numbers between 1 and 1000 that are divisible by 3.

Explanation by: Mr. Dubey
the list comprehension [x for x in range(1000) if x%3==0] produces a list of numbers between 1 and 1000 that are divisible by 3.

πŸ’¬ Discussion

πŸ“Š Question Analytics

πŸ‘οΈ
472
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
85%
Success Rate