11. What will be the output of the following Python code?
>>>example = "helle"
>>>example.rfind("e")
>>>example = "helle"
>>>example.rfind("e")
12. What will be the output of the following Python code snippet?
print('abcefd'.replace('cd', '12'))
print('abcefd'.replace('cd', '12'))
13. What will be the output of the following Python code?
print("abcdef".find("cd"))
print("abcdef".find("cd"))
14. What will be the output of the following Python code?
>>>print (r"\nhello")
>>>print (r"\nhello")
15. Suppose s is “\t\tWorld\n”, what is s.strip()?
16. 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)
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)
17. 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))
print('The sum of {0:b} and {1:x} is {2:o}'.format(2, 10, 12))
18. What will be the output of the following Python code?
print("xyyzxyzxzxyy".count('yy', 1))
print("xyyzxyzxzxyy".count('yy', 1))
19. What will be the output of the following Python code snippet?
print(''''''.isspace())
print(''''''.isspace())
20. To retrieve the character at index 3 from string s="Hello" what command do we execute (multiple answers allowed)?
Read More Section(Strings in Python)
Each Section contains maximum 100 MCQs question on Strings in Python. To get more questions visit other sections.