Python Language से सम्बंधित 100+ महत्वपूर्ण वैकल्पिक प्रश्न
Python Language से सम्बंधित 100+ महत्वपूर्ण वैकल्पिक प्रश्न (Python Language 100+ MCQ's In Hindi)
1. Python क्या है?
a) एक low-level programming language
b) एक high-level, interpreted programming language
c) एक hardware component
d) एक operating system
उत्तर: b
2. Python में variable की अधिकतम लंबाई क्या है?
a) 16 characters
b) 32 characters
c) 64 characters
d) कोई निश्चित लंबाई नहीं
उत्तर: d
3. निम्नलिखित में से कौन सा Python का reserved keyword नहीं है?
a) if
b) else
c) print
d) while
उत्तर: c
स्पष्टीकरण: Python में print एक built-in function है, न कि reserved keyword। if, else, और while reserved keywords हैं जो syntax में विशेष अर्थ रखते हैं।
4. Python में variable को declare करने से पहले उसका data type निर्दिष्ट करना आवश्यक है?
a) हाँ
b) नहीं
c) केवल integers के लिए
d) केवल strings के लिए
उत्तर: b
स्पष्टीकरण: Python एक dynamically typed language है, जिसमें variable declaration के समय data type निर्दिष्ट करने की आवश्यकता नहीं होती। Variable का type runtime पर निर्धारित होता है।
5. निम्नलिखित कोड का आउटपुट क्या होगा?
x = 5
y = 2
print(x ** y)
a) 10
b) 7
c) 25
d) 32
उत्तर: c
स्पष्टीकरण: ** operator exponentiation को दर्शाता है। यहाँ, x ** y का अर्थ है 5^2, जो 25 है।
6. Python में list और tuple के बीच मुख्य अंतर क्या है?
a) List mutable है, tuple immutable है
b) Tuple mutable है, list immutable है
c) दोनों mutable हैं
d) दोनों immutable हैं
उत्तर: a
स्पष्टीकरण: List mutable होती है, यानी इसके elements को बदला जा सकता है, जबकि tuple immutable होती है, यानी इसके elements को एक बार assign करने के बाद बदला नहीं जा सकता।
7. निम्नलिखित में से कौन सा valid variable name है?
a) 1variable
b) variable_name
c) variable@name
d) variable-name
उत्तर: b
स्पष्टीकरण: Python में variable name केवल अक्षर, अंक, और underscore (_) से शुरू हो सकता है। यह अंक से शुरू नहीं हो सकता और विशेष वर्ण (@, -, आदि) का उपयोग नहीं हो सकता।
8. निम्नलिखित कोड का आउटपुट क्या होगा?
print("Hello" + "World")
a) Hello World
b) HelloWorld
c) Hello+World
d) Error
उत्तर: b
स्पष्टीकरण: + operator strings को concatenate करता है। यहाँ "Hello" और "World" बिना space के जुड़कर "HelloWorld" बनाते हैं।
9. Python में indentation का उपयोग क्यों किया जाता है?
a) Code को सुंदर बनाने के लिए
b) Code blocks को define करने के लिए
c) Syntax error से बचने के लिए
d) उपरोक्त सभी
उत्तर: b
स्पष्टीकरण: Python में indentation का उपयोग code blocks (जैसे loops, functions, conditionals) को define करने के लिए किया जाता है। यह syntax का हिस्सा है।
10. निम्नलिखित कोड का आउटपुट क्या होगा?
def foo():
try:
return 1
finally:
return 2
k = foo()
print(k)
a) 1
b) 2
c) Error
d) 3
उत्तर: b
स्पष्टीकरण: Python में, यदि try और finally block दोनों में return statements हैं, तो finally block का return statement try block के return को override करता है। इसलिए आउटपुट 2 होगा।
11. Python में *args का उपयोग किस लिए किया जाता है?
a) Fixed number of arguments पास करने के लिए
b) Variable number of positional arguments पास करने के लिए
c) Keyword arguments पास करने के लिए
d) Default arguments पास करने के लिए
उत्तर: b
स्पष्टीकरण: *args का उपयोग function में variable number of positional arguments पास करने के लिए किया जाता है। यह arguments को tuple के रूप में प्राप्त करता है।
12. निम्नलिखित कोड का आउटपुट क्या होगा?
word = "Python Programming"
print(word[1:6])
a) ython
b) Python
c) ython
d) thon P
उत्तर: a
स्पष्टीकरण: String slicing में [1:6] index 1 से शुरू होकर index 5 तक के characters लेता है। यहाँ "Python Programming" में index 1 से 5 तक "ython" है।
13. Python में package क्या है?
a) एक single Python file
b) एक folder जिसमें multiple Python modules और init.py file होती है
c) एक built-in library
d) एक external software
उत्तर: b
स्पष्टीकरण: Python में package एक folder है जिसमें multiple Python modules और एक init.py file होती है, जो यह indicate करता है कि folder एक package है।
14. निम्नलिखित में से कौन सा data type immutable है?
a) List
b) Dictionary
c) Set
d) Tuple
उत्तर: d
स्पष्टीकरण: Tuple एक immutable data type है, जिसके elements को assign करने के बाद बदला नहीं जा सकता। List, dictionary, और set mutable हैं।
15. निम्नलिखित कोड का आउटपुट क्या होगा?
numbers = [1, 2, 3, 4]
print(numbers[-1])
a) 1
b) 2
c) 3
d) 4
उत्तर: d
स्पष्टीकरण: Negative indexing में -1 list के last element को represent करता है। यहाँ numbers[-1] 4 है।
16. Python में lambda function क्या है?
a) एक named function
b) एक anonymous function
c) एक built-in module
d) एक class
उत्तर: b
स्पष्टीकरण: Lambda function एक anonymous (बिना नाम का) function है जो single expression को evaluate करता है। इसका उपयोग छोटे operations के लिए किया जाता है।
17. निम्नलिखित कोड का आउटपुट क्या होगा?
for i in range(3):
print(i, end=" ")
a) 0 1 2
b) 1 2 3
c) 0 1
d) 1 2
उत्तर: a
स्पष्टीकरण: range(3) 0 से 2 तक integers generate करता है। end=" " के कारण आउटपुट एक line में spaces के साथ print होता है।
18. Python में global variable और local variable में क्या अंतर है?
a) Global variable केवल functions में accessible होता है
b) Local variable program के बाहर accessible होता है
c) Global variable program में कहीं भी accessible होता है, local variable केवल function में
d) दोनों एक समान हैं
उत्तर: c
स्पष्टीकरण: Global variable program में कहीं भी accessible होता है, जबकि local variable केवल उस function के अंदर accessible होता है जिसमें इसे define किया गया है।
19. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
x.append(4)
print(x)
a) [1, 2, 3]
b) [1, 2, 3, 4]
c) [4, 1, 2, 3]
d) Error
उत्तर: b
स्पष्टीकरण: append() method list में element को अंत में जोड़ता है। यहाँ x में 4 append होने के बाद list [1, 2, 3, 4] हो जाती है।
20. Python में set का उपयोग किस लिए किया जाता है?
a) Ordered collection of elements
b) Unordered collection of unique elements
c) Key-value pairs को store करने के लिए
d) Immutable elements को store करने के लिए
उत्तर: b
स्पष्टीकरण: Set एक unordered collection है जो unique elements को store करता है। यह duplicates को allow नहीं करता।
21. निम्नलिखित कोड का आउटपुट क्या होगा?
x = "hello"
print(x.upper())
a) HELLO
b) hello
c) Hello
d) Error
उत्तर: a
स्पष्टीकरण: upper() method string के सभी characters को uppercase में convert करता है। यहाँ "hello" को "HELLO" में convert किया जाएगा।
22. Python में None का क्या अर्थ है?
a) Zero value
b) Empty string
c) No value or null
d) Boolean False
उत्तर: c
स्पष्टीकरण: None Python में null value को represent करता है, जो यह indicate करता है कि variable का कोई value नहीं है।
23. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
y = x
y[0] = 4
print(x)
a) [1, 2, 3]
b) [4, 2, 3]
c) [1, 4, 3]
d) Error
उत्तर: b
स्पष्टीकरण: Python में list assignment (=) reference copy करता है। y = x के बाद, x और y दोनों एक ही list को point करते हैं। y[0] = 4 करने से x भी change हो जाता है।
24. Python में dictionary की key के लिए कौन सा data type valid नहीं है?
a) String
b) Integer
c) List
d) Tuple
उत्तर: c
स्पष्टीकरण: Dictionary की key immutable होनी चाहिए। String, integer, और tuple immutable हैं, इसलिए valid हैं, लेकिन list mutable है, इसलिए invalid है।
25. निम्नलिखित कोड का आउटपुट क्या होगा?
def test(*args):
for arg in args:
print(arg, end=" ")
test("Sunday", "Monday", "Tuesday")
a) SundayMondayTuesday
b) Sunday Monday Tuesday
c) Error
d) None
उत्तर: b
स्पष्टीकरण: *args variable number of arguments को tuple के रूप में लेता है। end=" " के कारण arguments spaces के साथ print होते हैं।
26. Python में list comprehension का उपयोग क्या है?
a) List को sort करने के लिए
b) List को create और modify करने के लिए एक concise तरीका
c) List को delete करने के लिए
d) List को reverse करने के लिए
उत्तर: b
स्पष्टीकरण: List comprehension एक concise syntax है जो list को create और modify करने के लिए उपयोग होता है, जैसे [x for x in range(5)]।
27. निम्नलिखित कोड का आउटपुट क्या होगा?
x = {1, 2, 2, 3}
print(len(x))
a) 4
b) 3
c) 2
d) Error
उत्तर: b
स्पष्टीकरण: Set duplicates को remove करता है। यहाँ {1, 2, 2, 3} में 2 duplicate है, इसलिए set {1, 2, 3} बनता है और len(x) 3 है।
28. Python में finally block का उपयोग किस लिए किया जाता है?
a) Exception को handle करने के लिए
b) Code को हमेशा execute करने के लिए, चाहे exception हो या न हो
c) Loop को terminate करने के लिए
d) Function को define करने के लिए
उत्तर: b
स्पष्टीकरण: finally block हमेशा execute होता है, चाहे exception raise हो या न हो। इसका उपयोग cleanup operations के लिए होता है।
29. निम्नलिखित कोड का आउटपुट क्या होगा?
x = "abcd"
for i in x:
print(i.upper())
a) ABCD
b) A B C D
c) a b c d
d) A
B
C
D
उत्तर: d
स्पष्टीकरण: Loop प्रत्येक character को iterate करता है और upper() method इसे uppercase में print करता है। प्रत्येक character नई line में print होता है।
30. Python में init method का उपयोग क्या है?
a) Class को delete करने के लिए
b) Object को initialize करने के लिए
c) Method को override करने के लिए
d) Module को import करने के लिए
उत्तर: b
स्पष्टीकरण: init एक constructor method है जो class के object को initialize करने के लिए उपयोग होता है।
31. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
print(x[1:2])
a) [1, 2]
b) [2]
c) [2, 3]
d) Error
उत्तर: b
स्पष्टीकरण: Slicing में [1:2] index 1 से शुरू होकर index 2 से पहले तक (index 1) का element लेता है, जो [2] है।
32. Python में break statement का उपयोग क्या है?
a) Loop को pause करने के लिए
b) Loop को terminate करने के लिए
c) Code को skip करने के लिए
d) Function को call करने के लिए
उत्तर: b
स्पष्टीकरण: break statement loop को तुरंत terminate करता है और control को loop के बाहर ले जाता है।
33. निम्नलिखित कोड का आउटपुट क्या होगा?
x = 10
if x > 5:
print("Big")
else:
print("Small")
a) Big
b) Small
c) Error
d) None
उत्तर: a
स्पष्टीकरण: x = 10, जो 5 से बड़ा है, इसलिए if condition True होती है और "Big" print होता है।
34. Python में range() function का उपयोग क्या है?
a) Random numbers generate करने के लिए
b) Sequence of numbers generate करने के लिए
c) String को reverse करने के लिए
d) List को sort करने के लिए
उत्तर: b
स्पष्टीकरण: range() function एक sequence of numbers generate करता है, जो loops में उपयोग होता है।
35. निम्नलिखित कोड का आउटपुट क्या होगा?
x = { "a": 1, "b": 2 }
print(x["a"])
a) 1
b) 2
c) a
d) Error
उत्तर: a
स्पष्टीकरण: Dictionary में key "a" का value 1 है, इसलिए x["a"] 1 print करता है।
36. Python में isinstance() function का उपयोग क्या है?
a) Object का type check करने के लिए
b) String को convert करने के लिए
c) List को sort करने के लिए
d) File को open करने के लिए
उत्तर: a
स्पष्टीकरण: isinstance() function यह check करता है कि कोई object किसी specific type या class का है या नहीं।
37. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
x.pop()
print(x)
a) [1, 2, 3]
b) [1, 2]
c) [2, 3]
d) Error
उत्तर: b
स्पष्टीकरण: pop() method list के last element को remove करता है। यहाँ 3 remove होने के बाद x = [1, 2] हो जाता है।
38. Python में try-except block का उपयोग क्या है?
a) Code को optimize करने के लिए
b) Exceptions को handle करने के लिए
c) Variables को declare करने के लिए
d) Loops को control करने के लिए
उत्तर: b
स्पष्टीकरण: try-except block का उपयोग errors या exceptions को handle करने के लिए किया जाता है ताकि program crash न हो।
39. निम्नलिखित कोड का आउटपुट क्या होगा?
x = 3.14
print(int(x))
a) 3.14
b) 3
c) 4
d) Error
उत्तर: b
स्पष्टीकरण: int() function floating-point number को integer में convert करता है, जो decimal part को truncate करता है। यहाँ 3.14 का integer 3 है।
40. Python में docstring का उपयोग क्या है?
a) Code को compile करने के लिए
b) Function या class के documentation के लिए
c) Variables को initialize करने के लिए
d) Errors को debug करने के लिए
उत्तर: b
स्पष्टीकरण: Docstring एक string literal है जो function, class, या module के documentation के लिए उपयोग होता है। इसे triple quotes (""" """) में लिखा जाता है।
41. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
y = x.copy()
y[0] = 4
print(x)
a) [4, 2, 3]
b) [1, 2, 3]
c) [1, 4, 3]
d) Error
उत्तर: b
स्पष्टीकरण: copy() method list की shallow copy बनाता है। y में changes x को affect नहीं करते, इसलिए x अपरिवर्तित रहता है।
42. Python में enumerate() function का उपयोग क्या है?
a) List को sort करने के लिए
b) Iterable के elements को index के साथ iterate करने के लिए
c) String को split करने के लिए
d) Dictionary को update करने के लिए
उत्तर: b
स्पष्टीकरण: enumerate() function iterable के elements को उनके index के साथ tuple के रूप में return करता है।
43. निम्नलिखित कोड का आउटपुट क्या होगा?
x = (1, 2, 3)
x[0] = 4
print(x)
a) (4, 2, 3)
b) (1, 2, 3)
c) Error
d) None
उत्तर: c
स्पष्टीकरण: Tuple immutable होता है, इसलिए इसके elements को modify नहीं किया जा सकता। x[0] = 4 से TypeError होगा।
44. Python में pickle module का उपयोग क्या है?
a) Data को serialize और deserialize करने के लिए
b) Random numbers generate करने के लिए
c) Files को read करने के लिए
d) Database को connect करने के लिए
उत्तर: a
स्पष्टीकरण: pickle module Python objects को serialize (byte stream में convert) और deserialize करने के लिए उपयोग होता है।
45. निम्नलिखित कोड का आउटपुट क्या होगा?
x = "Python"
print(len(x))
a) 5
b) 6
c) 7
d) Error
उत्तर: b
स्पष्टीकरण: len() function string की length return करता है। "Python" में 6 characters हैं।
46. Python में // operator का उपयोग क्या है?
a) Modulus
b) Floor division
c) Exponentiation
d) Multiplication
उत्तर: b
स्पष्टीकरण: // operator floor division करता है, जो quotient का integer part return करता है। उदाहरण: 7 // 2 = 3।
47. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
x.insert(1, 4)
print(x)
a) [1, 4, 2, 3]
b) [1, 2, 4, 3]
c) [1, 2, 3, 4]
d) Error
उत्तर: a
स्पष्टीकरण: insert() method list में specified index पर element insert करता है। यहाँ 4 को index 1 पर insert किया गया।
48. Python में pass statement का उपयोग क्या है?
a) Loop को terminate करने के लिए
b) Placeholder के रूप में, जब कोई code नहीं लिखा हो
c) Exception को raise करने के लिए
d) Function को call करने के लिए
उत्तर: b
स्पष्टीकरण: pass statement एक placeholder है जो syntax को valid रखता है जब code block खाली होता है।
49. निम्नलिखित कोड का आउटपुट क्या होगा?
x = 5
y = 2
print(x % y)
a) 2
b) 1
c) 3
d) 0
उत्तर: b
स्पष्टीकरण: % operator modulus operation करता है, जो division का remainder return करता है। यहाँ 5 % 2 = 1।
50. Python में class का उपयोग क्या है?
a) Functions को define करने के लिए
b) Objects और methods को define करने के लिए
c) Modules को import करने के लिए
d) Lists को create करने के लिए
उत्तर: b
स्पष्टीकरण: Class एक blueprint है जो objects और उनके methods/properties को define करता है।
51. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
print(x * 2)
a) [2, 4, 6]
b) [1, 2, 3, 1, 2, 3]
c) [1, 2, 3]
d) Error
उत्तर: b
स्पष्टीकरण: List को * operator से multiply करने पर list repetition होता है। यहाँ x * 2 list को दो बार repeat करता है।
52. Python में yield keyword का उपयोग क्या है?
a) Function को terminate करने के लिए
b) Generator function में values को return करने के लिए
c) Exception को handle करने के लिए
d) Loop को control करने के लिए
उत्तर: b
स्पष्टीकरण: yield keyword generator function में values को एक-एक करके return करता है, बिना function को terminate किए।
53. निम्नलिखित कोड का आउटपुट क्या होगा?
x = {1: "one", 2: "two"}
print(x.get(3, "not found"))
a) one
b) two
c) not found
d) Error
उत्तर: c
स्पष्टीकरण: get() method dictionary में key का value return करता है। यदि key不存在, तो default value ("not found") return होता है।
54. Python में slice() function का उपयोग क्या है?
a) List को sort करने के लिए
b) Iterable का हिस्सा extract करने के लिए
c) String को reverse करने के लिए
d) Dictionary को update करने के लिए
उत्तर: b
स्पष्टीकरण: slice() function iterable (जैसे list, string) का specific हिस्सा extract करने के लिए उपयोग होता है।
55. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
x.remove(2)
print(x)
a) [1, 3]
b) [1, 2]
c) [2, 3]
d) Error
उत्तर: a
स्पष्टीकरण: remove() method list से specified value को हटाता है। यहाँ 2 हटने के बाद x = [1, 3] हो जाता है।
56. Python में map() function का उपयोग क्या है?
a) List को filter करने के लिए
b) Function को iterable के प्रत्येक element पर apply करने के लिए
c) List को sort करने के लिए
d) Dictionary को create करने के लिए
उत्तर: b
स्पष्टीकरण: map() function एक function को iterable के प्रत्येक element पर apply करता है और result को map object के रूप में return करता है।
57. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
print(sum(x))
a) 6
b) 5
c) 3
d) Error
उत्तर: a
स्पष्टीकरण: sum() function list के सभी elements का योग return करता है। यहाँ 1 + 2 + 3 = 6।
58. Python में global keyword का उपयोग क्या है?
a) Variable को local scope में declare करने के लिए
b) Variable को global scope में declare करने के लिए
c) Function को define करने के लिए
d) Loop को terminate करने के लिए
उत्तर: b
स्पष्टीकरण: global keyword function के अंदर global variable को modify करने के लिए उपयोग होता है।
59. निम्नलिखित कोड का आउटपुट क्या होगा?
x = "hello"
print(x[::-1])
a) hello
b) olleh
c) Error
d) None
उत्तर: b
स्पष्टीकरण: Slicing में [::-1] string को reverse करता है। यहाँ "hello" का reverse "olleh" है।
60. Python में filter() function का उपयोग क्या है?
a) Iterable के elements को filter करने के लिए
b) List को sort करने के लिए
c) String को split करने के लिए
d) Dictionary को update करने के लिए
उत्तर: a
स्पष्टीकरण: filter() function एक function को iterable के elements पर apply करता है और True return करने वाले elements को filter object के रूप में return करता है।
61. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
print(x + [4, 5])
a) [1, 2, 3, 4, 5]
b) [4, 5, 1, 2, 3]
c) [1, 2, 3]
d) Error
उत्तर: a
स्पष्टीकरण: + operator lists को concatenate करता है। यहाँ [1, 2, 3] और [4, 5] मिलकर [1, 2, 3, 4, 5] बनाते हैं।
62. Python में id() function का उपयोग क्या है?
a) Object की identity return करने के लिए
b) Object को delete करने के लिए
c) Object को copy करने के लिए
d) Object को sort करने के लिए
उत्तर: a
स्पष्टीकरण: id() function object की unique identity (memory address) return करता है।
63. निम्नलिखित कोड का आउटपुट क्या होगा?
x = 5
print(type(x))
a) <class 'int'>
b) <class 'float'>
c) <class 'str'>
d) Error
उत्तर: a
स्पष्टीकरण: type() function variable का data type return करता है। यहाँ x एक integer है, इसलिए <class 'int'> print होगा।
64. Python में set के elements को access करने के लिए क्या उपयोग होता है?
a) Index
b) Key
c) Loop या membership operator
d) Slice
उत्तर: c
स्पष्टीकरण: Set unordered होता है, इसलिए index या key से elements access नहीं किए जा सकते। Loop या in operator का उपयोग होता है।
65. निम्नलिखित कोड का आउटपुट क्या होगा?
x = "Python"
print(x.find("th"))
a) 2
b) 3
c) 4
d) -1
उत्तर: a
स्पष्टीकरण: find() method substring का first occurrence का index return करता है। यहाँ "th" index 2 पर है।
66. Python में zip() function का उपयोग क्या है?
a) Lists को combine करने के लिए
b) Iterables के elements को pair करने के लिए
c) List को sort करने के लिए
d) Dictionary को create करने के लिए
उत्तर: b
स्पष्टीकरण: zip() function multiple iterables के elements को tuples के रूप में pair करता है।
67. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
x.reverse()
print(x)
a) [1, 2, 3]
b) [3, 2, 1]
c) [2, 1, 3]
d) Error
उत्तर: b
स्पष्टीकरण: reverse() method list को in-place reverse करता है। यहाँ x = [3, 2, 1] हो जाता है।
68. Python में assert statement का उपयोग क्या है?
a) Debugging और testing के लिए
b) Loop को control करने के लिए
c) Function को define करने के लिए
d) Exception को raise करने के लिए
उत्तर: a
स्पष्टीकरण: assert statement conditions को test करने के लिए उपयोग होता है। यदि condition False होती है, तो AssertionError raise होता है।
69. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
print(max(x))
a) 1
b) 2
c) 3
d) Error
उत्तर: c
स्पष्टीकरण: max() function list का maximum element return करता है। यहाँ maximum 3 है।
70. Python में nonlocal keyword का उपयोग क्या है?
a) Global variable को modify करने के लिए
b) Nested function में outer function के variable को modify करने के लिए
c) Loop को terminate करने के लिए
d) Class को define करने के लिए
उत्तर: b
स्पष्टीकरण: nonlocal keyword nested function में outer function के variable को modify करने के लिए उपयोग होता है।
71. निम्नलिखित कोड का आउटपुट क्या होगा?
x = "abc"
print(x * 3)
a) abcabcabc
b) abc
c) Error
d) None
उत्तर: a
स्पष्टीकरण: String को * operator से multiply करने पर string repetition होता है। यहाँ "abc" को 3 बार repeat किया गया।
72. Python में sorted() function का उपयोग क्या है?
a) List को in-place sort करने के लिए
b) Iterable को sorted list के रूप में return करने के लिए
c) String को reverse करने के लिए
d) Dictionary को update करने के लिए
उत्तर: b
स्पष्टीकरण: sorted() function iterable को sorted list के रूप में return करता है, बिना original iterable को modify किए।
73. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
y = [4, 5]
x.extend(y)
print(x)
a) [1, 2, 3, 4, 5]
b) [4, 5, 1, 2, 3]
c) [1, 2, 3]
d) Error
उत्तर: a
स्पष्टीकरण: extend() method list में another list के elements को append करता है। यहाँ x में y के elements जोड़े गए।
74. Python में raise keyword का उपयोग क्या है?
a) Exception को raise करने के लिए
b) Variable को declare करने के लिए
c) Loop को terminate करने के लिए
d) Function को call करने के लिए
उत्तर: a
स्पष्टीकरण: raise keyword custom exceptions को raise करने के लिए उपयोग होता है।
75. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
print(x.index(2))
a) 0
b) 1
c) 2
d) Error
उत्तर: b
स्पष्टीकरण: index() method list में element का first occurrence का index return करता है। यहाँ 2 का index 1 है।
76. Python में any() function का उपयोग क्या है?
a) Iterable में कोई भी element True होने पर True return करता है
b) Iterable के सभी elements True होने पर True return करता है
c) List को sort करता है
d) Dictionary को update करता है
उत्तर: a
स्पष्टीकरण: any() function iterable में कोई भी element True होने पर True return करता है।
77. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
print(len(x))
a) 2
b) 3
c) 4
d) Error
उत्तर: b
स्पष्टीकरण: len() function list की length return करता है। यहाँ x में 3 elements हैं।
78. Python में all() function का उपयोग क्या है?
a) Iterable में कोई भी element True होने पर True return करता है
b) Iterable के सभी elements True होने पर True return करता है
c) List को reverse करता है
d) String को split करता है
उत्तर: b
स्पष्टीकरण: all() function iterable के सभी elements True होने पर True return करता है।
79. निम्नलिखित कोड का आउटपुट क्या होगा?
x = "hello"
print(x.capitalize())
a) Hello
b) HELLO
c) hello
d) Error
उत्तर: a
स्पष्टीकरण: capitalize() method string के पहले character को uppercase और बाकी को lowercase करता है।
80. Python में list और set के बीच अंतर क्या है?
a) List ordered और mutable है, set unordered और mutable है
b) List unordered और immutable है, set ordered और mutable है
c) दोनों ordered और mutable हैं
d) दोनों unordered और immutable हैं
उत्तर: a
स्पष्टीकरण: List ordered और mutable होती है, जबकि set unordered और mutable होता है, लेकिन duplicates को allow नहीं करता।
81. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
x.clear()
print(x)
a) [1, 2, 3]
b) []
c) None
d) Error
उत्तर: b
स्पष्टीकरण: clear() method list के सभी elements को remove करता है, जिससे empty list [] रहता है।
82. Python में comprehension का उपयोग क्या है?
a) Code को debug करने के लिए
b) Lists, sets, या dictionaries को concise तरीके से create करने के लिए
c) Exceptions को handle करने के लिए
d) Files को read करने के लिए
उत्तर: b
स्पष्टीकरण: Comprehension (list, set, dictionary) एक concise syntax है जो data structures को create करने के लिए उपयोग होता है।
83. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
y = x[:]
y[0] = 4
print(x)
a) [4, 2, 3]
b) [1, 2, 3]
c) [1, 4, 3]
d) Error
उत्तर: b
स्पष्टीकरण: Slicing (x[:]) list की shallow copy बनाता है। y में changes x को affect नहीं करते।
84. Python में format() method का उपयोग क्या है?
a) String को format करने के लिए
b) List को sort करने के लिए
c) Dictionary को update करने के लिए
d) File को open करने के लिए
उत्तर: a
स्पष्टीकरण: format() method string में placeholders को values के साथ replace करता है।
85. निम्नलिखित कोड का आउटपुट क्या होगा?
x = 5
print(x > 3 and x < 10)
a) True
b) False
c) Error
d) None
उत्तर: a
स्पष्टीकरण: and operator दोनों conditions True होने पर True return करता है। यहाँ 5 > 3 और 5 < 10 दोनों True हैं।
86. Python में with statement का उपयोग क्या है?
a) Loop को control करने के लिए
b) Context management के लिए, जैसे file handling
c) Function को define करने के लिए
d) Exception को raise करने के लिए
उत्तर: b
स्पष्टीकरण: with statement context management के लिए उपयोग होता है, जैसे file को automatically close करने के लिए।
87. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
print(x.pop(1))
a) 1
b) 2
c) 3
d) Error
उत्तर: b
स्पष्टीकरण: pop(1) index 1 के element (2) को remove करता है और उसे return करता है।
88. Python में is operator का उपयोग क्या है?
a) Values को compare करने के लिए
b) Object identity को compare करने के लिए
c) Strings को concatenate करने के लिए
d) Lists को merge करने के लिए
उत्तर: b
स्पष्टीकरण: is operator objects की identity (memory address) को compare करता है।
89. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
print(2 in x)
a) True
b) False
c) Error
d) None
उत्तर: a
स्पष्टीकरण: in operator यह check करता है कि element list में मौजूद है या नहीं। यहाँ 2 list में है, इसलिए True return होता है।
90. Python में eval() function का उपयोग क्या है?
a) String को Python code के रूप में execute करने के लिए
b) List को sort करने के लिए
c) Dictionary को update करने के लिए
d) File को read करने के लिए
उत्तर: a
स्पष्टीकरण: eval() function string को Python expression के रूप में evaluate और execute करता है।
91. निम्नलिखित कोड का आउटपुट क्या होगा?
x = "123"
print(int(x))
a) 123
b) "123"
c) Error
d) None
उत्तर: a
स्पष्टीकरण: int() function string को integer में convert करता है, यदि string valid number हो। यहाँ "123" को 123 में convert किया गया।
92. Python में deepcopy और shallow copy में क्या अंतर है?
a) Shallow copy nested objects को copy करता है, deepcopy नहीं
b) Deepcopy nested objects को recursively copy करता है, shallow copy नहीं
c) दोनों एक समान हैं
d) Shallow copy faster है, deepcopy slower
उत्तर: b
स्पष्टीकरण: Shallow copy top-level elements को copy करता है, लेकिन nested objects को reference करता है। Deepcopy nested objects को recursively copy करता है।
93. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
print(x[0:2])
a) [1, 2]
b) [2, 3]
c) [1, 2, 3]
d) Error
उत्तर: a
स्पष्टीकरण: Slicing [0:2] index 0 से 1 तक के elements लेता है, जो [1, 2] है।
94. Python में numpy का उपयोग क्या है?
a) GUI applications बनाने के लिए
b) Numerical computations के लिए
c) Database management के लिए
d) File handling के लिए
उत्तर: b
स्पष्टीकरण: NumPy एक library है जो numerical computations और array operations के लिए उपयोग होती है।
95. निम्नलिखित कोड का आउटपुट क्या होगा?
x = {1, 2, 3}
x.add(4)
print(x)
a) {1, 2, 3, 4}
b) {1, 2, 3}
c) {4, 1, 2, 3}
d) Error
उत्तर: a
स्पष्टीकरण: add() method set में element जोड़ता है। यहाँ 4 जोड़ा गया, और set {1, 2, 3, 4} हो गया।
96. Python में pandas का उपयोग क्या है?
a) Data analysis और manipulation के लिए
b) GUI applications बनाने के लिए
c) Web development के लिए
d) File compression के लिए
उत्तर: a
स्पष्टीकरण: Pandas एक library है जो data analysis और manipulation के लिए उपयोग होती है, जैसे DataFrames और Series।
97. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
x.append([4, 5])
print(x)
a) [1, 2, 3, 4, 5]
b) [1, 2, 3, [4, 5]]
c) [4, 5, 1, 2, 3]
d) Error
उत्तर: b
स्पष्टीकरण: append() method list में single element के रूप में [4, 5] को जोड़ता है, न कि individual elements को।
98. Python में recursion का उपयोग क्या है?
a) Function को repeatedly call करने के लिए
b) Function को एक बार call करने के लिए
c) Loop को replace करने के लिए
d) Exception को handle करने के लिए
उत्तर: a
स्पष्टीकरण: Recursion में function खुद को repeatedly call करता है ताकि problem को smaller subproblems में solve किया जा सके।
99. निम्नलिखित कोड का आउटपुट क्या होगा?
x = "hello"
print(x.replace("h", "j"))
a) jello
b) hello
c) Error
d) None
उत्तर: a
स्पष्टीकरण: replace() method string में specified substring को replace करता है। यहाँ "h" को "j" से replace किया गया।
100. Python में virtual environment का उपयोग क्या है?
a) Code को optimize करने के लिए
b) Isolated Python environment बनाने के लिए
c) Database को manage करने के लिए
d) GUI applications बनाने के लिए
उत्तर: b
स्पष्टीकरण: Virtual environment isolated Python environment बनाता है, जो dependencies को manage करने में मदद करता है।
101. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
print(x.count(2))
a) 1
b) 2
c) 3
d) Error
उत्तर: a
स्पष्टीकरण: count() method list में specified element की occurrences की संख्या return करता है। यहाँ 2 एक बार है।
102. Python में name variable का उपयोग क्या है?
a) Module का नाम store करने के लिए
b) Function को define करने के लिए
c) Exception को handle करने के लिए
d) Loop को control करने के लिए
उत्तर: a
स्पष्टीकरण: name variable यह indicate करता है कि module directly run किया जा रहा है ("main") या import किया गया है।
103. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
print(x.pop(0))
a) 1
b) 2
c) 3
d) Error
उत्तर: a
स्पष्टीकरण: pop(0) index 0 के element (1) को remove करता है और उसे return करता है।
104. Python में del statement का उपयोग क्या है?
a) Variable या object को delete करने के लिए
b) Loop को terminate करने के लिए
c) Function को call करने के लिए
d) Exception को raise करने के लिए
उत्तर: a
स्पष्टीकरण: del statement variable, list element, या object को memory से delete करता है।
105. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
y = [x]
x[0] = 4
print(y)
a) [[1, 2, 3]]
b) [[4, 2, 3]]
c) [1, 2, 3]
d) Error
उत्तर: b
स्पष्टीकरण: y में x का reference है। x में changes y को affect करते हैं, क्योंकि list mutable है।
106. Python में isinstance() और type() में क्या अंतर है?
a) isinstance() object का type check करता है, type() object का type return करता है
b) दोनों एक समान हैं
c) isinstance() list को sort करता है, type() list को reverse करता है
d) isinstance() exception को handle करता है, type() exception को raise करता है
उत्तर: a
स्पष्टीकरण: isinstance() यह check करता है कि object किसी type का है या नहीं, जबकि type() object का type return करता है।
107. निम्नलिखित कोड का आउटपुट क्या होगा?
x = "hello"
print(x.islower())
a) True
b) False
c) Error
d) None
उत्तर: a
स्पष्टीकरण: islower() method यह check करता है कि string के सभी characters lowercase हैं या नहीं। यहाँ "hello" lowercase है।
108. Python में generator का उपयोग क्या है?
a) Memory-efficient iteration के लिए
b) Code को optimize करने के लिए
c) File handling के लिए
d) GUI applications बनाने के लिए
उत्तर: a
स्पष्टीकरण: Generator memory-efficient iteration प्रदान करता है, क्योंकि यह values को one-by-one generate करता है।
109. निम्नलिखित कोड का आउटपुट क्या होगा?
x = [1, 2, 3]
print(x + [4])
a) [1, 2, 3, 4]
b) [4, 1, 2, 3]
c) [1, 2, 3]
d) Error
उत्तर: a
स्पष्टीकरण: + operator lists को concatenate करता है। यहाँ [1, 2, 3] और [4] मिलकर [1, 2, 3, 4] बनाते हैं।
110. Python में module का उपयोग क्या है?
a) Code को organize और reuse करने के लिए
b) GUI applications बनाने के लिए
c) Database को manage करने के लिए
d) Hardware को control करने के लिए
उत्तर: a
स्पष्टीकरण: Module code को organize और reuse करने के लिए उपयोग होता है। यह functions, classes, और variables को contain करता है।
Post a Comment
Thank You...