MCQ Answer

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 से डिविजिबल हैं।
Topic : Sequence data types in python

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 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz