Which of the following is the correct way to create a string in Python?
Select an option to see the answer and solution.
What is the output of the following code:
word = "Python"
print(word[2])
Select an option to see the answer and solution.
What does the len() function do when applied to a string?
Select an option to see the answer and solution.
Which character is used to access individual elements of a string by index in Python?
Select an option to see the answer and solution.
What will be the output of the following code:
string = "Python"
print(string[1:4])
Select an option to see the answer and solution.
What is the purpose of the str() function in Python?
Select an option to see the answer and solution.
Which of the following methods is used to find the index of the first occurrence of a substring in a string?
Select an option to see the answer and solution.
What is the output of the code:
string = "Python"
print(string[-2])
Select an option to see the answer and solution.
In Python, which escape sequence is used to represent a newline character?
Select an option to see the answer and solution.
What is the output of the following code:
string = "Python"
print(string.capitalize())
Select an option to see the answer and solution.
What method is used to convert a string to uppercase in Python?
Select an option to see the answer and solution.
Which method is used to replace a substring in a string with another substring?
Select an option to see the answer and solution.
In Python, how can you check if a string starts with a specific substring?
Select an option to see the answer and solution.
Which method is used to count the occurrences of a substring in a string?
Select an option to see the answer and solution.
What is the purpose of the strip() method for strings?
Select an option to see the answer and solution.
What is the output of the following code:
string = "Python"
print(string[::-1])
Select an option to see the answer and solution.
What will the following code output:
string = "Python"
print(string.lower())
Select an option to see the answer and solution.
In Python, which escape sequence is used to represent a tab character?
Select an option to see the answer and solution.
What does the isalpha() method of a string object check for?
Select an option to see the answer and solution.
What is the output of the following code:
string = "Python"
print(string[1:])
Select an option to see the answer and solution.