NIELIT O Level Exam

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

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

1 और 1000 के बीच नंबर्स की लिस्ट बनाने के लिए एक लिस्ट लिखें, जो 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)]




Correct Answer is :

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.
CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad