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 - What is output of following code −
num=3 while True: if (num%0o12 == 0): break print(num) num += 1
we are getting output 3 to 9 because 0o12 is octal number.
Q 3 - When the given code is executed how many times ' 'you are learning python ' ' will be printed.
a = 0 while a<10: … print(''you are learning python'') … pass
The loop will execute infinite number of times because there is no statement specified for end of loop and pass indicates nothing is to be done.
Q 4 - What is output for − min(''hello world'')
python considers a blank space character as minimum value in a string.
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 happens in the below code?
class A: def __init__(self, i=100): self.i=i class B(A): def __init__(self,j=0): self.j=j def main(): b= B() print(b.i) print(b.j) main()
Reason being that i is initiated with self thus making it a instantiate variable of that class which cannot be inherited by the above way.
Q 8 - Which method is used to convert raw byte data to a string?
Decode is the method used to convert the raw byte data to a string.
Q 9 - Which way among them is used to create an event loop ?
Q 10 - What is the value of a, b, c in the given below code?
a, b = c = 2 + 2, ''TutorialsPoint''
b= 4, 'TutorialsPoint'
c= 4, 'TutorialsPoint'