प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
In Python, '{1}{0}'.format('a', 'b') produces the string:
सही उत्तर: क) ba
The numbers in braces are positional indices: {1} is 'b' and {0} is 'a'.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: g = (x * x for x in range(3)); print(next(g), next(g)) ?
सही उत्तर: घ) 0 1
A generator yields values one at a time: the first next() gives 0*0 = 0, the second gives 1*1 = 1.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python, count = 0; for i in range(3): for j in range(i): count += 1. What is count after the loops?
सही उत्तर: ख) 3
The inner loop runs 0, 1 and 2 times for i = 0, 1, 2, giving 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print('x' in 'xyz', 'xz' in 'xyz') ?
सही उत्तर: क) True False
'in' on strings checks for a contiguous substring; 'xz' is not contiguous in 'xyz'.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print(dict.fromkeys('ab', 0)) ?
सही उत्तर: ख) {'a': 0, 'b': 0}
fromkeys() creates a dict with each element of the iterable (here each character) as a key, all set to the given value.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python, any([0, '', None, 3]) returns:
सही उत्तर: क) True
any() returns True if at least one element is truthy; 3 is truthy.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print(list(zip(*[(1, 'a'), (2, 'b')]))) ?
सही उत्तर: ग) [(1, 2), ('a', 'b')]
The * unpacks the two tuples as separate arguments; zip then groups first elements together and second elements together.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print([i for i in range(10) if i % 2][-1]) ?
सही उत्तर: घ) 9
The comprehension keeps odd numbers [1, 3, 5, 7, 9]; index -1 gives the last one, 9.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print(isinstance(True, int)) ?
सही उत्तर: घ) True
In Python, bool is a subclass of int, so True is an instance of int.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python, class A's __init__ sets self.x = 1. Class B(A) defines its own __init__ that sets only self.y = 2 and does not call super().__init__(). What does hasattr(B(), 'x') return?
सही उत्तर: ख) False
B's __init__ overrides A's, and since A.__init__ is never called, the attribute x is never created.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।