Question 1 of 25
Hints left: 3
Q1
What will be the output of the following Python code? class father: def __init__(self, param): self.o1 = param class child(father): def __init__(self, param): self.o2 = param >>>obj = child(22) >>>print "%d %d" % (obj.o1, obj.o2)
Q2
Suppose s is “\t\tWorld\n”, what is s.strip()?
Q3
What will be the output of the following Python code? >>>print (r"\nhello")
Q4
What will be the output of the following Python code? print("abcdef".find("cd"))
Q5
What will be the output of the following Python code snippet? print('ab cd ef'.title())
Q6
What will be the output of the following Python code? print("Hello {name1} and {name2}".format(name1='foo', name2='bin'))
Q7
What will be the output of the following Python code? print('abcd'.partition('cd'))
Q8
To retrieve the character at index 3 from string s="Hello" what command do we execute (multiple answers allowed)?
Q9
Given a string example="hello" what is the output of example.count('l')?
Q10
What will be the output of the following Python code? print("ab\tcd\tef".expandtabs(4))
Q11
What will be the output of the following Python code snippet? print('ab cd-ef'.title())
Q12
What will be the output of the following Python code? print("xyyzxyzxzxyy".count('yy', 1))
Q13
What will be the output of the following Python code snippet? print('abcefd'.replace('cd', '12'))
Q14
What will be the output of the following Python code? print("Hello {0!r} and {0!s}".format('foo', 'bin'))
Q15
What will be the output of the following Python code snippet? print('abcdefcdghcd'.split('cd', -1))
-
A
-
B
-
C
-
D
Q16
What will be the output of the following Python code snippet? print(''''''.isspace())
Q17
What will be the output of the following Python code? class Count: def __init__(self, count = 0): self.__count = count c1 = Count(2) c2 = Count(2) print(id(c1) == id(c2), end = " ") s1 = "Good" s2 = "Good" print(id(s1) == id(s2))
Q18
What will be the output of the following Python code? >>>example = "helle" >>>example.rfind("e")
Q19
What is "Hello".replace("l", "e")?
Q20
What will be the output of the following Python code? >>>str1="helloworld" >>>str1[::-1]
Q21
What will be the output of the following Python statement? >>> print('x\97\x98')
Q22
What will be the output of the following Python statement? >>>"a"+"bc"
Q23
What will be the output of the following Python code snippet? print('The sum of {0:b} and {1:x} is {2:o}'.format(2, 10, 12))
Q24
What will be the output of the following Python code snippet? print('Hello World'.istitle())
Q25
What will be the output of the following Python code snippet? print('abcd'.translate({97: 98, 98: 99, 99: 100}))