String Questions In Python. MCQs related to Strings in Python. For more MCQs on different Python topics see Python MCQs
String Questions In Python
What will be the output of the code in Python ??
print(“abcdef”.center(7, 1))
a) 1abcdef
b) abcdef1
c) abcdef
d) error
What will be the output of this code in Python ??
print(‘abc’.encode())
a) abc
b) ‘abc’
c) b’abc’
d) h’abc’
What will be the answer of the following Python code ??
print(‘*’, “abcde”.center(6), ‘*’, sep=”)
a) * abcde *
b) * abcde *
c) *abcde *
d) * abcde*
What will be answer of the following Python code ??
print(“xyyzxyzxzxyy”.count(‘xyy’, -10, -1))
a) 2
b) 0
c) 1
d) error
String Questions In Python
What will be answer of the following Python ??
print(‘*’, “abcdef”.center(7), ‘*’, sep=”)
a) * abcdef *
b) * abcdef *
c) *abcdef *
d) * abcdef*
What will be the output of the following statement in Python ??
print(“xyyzxyzxzxyy”.count(‘xyy’, 2, 11))
a) 2
b) 0
c) 1
d) error
What is the answer of following Python code ??
print(‘*’, “abcdef”.center(7), ‘*’)
a) * abcdef *
b) * abcdef *
c) *abcdef *
d) * abcdef*
What is the answer of following Python ??
print(“xyyzxyzxzxyy”.count(‘xyy’, 0, 100))
a) 2
b) 0
c) 1
d) error
String Questions In Python
What output will come using this statement ??
print(“abcdef”.center(0))
a) cd
b) abcdef
c) error
d) none of the mentioned
What will be the output of the following line ??
print(“xyyzxyzxzxyy”.count(‘yy’, 2))
a) 2
b) 0
c) 1
d) none of the mentioned
The correct ouptut will be ??
print(“abcdef”.center())
a) cd
b) abcdef
c) error
d) none of the mentioned
What will be the output of the following Python code ??
print(“xyyzxyzxzxyy”.count(‘yy’, 1))
a) 2
b) 0
c) 1
d) none of the mentioned
String Questions In Python
What will be the output of the following Python code ??
print(“abc. DEF”.capitalize())
a) abc. def
b) ABC. DEF
c) Abc. def
d) Abc. Def
What will be the output of the following Python code ??
print(“xyyzxyzxzxyy”.count(‘yy’))
a) 2
b) 0
c) error
d) none of the mentioned
What will be the output of the following Python code ??
print(“abc DEF”.capitalize())
a) abc def
b) ABC DEF
c) Abc def
d) Abc Def