A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

121. What is the output of the following?
print('abcdefcdghcd'.split('cd', 2))
a. [‘ab’, ‘ef’, ‘ghcd’].
b. [‘ab’, ‘efcdghcd’].
c. [‘abcdef’, ‘ghcd’].
d. none of the mentioned
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).[‘ab’, ‘ef’, ‘ghcd’].

122. What is the output of the following?
print('ab\ncd\nef'.splitlines())
a. [‘ab’, ‘cd’, ‘ef’].
b. [‘ab\n’, ‘cd\n’, ‘ef\n’].
c. [‘ab\n’, ‘cd\n’, ‘ef’].
d. [‘ab’, ‘cd’, ‘ef\n’].
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).[‘ab’, ‘cd’, ‘ef’].

123. What is the output of the following?
print('Ab!2'.swapcase())
a. AB!@
b. ab12
c. aB!2
d. aB1@
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).aB!2

124. What is the output of the following?
print('ab cd ef'.title())
a. Ab cd ef
b. Ab cd eF
c. Ab Cd Ef
d. None of the mentioned
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).Ab Cd Ef

125. What is the output of the following?
print('ab cd-ef'.title())
a. Ab cd-ef
b. Ab Cd-ef
c. Ab Cd-Ef
d. None of the mentioned
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).Ab Cd-Ef

126. What is the output of the following?
print('abcd'.translate('a'.maketrans('abc', 'bcd')))
a. bcde
b. abcd
c. error
d. bcdd
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).bcdd

127. What is the output of the following?
print('abcd'.translate({97: 98, 98: 99, 99: 100}))
a. bcde
b. abcd
c. error
d. none of the mentioned
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).none of the mentioned

128. What is the output of the following?
print('abcd'.translate({'a': '1', 'b': '2', 'c': '3', 'd': '4'}))
a. abcd
b. 1234
c. error
d. none of the mentioned
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).abcd

129. What is the output of the following?
print('ab'.zfill(5))
a. 000ab
b. 00ab0
c. 0ab00
d. ab000
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).000ab

130. What is the output of the following?
print('+99'.zfill(5))
a. 00+99
b. 00099
c. +0099
d. +++99
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).+0099

Page 13 of 13