31. What will be the output of the following Python code snippet?
print('abcd'.translate({97: 98, 98: 99, 99: 100}))
print('abcd'.translate({97: 98, 98: 99, 99: 100}))
32. What will be the output of the following Python code snippet?
print('ab cd ef'.title())
print('ab cd ef'.title())
33. 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))
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))
34. What will be the output of the following Python code?
print("ab\tcd\tef".expandtabs(4))
print("ab\tcd\tef".expandtabs(4))
35. What will be the output of the following Python code?
print("Hello {0!r} and {0!s}".format('foo', 'bin'))
print("Hello {0!r} and {0!s}".format('foo', 'bin'))
36. What will be the output of the following Python code?
print('Hello!2@#World'.istitle())
print('Hello!2@#World'.istitle())
37. What will be the output of the following Python code snippet?
print('abef'.partition('cd'))
print('abef'.partition('cd'))
38. What will be the output of the following Python code?
print('*', "abcdef".center(7), '*', sep='')
print('*', "abcdef".center(7), '*', sep='')
39. What will be the output of the following Python code snippet?
print('11'.isnumeric())
print('11'.isnumeric())
40. What will be the output of the following Python code snippet?
print('HelloWorld'.istitle())
print('HelloWorld'.istitle())
Read More Section(Strings in Python)
Each Section contains maximum 100 MCQs question on Strings in Python. To get more questions visit other sections.