1. Which of the following is the correct way to create a string in Python?
2. What is the output of the following code:
word = "Python"
print(word[2])
word = "Python"
print(word[2])
3. What does the len() function do when applied to a string?
4. Which character is used to access individual elements of a string by index in Python?
5. What will be the output of the following code:
string = "Python"
print(string[1:4])
string = "Python"
print(string[1:4])
6. What is the purpose of the str() function in Python?
7. Which of the following methods is used to find the index of the first occurrence of a substring in a string?
8. What is the output of the code:
string = "Python"
print(string[-2])
string = "Python"
print(string[-2])
9. In Python, which escape sequence is used to represent a newline character?
10. What is the output of the following code:
string = "Python"
print(string.capitalize())
string = "Python"
print(string.capitalize())
Read More Section(Strings in Python)
Each Section contains maximum 100 MCQs question on Strings in Python. To get more questions visit other sections.