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

3/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('*', "abcdef".center(7), '*')

Select an option to see the answer and solution.

What will be the output of the following Python code?
print("xyyzxyzxzxyy".endswith("xyy", 0, 2))

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print('abcd'.translate('a'.maketrans('abc', 'bcd')))

Select an option to see the answer and solution.

Suppose i is 5 and j is 4, i + j is same as . . . . . . . .

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print('abcdefcdghcd'.split('cd'))

Select an option to see the answer and solution.

What will be the output of the following Python code?
print("ab\tcd\tef".expandtabs('+'))

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print('+99'.zfill(5))

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following Python code?
print('a'.maketrans('ABC', '123'))

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print('abcdefcdghcd'.split('cd', 0))

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following Python statement?
>>>"abcd"[2:]

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print('0xa'.isdigit())

Select an option to see the answer and solution.

The output of executing string.ascii_letters can also be achieved by:

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.

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("abcdef".center(7, '1'))

Select an option to see the answer and solution.