प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
In Python, class Counter has a class attribute count = 0, and its __init__ does Counter.count += 1. After a = Counter(); b = Counter(), what is Counter.count?
सही उत्तर: ग) 2
Each object creation increments the shared class attribute, so after two objects it is 2.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python: try: n = int('5') / except ValueError: print('bad') / else: print(n * 2). What is printed?
सही उत्तर: घ) 10
No exception occurs, so the else block runs and prints 5 * 2 = 10.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python: try: print(1/0) / except ZeroDivisionError: print('Z') / else: print('E') / finally: print('F'). What is printed?
सही उत्तर: ग) Z then F
The exception runs the except block (Z); the else block runs only if no exception occurs; finally always runs (F).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python, X = 5 is defined at module level, and def g(): print(X); X = 3. What happens when g() is called?
सही उत्तर: ग) UnboundLocalError is raised
Because X is assigned inside g, it is local throughout g, so printing it before assignment raises UnboundLocalError.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print(list(map(lambda x: x % 3, [3, 4, 5]))) ?
सही उत्तर: क) [0, 1, 2]
The lambda is applied to each element: 3 % 3 = 0, 4 % 3 = 1, 5 % 3 = 2.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python, def f(**k): return sorted(k). What does print(f(b=1, a=2)) display?
सही उत्तर: ग) ['a', 'b']
**k collects keyword arguments into a dict; sorted() on a dict sorts its keys.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python, def f(*a): return len(a). What does print(f(1, [2, 3], 'xy')) display?
सही उत्तर: ख) 3
*a collects the three positional arguments into a tuple; the list and string each count as one argument.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python, def f(x, y=2): return x ** y. What does print(f(3), f(2, 3)) display?
सही उत्तर: क) 9 8
f(3) uses the default y = 2 giving 9; f(2, 3) gives 2 ** 3 = 8.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python, 7 // 2.0 evaluates to:
सही उत्तर: क) 3.0
Floor division with a float operand returns a float: floor(3.5) = 3.0.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What value does Python give for 2 raised to the power -1, written 2 ** -1?
सही उत्तर: ख) 0.5
A negative exponent gives the reciprocal: 2 ** -1 = 1/2 = 0.5.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।