Question

1.
2.
3.
4.
Answer (Detailed Solution Below)

Option 2 : [2, 4, 8]

Advertisement

Detailed Solution

सही उत्तर [2, 4, 8] है।

Key Points
Helpful?
PrepSnapprepsnap.in • Part -A

Question:

What is the output of the following Python code? x = [i for i in range(10) if i % 2 == 0 if i % 3 != 0]; print(x) / निम्नलिखित Python कोड का आउटपुट क्या है?

1.
[0, 2, 4, 8]
2.
[2, 4, 8]
3.
[2, 4, 6, 8]
4.
[0, 2, 4, 6, 8]

Correct Answer: [2, 4, 8]

The even numbers below 10 are 0, 2, 4, 6, 8; the second condition removes multiples of 3, which are 0 and 6 (0 is also a multiple of 3). Hence [2, 4, 8]. / 10 से छोटी सम संख्याएँ 0, 2, 4, 6, 8 हैं; दूसरी शर्त 3 के गुणजों को हटाती है, जो 0 और 6 हैं (0 भी 3 का गुणज है)। अतः [2, 4, 8]।

Downloaded from PrepSnap (prepsnap.in)