प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
In Python, class P has __init__(self, n) storing self.n = n and __add__(self, o) returning P(self.n + o.n). What does print((P(2) + P(5)).n) display?
सही उत्तर: ख) 7
The + operator calls the overloaded __add__, which returns a new P whose n is 2 + 5 = 7.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: g = (i for i in range(3)); print(sum(g), sum(g)) ?
सही उत्तर: क) 3 0
The first sum consumes the generator (0 + 1 + 2 = 3); a generator can be iterated only once, so the second sum is 0.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
When max() is applied directly to a dictionary in Python, what does print(max({'a': 3, 'b': 1})) display?
सही उत्तर: घ) b
Iterating over a dictionary gives its keys, so max() compares 'a' and 'b' and returns 'b'.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print(round(3.14159, 3), round(1234, -2)) ?
सही उत्तर: ग) 3.142 1200
round(x, 3) keeps three decimals (3.142); a negative ndigits rounds to the left of the decimal point, so 1234 becomes 1200.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
Comparing a list with a range object in Python 3: what does print(list(range(3)) == [0, 1, 2], range(3) == [0, 1, 2]) display?
सही उत्तर: ख) True False
list(range(3)) is the list [0, 1, 2], but a range object is not equal to a list, so the second comparison is False.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: a = [1, 2, 3]; b = a; a += [4]; print(b) ?
सही उत्तर: क) [1, 2, 3, 4]
For lists, += extends the same list object in place, so b, which refers to it, also shows the new element.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: a = [1, 2, 3]; b = a; a = a + [4]; print(b) ?
सही उत्तर: घ) [1, 2, 3]
a + [4] creates a new list and rebinds a to it; b still refers to the original list [1, 2, 3].
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print(hex(255), oct(8)) ?
सही उत्तर: ग) 0xff 0o10
hex(255) gives '0xff' and oct(8) gives '0o10' (8 in base 8 is 10).
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: from functools import reduce; print(reduce(lambda a, b: a * b, [1, 2, 3, 4])) ?
सही उत्तर: ख) 24
reduce applies the function cumulatively: ((1 x 2) x 3) x 4 = 24.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: a = 'abc'; print(a[::-1] + a[0]) ?
सही उत्तर: क) cbaa
a[::-1] reverses the string to 'cba', and a[0] is 'a', giving 'cbaa'.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।