91. What will be the output of the following Python code?
print('a B'.isalpha())
print('a B'.isalpha())
92. What function do you use to read a string?
93. What will be the output of the following Python code snippet?
print('abcdef12'.replace('cd', '12'))
print('abcdef12'.replace('cd', '12'))
94. What will be the output of the following Python code snippet?
print('abcdefcdghcd'.split('cd', 2))
print('abcdefcdghcd'.split('cd', 2))
95. What will be the output of the following Python code snippet?
print('Ab!2'.swapcase())
print('Ab!2'.swapcase())
96. What will be the output of the following Python code?
print("abcdef".center(7, 1))
print("abcdef".center(7, 1))
97. What will be the output of the following Python code?
class Name:
def __init__(self, firstName, mi, lastName):
self.firstName = firstName
self.mi = mi
self.lastName = lastName
firstName = "John"
name = Name(firstName, 'F', "Smith")
firstName = "Peter"
name.lastName = "Pan"
print(name.firstName, name.lastName)
class Name:
def __init__(self, firstName, mi, lastName):
self.firstName = firstName
self.mi = mi
self.lastName = lastName
firstName = "John"
name = Name(firstName, 'F', "Smith")
firstName = "Peter"
name.lastName = "Pan"
print(name.firstName, name.lastName)
98. What will be displayed by print(ord('b') - ord('a'))?
99. What will be the output of the following Python code?
print("xyyzxyzxzxyy".endswith("xyy"))
print("xyyzxyzxzxyy".endswith("xyy"))
100. What will be the output of the following Python code snippet?
print('The sum of {0} and {1} is {2}'.format(2, 10, 12))
print('The sum of {0} and {1} is {2}'.format(2, 10, 12))
Read More Section(Strings in Python)
Each Section contains maximum 100 MCQs question on Strings in Python. To get more questions visit other sections.