Following quiz provides Multiple Choice Questions (MCQs) related to Python. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - What is the output for −
'you are doing well' [2:999]
Slicing will never give us an error even if we give it too large of an index for the string. It will just return the widest matching slice it can.
Q 2 - Name the python module which supports regular expressions.
re is the module which supports regular expressions and is part of standard library.
We can import re module as − import re.
Q 3 - Syntax error in python is detected by _________at _______
Syntax error in python is detected by interpreter at run time.
2**3 gives 2*2*2 i.e. 8, then 2*8 gives 16, since order of precedence is ** then*. ** implies ‘‘ raise to power’’.
Q 5 - What is output of following −
It Counts the number of times the substring ‘abb’ is present starting from position 2 and ending at position 11 in the given string.
Q 6 - What is the output of the following code?
s = ''\t\t\t\n\nTutorialsPoint\n\n\n\t\t\t'' s.strip()
Strip method is used to remove all the newline and tab spaces code in the string.
Q 7 - Analyze the code −
print(''Recursive Function'') def factorial(n): return(n*factorial(n-1)) factorial(4)
there is no condition in the code to stop the function.
Q 8 - Which code is used to open a file for binary writing?
‘b’ format is used to work on the binary format of file.
Q 9 - Select the valid code to bind a canvas with a key event p −
Q 10 - How you can lift the pen of in turtle?