प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
Determine the output of this Python 3 code: n = 0 while True: n += 1 if n * n > 50: break print(n)
सही उत्तर: ग) 8
7 * 7 = 49 is not greater than 50, but 8 * 8 = 64 is, so the loop stops at n = 8.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this Python 3 code: print(f"{'ab':*>4}|{5:0<3}|")
सही उत्तर: ख) **ab|500|
'*>4' right-aligns 'ab' in a width of 4 using * as the fill character, and '0<3' left-aligns 5 in a width of 3 padded with zeros on the right.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this Python 3 code: print('%.2f' % (2 / 3))
सही उत्तर: क) 0.67
2 / 3 = 0.6666..., which rounds to 0.67 with two decimal places.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this Python 3 code: print(' '.join(sorted('the quick brown fox'.split(), key=len)))
सही उत्तर: घ) the fox quick brown
Words are sorted by length (3 before 5); Python's sort is stable, so equal-length words keep their original order.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this Python 3 code: try: d = {} d['k'] += 1 except KeyError as e: print('K', e)
सही उत्तर: ग) K 'k'
d['k'] += 1 must first read the missing key, raising KeyError; printing the exception shows the key in quotes, 'k'.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this Python 3 code: print(any(x > 3 for x in [1, 2]), all(x > 0 for x in [1, 2]))
सही उत्तर: ख) False True
No element is greater than 3, so any() is False; every element is positive, so all() is True.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this Python 3 code: class A: def f(self): return self.g() def g(self): return 'A' class B(A): def g(self): return 'B' print(B().f())
सही उत्तर: क) B
f is inherited from A, but self refers to a B object, so self.g() calls B's overriding g.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this Python 3 code: class A: def __init__(self): self.x = 1 class B(A): def __init__(self): super().__init__() self.x += 1 print(B().x)
सही उत्तर: घ) 2
super().__init__() sets x to 1 and B's constructor then increases it to 2.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this Python 3 code: print(list(range(10))[2:8:3])
सही उत्तर: ग) [2, 5]
The slice starts at index 2 and takes every third item before index 8: 2 and 5.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Determine the output of this Python 3 code: a = [1, 2, 3]; a[1:1] = [7, 8]; print(a)
सही उत्तर: ख) [1, 7, 8, 2, 3]
Assigning to the empty slice a[1:1] inserts the new items at index 1 without removing anything.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।