Report Bug

Qus

Write a list comprehension equivalent for the Python code shown below.

for i in range(1, 101):  	if int(i*0.5)==i*0.5:  		print(i)
Qusनीचे दिखाए गए Python कोड के बराबर एक लिस्ट काम्प्रीहेन्शन लिखें।


A. [i for i in range(1, 100) if int(i*0.5)==(i*0.5)]
B. [i for i in range(1, 101) if int(i*0.5)==(i*0.5)]
C. [i for i in range(1, 101) if int(i*0.5)=(i*0.5)]
D. [i for i in range(1, 100) if int(i*0.5)=(i*0.5)]


Solution
B. [i for i in range(1, 101) if int(i*0.5)==(i*0.5)]



Explanation
The code shown above prints the value ‘i’ only if it satisfies the condition: int(i*0.5) is equal to (i*0.5). Hence the required list comprehension is: [i for i in range(1, 101) if int(i*0.5)==(i*0.5)].
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