प्रोग्रामिङ – Programming MCQ
प्रोग्रामिङ – कम्प्युटर र IT
Programming · Computer & IT (Technical) · १,५६५ प्रश्न
१,५६५ प्रश्न उपलब्ध। मोड छान्नुहोस्:
प्रोग्रामिङ: प्रश्न र उत्तर
सही लागेको विकल्पमा थिच्नुहोस्। सही भए हरियो, गलत भए रातो देखिन्छ; ३ सेकेन्डपछि सही उत्तर र व्याख्या देखिन्छ।
सही: ० / ०
-
What is the output of the Python code: print(sorted('cab', reverse=True)) ?
सही उत्तर: ख) ['c', 'b', 'a']
sorted() works on any iterable and always returns a list; reverse=True sorts in descending order.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print(str(12) * 2, int('12') * 2) ?
सही उत्तर: ग) 1212 24
Multiplying a string repeats it, while multiplying an integer is arithmetic.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print(bool([]), bool([0])) ?
सही उत्तर: घ) False True
An empty list is falsy, while a list containing one element (even 0) is non-empty and therefore truthy.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: t = (1, 2, [3]); t[2].append(4); print(t) ?
सही उत्तर: घ) (1, 2, [3, 4])
The tuple itself cannot change, but the list it holds is mutable and can be modified in place.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: d = {}; d.setdefault('k', []).append(1); d.setdefault('k', []).append(2); print(d) ?
सही उत्तर: क) {'k': [1, 2]}
setdefault() inserts [] only if the key is missing and returns the stored list, so both appends go into the same list.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
In Python, s = 0; for i in range(5): if i == 3: break; s += i — and the for loop has an else clause doing s += 100. What is s after the loop?
सही उत्तर: ख) 3
The loop adds 0, 1 and 2, then break is executed at i = 3, so the else clause is skipped; s = 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print(int(3.9) + round(3.5)) ?
सही उत्तर: ग) 7
int() truncates 3.9 to 3, and round(3.5) rounds to the nearest even integer, 4, so the sum is 7.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print('Hello'[1:4:2]) ?
सही उत्तर: ग) el
The slice takes indices 1 and 3 (start 1, stop before 4, step 2), which are e and l.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print(f'{3.14159:.2f}', f'{7:03d}') ?
सही उत्तर: घ) 3.14 007
:.2f rounds to two decimal places and :03d pads the integer with zeros to width 3.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
-
What is the output of the Python code: print(list(map(int, '123'))) ?
सही उत्तर: क) [1, 2, 3]
map() applies int to each character of the string '123'.
💬 टिप्पणी / गल्ती रिपोर्ट (०)
यी अभ्यास प्रश्न हुन्, आधिकारिक प्रश्न होइनन्। पाठ्यक्रम, विज्ञापन र नतिजाका लागि सम्बन्धित निकायको आधिकारिक वेबसाइट हेर्नुहोस्। उत्तरमा गल्ती भेटे प्रश्नमुनिको "टिप्पणी / गल्ती रिपोर्ट" मा लेख्नुहोस्।
नमस्ते! पाठ्यक्रम, सामान्य ज्ञान, भाषा परीक्षा वा कुनै प्रश्नको उत्तर बुझ्न सोध्नुहोस्।
AI ले गल्ती गर्न सक्छ। महत्वपूर्ण कुरा आधिकारिक स्रोतमा जाँच्नुहोस्।