DSSSB TGT CS Mock 02 – Question 175

Question:

What is the output of the following Python expression?
print([x**2 for x in range(5) if x % 2 != 0])

निम्नलिखित पायथन व्यंजक का आउटपुट क्या होगा?
print([x**2 for x in range(5) if x % 2 != 0])

Options:

  • [1, 9]
  • [0, 4, 16]
  • [1, 4, 9]
  • [1, 9, 25]
  • [1, 9]
  • [0, 4, 16]
  • [1, 4, 9]
  • [1, 9, 25]

Correct Answer: a)

Explanation:

`range(5)` generates numbers 0, 1, 2, 3, 4.
The condition `x % 2 != 0` filters the odd numbers: 1 and 3.
The squares of these numbers: \(1^2 = 1\) and \(3^2 = 9\).
Output is **[1, 9]** (Option a).

range(5) में विषम संख्याएँ 1 और 3 हैं। इनका वर्ग \(1^2 = 1\) और \(3^2 = 9\) है। अतः परिणाम **[1, 9]** होगा (विकल्प a)।

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top