0% found this document useful (0 votes)
75 views18 pages

MCQ On Python 5eea6a1139140f30f369ebae

Uploaded by

Sharlin Regina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
75 views18 pages

MCQ On Python 5eea6a1139140f30f369ebae

Uploaded by

Sharlin Regina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 18
De Brac) Python Questions Latest Python MCQ Objective Questions CER ABR he lial RI a eon Start Complete Exam Preparation jon Bank Dally Live rey boca Cie a Download App Question 1: View this Question Online > What are Python files containing Python definitions and statementscalled? 1. Flowcharts 2. Algorithms 3. Modules 4, Sequences Answer (Detailed Solution Below) ’ : Modules coaching India's Super Teachers for all ef Ay AO Tel Oln moles or Python Question 1 Detailed Solution Python files containing Python definitions and statements are called modules. So the answer is (3). i Key Points — + A module isa file that contair Pa ‘ode, suchas functions, classesand variables. Modules canbe imported into othe Pykon files, which allows you to reuse code and organize your code into smaller, more 1 files. + Modules are typically named with a .py extension. For example, a module named my_module.py would contain Python code that can be imported into other Python files using the following statement: 2 import my_module * Once you have imported a module, you can accessthe code in that module using the module's name. For example, if you have a function called greet() in the my_module.py module, you can call that function fram another Python file using the following statement my_module.greet() + Modules are a powerful feature of Python that allow you to write more organized and reusable code. & Additional Information + Flowchartsare visual representations of algorithms. + Algorithms are step-by-step instructions for solving a problem. + Sequencesare ordered lists of elements. wr eae Rare) Rey Scam Ce Cima elo) Pus oes Pac as Cold Question Bank Exit ey id D> Download App Question 2: \* View this Question Online > co find the output of the program ot = Oo eee ye pl atl 1.123456 ny . 12345678 . 123456789 4. none of these a . None of the above/More than one of the above Answer (Detailed Solution Below) 0° Option 2:12345678 nN Python Question 2 Detailed XS Correct answeris option B + program start from 1 + checkcondition ifa% 9== * then run and print all the value of a till a=8 + when a=9 then condition is false + then program Break + Sothe answeris1 2345678 ee ee a Meet Boel OR DR Re eras Start Complete Exam Preparation ca Pear feed ies ca Vessel Cres eau peer Download App Question 3: View this Question Online > What is the output of following code: print (type(type(int))) 1. type ‘int 3. error 5. None of the above/More than one of the above Answer (Detailed Solution Below) Option 2: Python Question 3 Detailed Solution Concept: Type function type() : It either returns the type of the object or returns anew type object based on the argument passedto it. Explanation: If we passsingle object to type(), then it returns its type. Here code is given as: Print type(typeqing)) It returns the classof the argument to which object belongs. So, it return type Pees a errr) Sey Start Complete Exam Preparation Penne eae area Gite Pecoraro Question 4: View this Question Online > What is output of the code in Python Language: >>> str1= All the Best’ >> striL3] 4.7% 5. None of the above/More than one of the above Answer (Detailed Solution Below) Option 2:'e Python Question 4 Detailed Solution © Key Points. Here str is an array of continuous elements, str1[0]=A=str1L0] stri[i}=l=str1 11] str1[2]=l=str1[-10] str1[3]=" ‘=str1£9] str1[4]=t=str 8) str1[5]=h=str1L7] str1[6]=e=str1[-6] stri[7I=' '=str1L-5] str1[8]=B=st1[-4] a str1[9]=e=str1[-3] 0 -3 -2 -1 Aj ljl t{hje Ble|s}t Ow 2s es 67 8 9 10.71 str1 Hence the correct answer is ©: India's #1 Learning Platform Cees Start Complete Exam Preparation Bk: Gece ean Corres a Ga cree Question 5: View this Question Online > What will be the output of the following command in python? a= "python" whilei in a: a= afl] print(i, end = "P)| =" » A 2. python 3. pppppp 4, More than one of the above 5. None of the above Answer (Detailed Solution Below) Option 3:pppppp Python Question 5 Detailed Solution ’ In python language, +1 Iscalled list indexing or 1 3 It returns the whole messageasit Is but without the last element. You can alwayschange the number to -2 of -3 according to the requirement. Hence the answer willbe ppp ppp. In every loop one letter will be eliminated from the string and p will be printed with" * string in the end. Note:- For better understanding try to run the above program. Top Python MCQ Objective Questions shane acta Trusted by 1,86,00,449+ Student: Start Complete Exam Preparation eae pan Pala te Csr Gd Download App Question 6: View this Question, @nline™> “eg is NOT’ feature of Python language? -Ipterpreted language 2. Portable High level language 4, Caseinsensitive Answer (Detailed Solution Below) Option 4: Caselnsensitive Python Question 6 Detailed Solution © Key Points. Python is a dynamic, high-level, free open source, and interpreted programming language. It supports object-oriented programming aswell as procedurel- oriented programming. Feature of Python language + Easyto code + Free and Open Source a + Object-Oriented Languaae + GUI Programming Support. + High-Level Language Extensible feature Python isa Portablelanguage + Python isan integrated language + Interpreted Language Large Standard Library Dynamically Typed Language It case-sensitive programming language. Hence the correct answer is Caseinsensitive ee ae Rec tiy Pela (CM Cm e le Laced) CR Soc eo au ales Cel (ee Download App Question 7: View this Question Online > What does this program print? days= "Mon, Tue, Wed, Thu, Fri, Sat, Sun" print(daysf::5]) 1. Mon Tue Wea ThUFTi Sat Sun »N 3. MTWTFSS. 47 Answer (Detailed Solution Below) Option 3: MTWTFSS. Python Question 7 Detalled Solution Concept: Slicing: It is used to slicea particular sequence. We can specifywhereiit’startsand where it will end, how many characterscan be skipped. Explanation: FS ee days = “Mon, Tue, Wed, 7 print(daysf::5]) Output: In this, slice startsat the first character and includes every fifth character whichis : MIWTFSS Italso count spaceasa character. Important Point: “Mon, Tue” in this 4*” characteris space eee sen etl Reena rote Start Complete Exam Preparation emer ee ities Doeciapry jownload App Question 8: View this Question Online > The command used to start Python from the command prompt is. . execute python 3. py 4. Both 2 and 3 are correct Answer (Detailed Solution Below) Option 4: Both 2 and 3 are correct Python Question 8 Detailed Solution To execute python from the command prompt, ‘python’ andpy) commandsis entered. The Correct Answer is Both py and python a : ees Re Reto Start Complete Exam Preparation iPS cero B Download App Question 9: What isthe output of the below program in python: print(0.2+ 0.4== 0.6) 1 —™ 2. False 3. Error 4, Depends on machine Answer (Detailed Solut' Option 2: False CR RR eres a ee eo ae ee NC TT Ie eT REET 0.2, 0.4 and 0.6 can not be represented accurately in binery. The round off errors from m 0.4 addsup Hence there is a difference between (0.2 + 0.4)and 0.6. Thisis becauseyou can not compare floating point value, asit cannot be considered precise. Note: Ifyou run above program then we will get the output false. India’s #1 Learning Platform Start Complete Exam Preparation Cal] a (z) red { Daa es Col a Ge Sa Exeter) Download App Question 10: View this Question Online > What will be output of the following command in python? print (r"\nhello’) 1 > \ 2. new line and hello 3. \nhello 4. Error Answer (Detailed Solution Below) Option 3: \nhello Python Question 10 Detailed Solution RoC cote In python language, ~ when'r’ or 'R’ is used before the string, it converts the string into a raw string and the escape sequence like \n are not converted. Hence the answeris \nhello. GEER ABR Ret liial Start Complete Exam Preparation BCC DAR Seco Poscoeery Gree nee be Question Bank Exotica) Download App Question 11: View this Question Online > What will be the result of the below command in python language: round(0.4) - round(-0.5) Answer (Detailed Solution Below) Option 1:0 Python Question 11 Detailed Solution In python language, the svstemrounds off the number away from 0 when the number which has to be rounded offis. halfway through. This means, round(0.4) = 0 and round(-0 This gives, 0-(-0) = 0 x NOTE: It does not depend on the negative value.The round function is used to round the value.r Eg: round(0 to 0.5)gives as 0. round(-0.6 to -0.9) gives 2-1. Hence the answer is 0. eRe anon ete Renae Pott Start Complete Exam Pr lees Phd aca laa ‘Question Bank Exotic) Jownload App Question 12: View this Question Online > What is the output of the code in Python Language: for num in range (3): ifnum > 0 print (num*100) 1 7~ 2. 100, 100, 100 3. 100,200 4. 300,200 Answer (Detailed Solution Below) Option 3: 100, 200 Python Question 12 Detailed Solution © Key Points Python range() Basics : In simple terms, range() allows the user to generate a series of numbers within a given range. for num in range (3): ifnum > 0: ~a print (num*100) Here num has initially 0 and it prints num = 100 gives 0 as output and next iteration num is 1 and prints 100. After num has2 and prints 200. And finally range become closes. Hence the correct answer is 100,200. Note: for better understandingrun the above program. ee eae) SP POPOL Ea Pea mC Me Cima erLe Laced) alee eas Des ciolen resieicoug Download App Question 13: View this Question Online > Which of following is keyword used in python? 4. finally 2, lambda 3 Pm 4, Allof above Answer (Detailed Solution Below) Option 4: All of above Python Question 13 Detailed Solution The correct answeris option 4. Concept: In Python, reserved words are referred to as keywords. A Keyword cannot be used asa variable name, function name, or other identifiers. Here's a list of all keywords in Python Programming: False, await, else, import, ik break, except, in, raise, True, class finally, is, return, and, continue, for, lambda, try. as, ‘om, nonlocal, while, assert.del, global, not, with, asyne elf, if, or, yield. The keywords listed above may change between Python versions. Some extras may be added, while others may be deleted. You may alwaysretrieve alist of keywords in your current version by entering the following command at the prompt. Syntax: >>> import keyword >>> print(keyword.kwlist) Hence the correct answer is All of above. India's #1 Learning Platform Cacia cotta Start Complete Exam Preparation ieee kes iw foster Ext z ra) Download App resieacg Question 14: View this Question Online > What isthe maximum length of a Python identifier? 1. 33 2. 28 4. No fixed length specified Answer (Detailed Solution Below) Option 4: No fixed length specified Python Question 14 Detailed Solution The correct answeris option 4. Concept: Python Identifiers are namesassignedto things suchas classesfunctions, variables, and soon. It helps in distinguishing one entity from another. Rules for writing identifiers: + An identifier canbe of any length, + Identifiers can be a mix of lowercase(@-z)or capital (A-Z) characters,numerals (0-9), or underscore(_). Namesiiféiifmy Class, var_1 and print_this_to_screen, all are valid exemple. + A digit cannot be the firstehayacter of an identifier. Variable is an acceptablename, but variable is not. + Keywords cannot be used asidentifiers. + In our identifier, we cannot use special characterssuch as |, @, #, $, percent, and so on. Explanation: In python an Identifier there is no fixed length so the identifier canbe of any lenath. Hence the correct answer is No fixed/ength specified. og x rN India’s #1 Learning Platform Ree ar kot ASE Ta meni) (CM Clune) ia ) Dally Live eed Pea Reston resieuccg Exeter Download App Question 15: View this Question Online > What will be the output of the following command in python? a= "python" isp while i in a: 2. python 3. PPPPpp 4. None of the above Answer (Detailed Solution Below) co ¢ Option 3: pp pppp a ae Python Question 15 Detailed Solution XO In python language, eo +1 iscalled list indexing or ef the whole messageasit is but without the last element. You can alwayschange the number to -2 of -3 according to the requirement. Hence the answer willbe p PP PP P- In every loop one letter will be eliminated from the string and p will be printed with" " string in the end Note:- For better understanding try to run the above program.

You might also like