प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
What does the following Python code print? print({k: v for k, v in zip('abc', [1, 2, 3]) if v != 2})
सही उत्तर: घ) {'a': 1, 'c': 3}
zip pairs 'a'-1, 'b'-2, 'c'-3, and the condition skips the pair whose value is 2.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What does the following Python code print? print(list(enumerate('xy', start=1)))
सही उत्तर: क) [(1, 'x'), (2, 'y')]
enumerate() pairs each item with a counter, which here starts from 1.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python, what happens when s = 'abc' is followed by s[0] = 'x'?
सही उत्तर: ग) a TypeError is raised because strings are immutable
Python strings are immutable, so item assignment raises TypeError.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python, class P has def __init__(self, x): self.x = x and def __eq__(self, o): return self.x == o.x. What does print(P(1) == P(1), P(1) is P(1)) display?
सही उत्तर: घ) True False
== calls the user-defined __eq__, which compares x values; 'is' checks identity, and two separate objects are not identical.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python, def outer(): c = 0; def inner(): nonlocal c; c += 1; return c; return inner. What is printed by g = outer(); g(); print(g()) ?
सही उत्तर: ख) 2
The closure keeps the variable c alive between calls; the second call increases it to 2.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python, def f(n): return n and n + f(n - 1). What does print(f(4)) display?
सही उत्तर: ग) 10
When n is 0, 'n and ...' returns 0 and stops the recursion, so f(4) = 4 + 3 + 2 + 1 + 0 = 10.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What does the following Python code print? try: raise ValueError('x') / except Exception as e: print(type(e).__name__)
सही उत्तर: क) ValueError
The except clause catches the ValueError object, and type(e).__name__ gives the name of its actual class.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What does the following Python code print? print([1, 2] == [2, 1], {1, 2} == {2, 1})
सही उत्तर: घ) False True
Lists are ordered, so [1, 2] and [2, 1] differ; sets are unordered, so {1, 2} equals {2, 1}.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What does the following Python code print? print((1, 2, 3) < (1, 3))
सही उत्तर: ख) True
Tuples are compared element by element: the first elements are equal, and 2 < 3 decides the result.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What does the following Python code print? print(next((x for x in [3, 8, 5] if x > 4), None))
सही उत्तर: ग) 8
next() returns the first value produced by the generator, i.e. the first element greater than 4, which is 8.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।