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

2/8

Page

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

Which method is used to split a string into a list of substrings based on a specified separator?

Select an option to see the answer and solution.

What is the purpose of the find() method for strings?

Select an option to see the answer and solution.

What is the output of the following code:
string = "Python is fun"
print(string.split())

Select an option to see the answer and solution.

In Python, how can you check if a string ends with a specific substring?

Select an option to see the answer and solution.

What is the purpose of the join() method for strings?

Select an option to see the answer and solution.

What is the output of the following code:
string = "Python"
print(string.find("th"))

Select an option to see the answer and solution.

Which method is used to remove leading and trailing whitespace from a string?

Select an option to see the answer and solution.

What will be the output of the following code:
string = "Hello, world!"
print(string.replace("o", "i"))

Select an option to see the answer and solution.

What is the purpose of the title() method for strings?

Select an option to see the answer and solution.

In Python, how can you check if a string contains only numeric characters?

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print('a@ 1,'.islower())

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>>example = "helle"
>>>example.find("e")

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', 100))

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print('abcd'.translate({'a': '1', 'b': '2', 'c': '3', 'd': '4'}))

Select an option to see the answer and solution.

What will be the output of the following Python code?
print('1Rn@'.lower())

Select an option to see the answer and solution.

What will be the output of the following Python code snippet?
print('1@ a'.isprintable())

Select an option to see the answer and solution.

What arithmetic operators cannot be used with strings?

Select an option to see the answer and solution.

What will be the output of the following Python statement?
>>>chr(ord('A'))

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.