Vidyalelo
Python · all questions

MCQs for Python Strings: Exam
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

160

Questions

4/8

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following Python code?
print('{0:.2}'.format(1/3))

Select an option to see the answer and solution.

What will be the output of the following Python code?
print('xyxxyyzxxy'.lstrip('xyy'))

Select an option to see the answer and solution.

The format function, when applied on a string returns . . . . . . . .

Select an option to see the answer and solution.

What will be the output of the following Python code?
print("abc DEF".capitalize())

Select an option to see the answer and solution.

What will be the output of the following Python code?
print('ab,12'.isalnum())

Select an option to see the answer and solution.

What will be the output of the following Python code?
print("xyyzxyzxzxyy".count('yy', 2))

Select an option to see the answer and solution.

What will be the output of the following Python code?
print("abcdef".find("cd") == "cd" in "abcdef")

Select an option to see the answer and solution.

What will be the output of the following Python code?
print("Hello {0} and {1}".format(('foo', 'bin')))

Select an option to see the answer and solution.

What will be the output of the following Python code?
print("abcdef".center())

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>>example = "snow world"
>>>example[3] = 's'
>>>print example

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print('\t'.isspace())

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print('xyyxyyxyxyxxy'.replace('xy', '12', 0))

Select an option to see the answer and solution.

To concatenate two strings to a third what statements are applicable?

Select an option to see the answer and solution.

If a class defines the __str__(self) method, for an object obj for the class, you can use which command to invoke the __str__ method.

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print('{:#}'.format(1112223334))

Select an option to see the answer and solution.

Which of the following statement prints hello\example\test.txt?

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print('abc'.islower())

Select an option to see the answer and solution.

What will be the output of the following Python statement?
>>>print(chr(ord('b')+1))

Select an option to see the answer and solution.

What will be the output of the following Python code?
print("abcdef".center(10, '12'))

Select an option to see the answer and solution.

What will be the output of the following Python code?
print("Hello {0} and {1}".format('foo', 'bin'))

Select an option to see the answer and solution.