पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 12 के उत्तर और हल FliQi Question Bank app में।
भाषा
प्रश्न 1उत्तर + हल
Python programming में pass एक null statement है।
In Python programming, pass is a null statement.
AहाँYes
BनहींNo
Cकह नहीं सकतेCan't say
Dइनमें से कोई नहींNone of these
सही उत्तर / Answer: (A)
हल / Solution
pass Python का एक keyword है। यह चलने पर कुछ भी नहीं करता, इसलिए इसे null statement कहते हैं। Python में if, for, def या class के बाद कम से कम एक statement लिखना ज़रूरी है। जब वहाँ अभी कोई काम नहीं लिखना हो, तब pass रख देते हैं, जैसे def f(): pass। block ख़ाली छोड़ने पर IndentationError आता है। इसलिए कथन सही है और उत्तर 'हाँ' है।
pass is a Python keyword. When it runs it does nothing at all, so it is called a null statement. Python needs at least one statement after if, for, def or class. When you have nothing to write there yet, you put pass, for example def f(): pass. Leaving the block empty gives an IndentationError. So the statement is true and the answer is 'Yes'. The other options do not fit.
प्रश्न 2उत्तर + हल
Python में आरक्षित keyword (reserved keyword) चुनिए।
Select the reserved keyword in Python.
Aimport
Braise
Celse
Dउपरोक्त सभीAll of the above
सही उत्तर / Answer: (D)
हल / Solution
Reserved keyword वे शब्द हैं जिनका Python में पहले से तय अर्थ है। इन्हें variable या function के नाम की तरह इस्तेमाल नहीं कर सकते। import किसी module को program में लाता है। raise जान-बूझकर exception खड़ा करता है। else तब चलता है जब if की शर्त झूठी हो। तीनों keyword.kwlist की सूची में मौजूद हैं। इसलिए कोई एक विकल्प अकेला पूरा उत्तर नहीं है, सही उत्तर 'उपरोक्त सभी' है।
Reserved keywords are words that already have a fixed meaning in Python. You cannot use them as names of variables or functions. import brings a module into the program. raise throws an exception on purpose. else runs when the if condition is false. All three appear in keyword.kwlist. So no single option is the full answer, and the correct choice is 'All of the above'. Writing import = 5 gives a SyntaxError.
प्रश्न 3उत्तर + हल
निम्नलिखित में से कौन-सा keyword class definition की शुरुआत बताता है?
Which of the following keywords marks the beginning of a class definition?
Adef
Bclass
Creturn
Dउपरोक्त सभीAll of the above
सही उत्तर / Answer: (B)
हल / Solution
Python में नई class बनाने के लिए class keyword लिखा जाता है, जैसे class Student: और उसके बाद indent किया हुआ block। यही keyword बताता है कि यहाँ से class definition शुरू हो रही है। def keyword function बनाने के लिए होता है, class के लिए नहीं। return function के अंदर से कोई value वापस भेजता है। तीनों का काम अलग है, इसलिए 'उपरोक्त सभी' भी ग़लत है। सही उत्तर class है।
In Python a new class is created with the class keyword, for example class Student: followed by an indented block. This keyword tells Python that a class definition starts here. The def keyword is used to define a function, not a class. The return keyword sends a value back from inside a function. All three do different jobs, so 'All of the above' is also wrong. The correct answer is class.
प्रश्न 4उत्तर + हल
निम्नलिखित में से कौन-सा फ़ंक्शन सभी मिलानों (matches) की सूची लौटाता है?
Which of the following functions returns a list containing all matches?
Afind
Bfindall
Cget
Dcount
सही उत्तर / Answer: (B)
हल / Solution
पायथन के re मॉड्यूल में findall() फ़ंक्शन किसी pattern के सभी मिलान खोजकर उन्हें एक list में लौटाता है। जैसे re.findall('a', 'banana') का नतीजा ['a', 'a', 'a'] है। string का find() method सिर्फ़ पहले मिलान का index देता है, और न मिलने पर -1 देता है। count() सिर्फ़ गिनती देता है कि मिलान कितनी बार आया। get() dictionary से किसी key का मान लाता है। इसलिए सही उत्तर findall है।
In Python's re module, findall() finds every match of a pattern and returns them in a list. For example, re.findall('a', 'banana') gives ['a', 'a', 'a']. The string method find() returns only the index of the first match, or -1 if nothing is found. count() only tells how many times the match occurs. get() fetches the value of a key from a dictionary. So the function that returns a list of all matches is findall.
प्रश्न 5उत्तर + हल
निम्नलिखित में से कौन-सा ब्लॉक कोड के किसी हिस्से को त्रुटियों (errors) के लिए परखने देता है?
Which of the following blocks allows you to test a block of code for errors?
Aexcept block
Btry block
Cfinally block
Dइनमें से कोई नहींNone of these
सही उत्तर / Answer: (B)
हल / Solution
पायथन में try ब्लॉक के अंदर वह कोड रखा जाता है जिसे त्रुटि के लिए परखना हो। अगर वहाँ कोई एक्सेप्शन आता है, तो प्रोग्राम बंद होने के बजाय नियंत्रण except ब्लॉक पर चला जाता है। except ब्लॉक त्रुटि को संभालता है, परखता नहीं। finally ब्लॉक हर हाल में चलता है और सफ़ाई का काम करता है, जैसे फ़ाइल बंद करना। इसलिए कोड को परखने का काम try ब्लॉक करता है।
In Python, the code you want to test for errors goes inside a try block. If an exception occurs there, control moves to the except block instead of the program crashing. The except block handles the error; it does not test the code. The finally block always runs and is used for clean-up, such as closing a file. So the block that lets you test code for errors is the try block.
प्रश्न 6उत्तर + हल
निम्नलिखित में से कौन-सा पायथन का आरक्षित कीवर्ड (reserved keyword) नहीं है?
Which of the following is not a reserved keyword in Python?
Aclass
Bgoto
Cand
DNone
सही उत्तर / Answer: (B)
हल / Solution
आरक्षित कीवर्ड वे शब्द हैं जिनका पायथन में पहले से तय अर्थ है। class कीवर्ड नई क्लास बनाता है। and एक तार्किक ऑपरेटर है, जो दोनों शर्तें सही होने पर True देता है। None भी कीवर्ड है, जो 'कोई मान नहीं' बताता है। ध्यान दीजिए कि None बड़े N से लिखा जाता है। goto C जैसी भाषाओं में मिलता है, पर पायथन में goto नाम का कोई कीवर्ड नहीं है। इसलिए सही उत्तर goto है।
Reserved keywords are words with a fixed meaning in Python. class creates a new class. and is a logical operator that gives True only when both conditions are true. None is also a keyword; it means no value, and it is written with a capital N. goto exists in languages like C, but Python has no goto keyword at all. So among the given words, goto is the one that is not a reserved keyword.
प्रश्न 7उत्तर + हल
नीचे दिए फ़ंक्शन को देखिए: all([2,4,0,6]) इस फ़ंक्शन का आउटपुट क्या होगा?
Study the following function: all([2,4,0,6]) What will be the output of this function?
AFalse
BTrue
Cerror
Dअमान्य कोडInvalid code
सही उत्तर / Answer: (A)
हल / Solution
all() फ़ंक्शन तभी True देता है जब दिए गए iterable का हर मान सत्य (truthy) हो। अगर एक भी मान असत्य (falsy) हो, तो नतीजा False आता है। पायथन में 0 को falsy माना जाता है। सूची [2, 4, 0, 6] में 0 मौजूद है, इसलिए all() का नतीजा False है। 0 के बिना, जैसे [2, 4, 6], नतीजा True आता। यह कोड पूरी तरह सही है, इसलिए error या अमान्य कोड वाले विकल्प भी गलत हैं।
The all() function returns True only when every item in the iterable is truthy. If even one item is falsy, it returns False. In Python, 0 is treated as falsy. The list [2, 4, 0, 6] contains 0, so all() returns False. Without the 0, as in [2, 4, 6], the result would be True. The code itself is perfectly valid, so the error and invalid code options are wrong too.
प्रश्न 8उत्तर + हल
निम्नलिखित फ़ंक्शन का मान किसके बराबर निकाला जाता है? pow(x,y,z)
Which of the following is correctly evaluated for this function? pow(x,y,z)
A(x**y) / z
B(x / y) * z
C(x**y) % z
D(x / y) / z
सही उत्तर / Answer: (C)
हल / Solution
पायथन में pow() तीन आर्ग्युमेंट भी ले सकता है। pow(x, y, z) का मतलब है पहले x की घात y निकालना, फिर z से भाग देकर शेषफल लेना, यानी (x**y) % z। जैसे pow(2, 5, 3) में 2**5 = 32 और 32 % 3 = 2, इसलिए उत्तर 2 आता है। पायथन इसे तेज़ तरीके से निकालता है, बड़ी संख्या बनाए बिना। बाक़ी विकल्पों में / (भाग) या * (गुणा) है, जो pow() नहीं करता।
Python's pow() can take three arguments. pow(x, y, z) means raise x to the power y, then take the remainder after dividing by z, that is (x**y) % z. For example, pow(2, 5, 3): 2**5 is 32, and 32 % 3 is 2, so the result is 2. Python computes this efficiently without building a huge number. The other options use division or multiplication, which pow() does not do.
प्रश्न 9उत्तर + हल
नीचे दिए फ़ंक्शन को देखिए: round(4.576) इस फ़ंक्शन का आउटपुट क्या होगा?
Study the following function: round(4.576) What will be the output of this function?
A4
B3
C576
D5
सही उत्तर / Answer: (D)
हल / Solution
round() फ़ंक्शन को दूसरा आर्ग्युमेंट न दिया जाए, तो वह संख्या को निकटतम पूर्णांक में बदल देता है। 4.576 का दशमलव भाग 0.576 है, जो 0.5 से बड़ा है। इसलिए संख्या ऊपर की ओर 5 हो जाती है। 4 तब आता जब दशमलव भाग 0.5 से छोटा होता। 3 का यहाँ कोई आधार नहीं है। 576 सिर्फ़ दशमलव के बाद के अंक हैं, round() उन्हें अलग नहीं करता। इसलिए आउटपुट 5 है।
When no second argument is given, round() rounds a number to the nearest integer. In 4.576, the decimal part is 0.576, which is more than 0.5. So the number goes up to 5. The answer 4 would come only if the decimal part were below 0.5. The value 3 has no basis here. 576 is just the digits after the decimal point, and round() does not pull those out. So the output is 5.
प्रश्न 10उत्तर + हल
निम्नलिखित में से कौन-सा फ़ंक्शन पायथन भाषा का बिल्ट-इन (built-in) फ़ंक्शन है?
Which of the following functions is a built-in function in Python?
Aprintf()
Bprint()
Cval()
Dइनमें से कोई नहींNone of these
सही उत्तर / Answer: (B)
हल / Solution
बिल्ट-इन फ़ंक्शन वे हैं जो पायथन में पहले से मौजूद हैं। इन्हें लगाने के लिए कुछ import नहीं करना पड़ता। print() ऐसा ही फ़ंक्शन है, जो स्क्रीन पर आउटपुट दिखाता है, जैसे print('Hello')। printf() C भाषा का फ़ंक्शन है, पायथन का नहीं। val() भी पायथन में नहीं है, यह Visual Basic जैसी भाषाओं में मिलता है। print() बिल्ट-इन है, इसलिए 'इनमें से कोई नहीं' गलत है। सही उत्तर print() है।
Built-in functions are always available in Python without any import. print() is one of them; it shows output on the screen, as in print('Hello'). printf() belongs to the C language, not Python. val() does not exist in Python either; it is found in languages like Visual Basic. Since print() is a real built-in function, 'None of these' is wrong. So the correct answer is print().
आगे के 12 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति